Hi,
I hope you can help me with this problem:
I set up a Team Build-Server. Basically, it works, my small test-project is building fine. But with our real C++-application there are some problems:
- Some of our projects are generating libs as output-files and have a common folder set as the folder where the final .lib should be stored. This folder is not under source-control, because it is empty. Now, when one of these projects is built, it tries to create this folder but it fails, because its parent-folder is read-only. I created a work-around and checked this empty folder in. But I think that's not very nice.
- Our projects require an external library. To use this library they have to include some files. These files are under Source-Control for the mere reason that everything needed to compile is under Source-Control (we never change these files though). The path to these files is set as a global include-directory under Tools -> Options -> Projects and Solutions -> VC++ Directories and we include those files via #include <...>. When building the projects with VisualStudio on the machine where the TeamBuild-service is running, everything works like a charme, but the TeamBuild-service failes to find these files. How to tell him, where to find them
- We have one Team project which consists of 3 branches of the same application. I would like to create seperate Team Builds for every branch. Basically it works (I select just the solutions, I want to be built), but it always checks out the complete source-tree (the 2 branches I am not building, too). This is an extreme overhead and costs a lot of time. How to change this
Thank you for any answer,
Daniel Hilgarth

Three problems with Team Build: read-only paths, missing include paths and huge checkouts
AnthonyS
Hi,
Thanks a lot for your answer, this is working (I guess). But now it seems, as if the additional include-directories which are specified in the project-files are no longer used.
How to fix this new problem
Gary M.
Hi,
the problem with include-files still is unsolved. I added this to my teambuild-file:
<
AdditionalReferencePath Include="c:\path\boost_1_33_1" />In this directory, there is a directory called boost. Nevertheless, I get the same compile-errors:
fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory.
Please help, this is rather urgent.
Kind regards,
Daniel
InfoseekerExtra
Does the SetEnvironmentVariable apply throughout the build, including when the test portion of the build starts
I have a build which its tests need to know where the build output is placed through use of an environment varialbe. If I only had one build type it wouldnt be a problem, but I have 4 branches of the same build building on my build machine, with their outputs being placed in different directories, and the same tests need to be able to execute on all of them... any ideas
TJ9139
2) Use "AdditionalReferencePath" itemgroup to specify the location for referenced assemblies and resources. Reference -(tfsbuild.proj) - http://blogs.msdn.com/manishagarwal/archive/2006/01/04/509125.aspx
3) To avoid getting specific folders under team build - Reference :- http://blogs.msdn.com/manishagarwal/archive/2005/10/13/480584.aspx
Zhou Justin
Daniel,
Yes. That is a problem. Here is another ( slightly more complex) way you can solve your issue without overriding the existing AdditionalOverrides property , by adding your global include path to the INCLUDE environment variable.
You have to make modifications to your Microsoft.TeamFoundation.Build.targets file in "Program Files\MSBuild\Microsoft\VisualStudio\v8.0\TeamBuild\" . This file is a common file used by all the TeamProjects in a build. So please ensure that you do the changes carefully and also make a backup of the file before modification.
Step 1) Add a Property say (MyCustomBuildProperties) in an existing PropertyGroup or to a new PropertyGroup
<PropertyGroup>
<MyCustomBuildProperties></MyCustomBuildProperties>
</PropertyGroup>
** In the next release of TFS there will be a property in this file predefined that can be used to pass properties to msbuild command but for now this will have to done explicitly.
Step 2) Inside the CoreCompile target in the same file add the new Property to the list of properties of the MSBuild task that used for compilation -
<!-- Build using MSBuild task -->
<MSBuild
Condition=" '@(SolutionToBuild)'!='' "
Projects="@(SolutionToBuild)"
Properties="$(MyCustomBuildProperties);Configuration=$(FlavorToBuild);Platform=$(PlatformToBuild);SkipInvalidConfigurations=true;VCBuildOverride=$(MSBuildProjectDirectory)\TFSBuild.vsprops;FxCopDir=$(FxCopDir);OutDir=$(OutDir);ReferencePath=$(ReferencePath);TeamBuildConstants=$(TeamBuildConstants);$(CodeAnalysisOption)"
Targets="Build" />
Step3)Now you can pass any properties to the msbuild task from your tfsbuild.proj file by overriding the "MyCustomBuildProperties".
Edit the TfsBuild.proj file and override the MyCustomBuildProperties property as
<MyCustomBuildProperties>VCBuildAdditionalOptions=/useenv</MyCustomBuildProperties>
By setting this option Vcbuild will use the INCLUDE environment variable during the build.
Step4) Now we have to set the environment variable INCLUDE by adding your global search path to it before the build starts.
a)For this you will need to author a msbuild task that sets a given environment variable. You can find the code for the task at
"http://blogs.msdn.com/msbuild/archive/2006/01/21/515834.aspx" . You can use this code compile it to as a csharp library (say SetENv.dll) and check the dll into the <YourTeamPRoject>\TeamBUildTypes\<YourBuildType> folder.
b) After this edit your TfsBuild.Proj again and override the BeforeCompile target as follows.
(Since TeamBuild kicks off a build in a dos cmd we need to explicitly set the required env variables if we use the /useenv option of vcbuild. For this set a global system environment variable VCInstallDir to "<YourVSDrive>\Program Files\Microsoft Visual Studio 8\" )
<UsingTask TaskName="SetEnvironmentVariable"
AssemblyFile="SetEnv.dll" />
<Target Name="BeforeCompile" >
<!-- Set the Path, LIB and INCLUDE to the values of a visual studio cmd env -->
<SetEnvironmentVariable
Condition=" '$(IsDesktopBuild)'!='true' "
Name="PATH"
Value="$(VCInstallDir)Common7\IDE;$(VCInstallDir)VC\BIN;$(VCInstallDir)Common7\Tools;$(VCInstallDir)Common7\Tools\bin;$(VCInstallDir)VC\PlatformSDK\bin;$(VCInstallDir)SDK\v2.0\bin;$(PATH)" />
<SetEnvironmentVariable
Condition=" '$(IsDesktopBuild)'!='true' "
Name="LIB"
Value="$(VCInstallDir)VC\ATLMFC\LIB;$(VCInstallDir)VC\LIB;$(VCInstallDir)VC\PlatformSDK\lib;$(VCInstallDir)SDK\v2.0\lib;$(LIB)" />
<SetEnvironmentVariable
Condition=" '$(IsDesktopBuild)'!='true' "
Name="INCLUDE"
Value="$(VCInstallDir)VC\ATLMFC\INCLUDE;$(VCInstallDir)VC\INCLUDE;$(VCInstallDir)VC\PlatformSDK\include;$(VCInstallDir)SDK\v2.0\include;$(INCLUDE);$(MYPATH)" />
<SetEnvironmentVariable
Condition=" '$(IsDesktopBuild)'=='true' "
Name="INCLUDE"
Value="$(INCLUDE);$(MYPATH)"/>
</Target>
Check in the TfsBuild.proj file and fire off a build to ensure that changes you have made haven't introduced any errors.
Please let me know if anything is unclear.
Thanks,
Chaitanya
Staceyd
Hi Daniel
TeamBuild generates a TFSBuild.vsprops file which contains overrides for VC++ projects. To solve your issue, you will need to override the AdditionalIncludeDirectories property of the VCCLCompilerTool Tag. The TFSBuild.vsprops file is not a static file but is generated by TeamBuild dynamically for each platform/flavor configuration. So in order to allow a user to provide additional overrides (over and above what TeamBuild already overrides) a property called AdditionalVCOverrides has been provided. You should assign a string that will override the AdditionalIncludeDirectories property to the AdditionalVCOverrides property.
Simply put this means adding the following line to your TFSBuild.vsprops file
<Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="$(YOUR_ENVIRONEMENTVARIABLE_USED_FOR_THE_PATH)" />
To add this you will need to edit your TFSBuild.proj file and add the following lines.
Since this is an string containing xml tags we need to escape some of the special characters (like <, >,),(, " etc)
<PropertyGroup>
<AdditionalVCOverrides>%3CTool Name=%22VCCLCompilerTool%22 AdditionalIncludeDirectories=%22$%28YOUR_ENVIRONEMENTVARIABLE_USED_FOR_THE_PATH%29%22 /%3E%0D%0A</AdditionalVCOverrides>
</PropertyGroup>
some common escape sequences (includes all the ones I have used) can be found at
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnmbscrm1_2/html/mbs_crmreportsfromurl.asp
I have tried this out on my dev box and it works so hopefully this should solve your problem.
After doing this fire off a build and ensure that the TFSBUild.vsprops file in the BuildType dir contains the new AdditionalIncludeDirectories tag. Also if you are adding a new environment varialbe for this purpose, you will need to restart the TeamBuildService on your BuildMachine.
Thanks,
Chaitanya
Jasen Bankson
Ok. You get this error when the proper VC++ paths are not in the PATH environment variable.
The statement
<!-- Set the Path, LIB and INCLUDE to the values of a visual studio cmd env -->
<SetEnvironmentVariable
Condition=" '$(IsDesktopBuild)'!='true' "
Name="PATH"
Value="$(VCInstallDir)Common7\IDE;$(VCInstallDir)VC\BIN;$(VCInstallDir)Common7\Tools;$(VCInstallDir)Common7\Tools\bin;$(VCInstallDir)VC\PlatformSDK\bin;$(VCInstallDir)SDK\v2.0\bin;$(PATH)" />
is supposed to set the PATH to the proper values.
Have you set VCInstallDir to the proper system environment variable that equals to "<YourVSDrive>\Program Files\Microsoft Visual Studio 8\" Also you will need to restart the TEamBuildService for the environment variable to be show itself in the build process.
The BeforeCompile is an empty target defined in the targets file. You can directly use it in your TfsBuild.proj file so that it gets overridden. Place the override of the BeforeCompile target at the end of the TfsBuild.proj file rather than at the beginning so that your overriden target comes after the import statement of the targets file.
Let me know how this goes.
Thanks,
Chaitanya
Timo van Noppen
wow... This is getting more and more complicated... And still it is not working!
The BeforeCompile-target I added to the targets-file, because in the proj-file there was no such target.
For every project now I am getting the following:
Solution: xxx.sln, Project: yyy.vcproj, Compilation errors and warnings
Project(0,0): error PRJ0003: Error spawning 'cl.exe'.
:(
The same happens, if I add BeforeCompile to the proj-file......
Naama Zarfati
Daniel,
I am so sorry daniel, I replied rather quickly without reading your scenario properly.
Actually C++ projects are build (vcbuild) in a different way (than csproj/vbproj/webproj etc). The additional properties are passed using TFSBuild.vsprops file which is generated on the fly by the build process (refer corecompile target in msft.teamfoundation.build.targets file).
This overrides file is passed to the msbuild task using the following option in core compile target - VCBuildOverride=$(MSBuildProjectDirectory)\TFSBuild.vsprops
We will investigate this issue and get back to you ASAP.
Regards
Eamonn Turley
1. What you describe is a good way to tackle the situation. Or you could also create the folder outside the Sources branch using a custom task before the get happens.
2. Team Build has no knowledge of the global reservation path - hence this file is not found. You need to include these files in any of the folders in the generic Path env variable or put it in the same directory as the solution that references these
3. If you want to sync only certain solutions, you need to create explicit workspaces for those. Check out this entry for more info.
Hope that helps.
Chris Berg
1. ok.
2. "You need to include these files in any of the folders in the generic Path env variable" -> how to Your second suggestion sure is no option ;)
It's a bit poor that TeamBuild has no built-in way to handle this. Such an expensive tool, but can't handle everyday-issues for C++-projects.
3. Thanks, I will have a look.