Team Foundation Server is a pretty sweet setup. It integrates source control into the Visual Studio IDE, and makes it easy for teams to work on projects together. With a little tweaking you can set up Continuous Integration and nightly builds. There are many different ways to set up your project layouts and references, which can make it easier to do deployments, etc. The one thing they forgot to mention is that, it is really easy with .NET projects. It gets a little hairy with Visual C++ projects.
What happens is that if you have VC++ projects that output libs (assemblies in .NET Land), and another project needs to reference them, you will probably run into pathing issues on your TFS buildserver.
TFS wants to output all the binaries to a specific folder. With VC++, there is a TFSBuild.props file that gets created dynamically that overrides the output folder (nice huh?). It is really a pain to try to override this yourself from what I have been researching. 20 different ways and no real solid method.
On your TFS server, in the path
C:Program FilesMSBuildMicrosoftVisualStudiov8.0TeamBuildMicrosoft.TeamFoundation.Build.targets
Is where all the settings are stored for how the builds happen.
There is a place in there where you can find the setting where the path gets overridden for VC++. It is set as $(OutDir)
When you make projects on your local machine, the output dir is set to $(SolutionDir)$(ConfigurationName)
Everything builds fine on your local machine, but once you try to set up a team build and have it build on the TFS server, it croaks, because the paths to libs arent the same.
Even though Microsoft says all over, never edit the .targets file, I did anyways, and all our projects build and have no issues on the TFS Server.
One other quick thing I have found different for VC++ projects compared to .NET projects. When you create a team build, you need to specify Win32 for the CPU target instead of the default Any CPU. Another quirk as usual 🙂
One reply on “TFS Team Build, TFSBuild.props and Visual C++”
I am agree with your points and appriciate. I am trying to build a VC++ project(with WIn32 CPU target) along with the C# project on MS Build 2008 which not causing any error but seems not building the VC++ project. VC++ project has certain post-build events which copies the binaries from $(SolutionDir)ReleaseU to some third party folder. While we queue the Nightly_build it copies all the solution to the build server and log says building AIMCEView but further no indication of running post build event. On build server Release folder doesn’t exist in VC++ directory which shows may be the solution is not getting build correctly. I made the following changes in TFBuild.Proj to build the VC++ project.
VCBuildToolPath=$(ProgramFiles)/Microsoft Visual Studio 9.0/VC/vcpackages
ReleaseWin32
ReleaseAny CPU
Please suggest me that using this way can we build the VC++ project?
Why post build events are not getting executed? Post build event of VC++ project has following commands
xcopy “$(SolutionDir)ReleaseUAIMCEView.pdb” “$(SolutionDir)../../Thirdparty/AIMCEView” /D /E /Y/R/F
xcopy “$(SolutionDir)ReleaseUAIMCEView.ocx” “$(SolutionDir)../../Thirdparty/AIMCEView”/D /E /Y/R/F
xcopy “$(SolutionDir)fpSpru70.ocx” “$(SolutionDir)../../Thirdparty/AIMCEView”/D /E /Y/R/F
Build gives no error, just win32release.txt gives the following warning at two times as two solution are getting build.
“The specified solution configuration “Release|Win32″ is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform=”Any CPU”) or leave those properties blank to use the default solution configuration.”
LikeLike