Resolving file references in team build ( Part -2 )
<Reference
Include="Microsoft.TeamFoundation.VersionControl.Client,
Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<Private>false<Private>
<HintPath>d:\temp\Microsoft.TeamFoundation.VersionControl.Client.dll<HintPath>
</Reference>
$/MyProj2
│
├───CustomLibrary
│ │ CustomLibrary.sln
│ │ CustomLibrary.vssscc
│ │
│ ├─── CustomLibrary
│ │ │ CustomLibrary.csproj
│ │ │ CustomLibrary.csproj.vspscc
│ │ │ MyLibrary.cs
│ │ └───Properties
│ │ AssemblyInfo.cs
│
├───CustomApplication
│ │ CustomApplication.sln
│ │ CustomApplication.vssscc
│ │
│ ├─── CustomApplication
│ │ │ CustomApplication.csproj
│ │ │ CustomApplication.csproj.vspscc
│ │ │ Program.cs
│ │ └───Properties
│ │ AssemblyInfo.cs
│
├───binaries
<Reference
Include="CustomLibrary, Version=1.0.0.0,
Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\binaries\CustomLibrary.dll</HintPath>
</Reference>
- User needs to customize the build scripts of individual solutions to copy generated assemblies in the common binaries folder. This is to facilitate the assembly resolution of dependent projects. User can do this easily by adding a custom post build step in the csproj file. For example in our project we added the following target to CustomLibrary.csproj.
<Target Name="AfterBuild">
<Exec
Command="xcopy /Y /S /F $(TargetPath) $(SolutionDir)..\binaries" />
</Target>
- When creating the build type user make sure
- Template workspace selected should result in syncing of binaries folder on build machine.
- Ordering of solutions is proper. For example in our example, CustomLibrary.sln should be build before CustomApplication.sln
- In our example we do not need to define AdditionalReferencePath item but user can define new item to resolve references from different locations. For example user can additional define AdditionalReferencePath item in tfsbuild.proj.
<AdditionalReferencePath
Include="$(SolutionRoot)\Binaries ">
- Please note that there is a bug in Microsoft.TeamFoundation.Build.targets where value of ReferencePath is not evaluated properly. This is fixed in post beta3 bits. You need to make the following change in target "CoreCompile" :-
From:-
<CreateProperty
Condition=" '@(AdditionalReferencePath)'!='' "
Value="$(OutDir)%3B@(AdditionalReferencePath)"
...
To:-
<CreateProperty
Condition=" '@(AdditionalReferencePath)'!='' "
Value="$(OutDir);@(AdditionalReferencePath)" >
...