Thursday, October 25, 2007

AfterCompile vs AfterCompileSolution

I ran into something with Team Build 2008 that burnt me up for pretty much a whole day. I was using the AfterCompileSolution target (as I saw suggested) to run the building of our setup projects (because MSBuild doesn't support setup projects - how can an open source setup project engine - wix - support MSBuild and MS does support them is beyond me). Anyway, I am also using the AssemblyInfoTask to increment our version numbers. So the $(MaxAssemblyVersion) is always blank. Even though I went into the blah.blah.Versioning.targets and spit it out there and it gives me the 5.0.0.10 I am expecting. So, WTF.

Dunno, but apparently something is out of scope, so if I go back to "AfterCompile" instead of "AfterCompileSolution" then it's back, but now $(Platform) is gone.

????

<Target Name="AfterCompile">

<DevEnv TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Solution="$(Solution)"
SolutionConfiguration="Setup"
SolutionPlatform="Any CPU"
Target="Build"
Version="9" />


<WorkspaceItemConverterTask
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
WorkspaceName="$(WorkspaceName)"
WorkspaceOwner="$(WorkspaceOwner)"
ServerItems="$/Trimble.MobileSolutions/current">
<Output TaskParameter="LocalItems" ItemName="LocalDirectory" />
</WorkspaceItemConverterTask>

<Exec WorkingDirectory="$(SolutionRoot)"
Command="$(TF) checkin /comment:"Auto-Build: Version Update" /noprompt /override:"Auto-Build: Version Update $(MaxAssemblyVersion)" /recursive $(AssemblyInfoSpec)"
ContinueOnError="true" />

<PropertyGroup>
<LocalDirectoryAsProperty>@(LocalDirectory->'%(FullPath)')</LocalDirectoryAsProperty>
</PropertyGroup>


<CreateItem Include="$(LocalDirectoryAsProperty)\**\product\setup\**\*.msi">
<Output TaskParameter="Include" ItemName="MsiFiles"/>
</CreateItem>

<!--<Copy SourceFiles="@(MsiFiles)" DestinationFolder="$(DropLocation)\xx.$(MaxAssemblyVersion).xx" />-->
<Copy SourceFiles="@(MsiFiles)" DestinationFolder="$(DropLocation)\$(MaxAssemblyVersion)\%(FilesToArchive.RecursiveDir)"/>
<!--<Copy SourceFiles="@(MsiFiles)" DestinationFolder="$(DropLocation)\$(MaxAssemblyVersion)\%(RecursiveDir)" />-->


</Target>

Tuesday, October 23, 2007

MsBuild and CopyLocal = False

As MsBuild rolls thru building a solution, it calls GetCopyToOutputDirectoryItems as a task (subtask) for each project reference during the CoreCompile task.

If you are using a "build all to one directory" strategy, this is a waste. To change the net effect of this, change all project references to CopyLocal = false.

This decreased our build time from almost 3 minutes to just over 2 minutes.