Project TargetDir on a TFS build server

I use Pre- / Post-build events in VS2012 project files to complete build tasks. This works fine locally, but I have a problem with our TFS 2012 Build Server.

Locally, $(TargetDir) for each project is installed in its own /bin .

However, on the build server, this is the only /bin outside the solution root folder in which it combines all the generated binaries.

This is not at all what I want!
I just want the build server to behave just like my VS2012 build.
There seems to be no settings in the build template that allows me to change this.

Can someone tell me how can I get the build server to output my binaries to a separate /bin for each project?

(FYI, the build server is configured to create a .sln file, not some additional MSBuild script.)

+6
source share
2 answers

TFS and Visual Studio use msbuild to create your solution, however the structure of the build exit folders is different. The reason the output is not in the same structure as VS is because the TFS build template overrides the $ (OutDir) property to point to the binaries folder of the build agent.

In TFS 2012 / .net 4.5, you can control this behavior by passing the msbuild argument in the assembly definition /p:GenerateProjectSpecificOutputFolder=true

See this blog for more information.

+7
source

This is because MSBuild and TFSBuild are two different products - on your local machine, MSBuild is used to create your projects.

One of the methods that I used to solve this problem should be a little more verbose and use a combination of ProjectDir and ConfigurationName . Here is an example when I copy some configuration files:

robocopy "$ (ProjectDir) bin \ $ (ConfigurationName)" "... destination folder ..." * .config

(Note that I deleted the target path, this was not essential for the example)

This works whether the build is configured for AnyCPU or x86 / 64 due to Microsoft's agreement to include a slash as part of the folder name.

+2
source

Source: https://habr.com/ru/post/957181/


All Articles