Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force VS2010 to keep the build output path absolute

We want to have our build server send the output of each build to
C:\Projects\{project name}\build\{build configuration}\.

To accomplish this, I set the Build Output path property for my projects to that in Visual Studio 2010, and build locally to make sure everything works. When I do so, visual studio changes the path to a relative one, for example ..\..\build\Debug.

Since the project directory is not the same on the build server (we use TeamCity, so the project url there is something like C:\BuildAgent\work\9358A92GF92), the output doesn't end up where we want it.

How do I make Visual Studio not change the build output paths to relative paths?

like image 356
Tomas Aschan Avatar asked Jul 07 '10 11:07

Tomas Aschan


2 Answers

You cannot convince the IDE to make it absolute. Possible solutions:

  1. Use a post-build event to xcopy the build output
  2. It won't make the path relative if the output directory is on another drive. You could use the SUBST command to map a drive letter like z: to a folder on c: and fool the IDE that way
  3. Run msbuild.exe directly on the build machine. Use the /p command line option to force the OutDir property to another value.

Solution 3 is probably best since you can make it specific to the build machine without tinkering with the project files and make the devs' lives difficult. The command should look similar to this:

 msbuild /p:outdir=c:\mumble\ projectOrSolutionFileName

Beware that the output directory name must end with a trailing backslash

like image 74
Hans Passant Avatar answered Oct 15 '22 15:10

Hans Passant


You can not convince IDE to use absolute path, but you can change the Project file:

<OutputPath>C:\Dir1\Dir2</OutputPath>

Your IDE will still show relative path but it will store the absolute path.

Works for me with Visual studio 2010 Sp1

like image 3
Alexander Bartosh Avatar answered Oct 15 '22 13:10

Alexander Bartosh