0

Usually, visual studio puts output files to bin/debug or bin/release.

When solution contains a large number of projects its not easy to modify each project output manually.

Also edits in csproj files no desirable, because some of them is shared between solutions..

My questions: Is anybody knows a tool, which can quickly configure output path ?

UPDATE: my problem solved by TFS Build

gdbdable
  • 4,445
  • 3
  • 30
  • 46

2 Answers2

1

Customize your project using the msbuild properties which you can do if you follow these steps:

Go to the solution explorer and unload one project by right clicking on it and select Unload Project.

Then right click again on the unloaded project and select Edit Project. This will open the XML definition of your project, and you will have intellisense for the layout which will help you perform the next steps.

In the visual studio editor find the first PropertyGroup tag and add these lines near or at the end of the closing PropertyGroup tag:

<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<BuildDirectory Condition="$(BuildDirectory) =='' or $(BuildDirectory) == '*Undefined*'">$(SolutionDir)\build\</BuildDirectory>

The above SolutionDir is defined in msbuild properties which you can obtain using this answer: msbuild script using solution information and also check out the well known msbuild properties here

The next step is to find the OutputPath tag for each configuration and edit it like this:

<OutputPath>$(BuildDirectory)\x86\AutomatedDebug\</OutputPath>

The example above assumes you have a configuration named AutomatedDebug with destination platform x86.

The output will be

x:\projects\whereever-your-solution-is\build\x86\AutomatedDebug\

Repeat for each project.

To unload more than one project, collapse all projects in the solution explorer and shift click or ctrl click to select all or some projects, then right click on the selected group to unload, unfortunately you cannot do this for editing, at least in visual studio 2010.

I am the first to admit that this is somewhat cumbersome to do for existing projects, but you could easily create a visual studio project template that has these settings changed so that new projects will use a more convenient default output directory.

You cannot edit the output directory directly in visual studio because the project properties editor escapes any $() enclosed text.

Also you could only modify the OutputPath using the name of a system environment variable enclosed in $(). This last option is to enable a global output directory.

If you build any single project modified in this way using msbuild directly in the commandline the output directory will be created one directory above from where you ran msbuild

..\build\x86\AutomatedDebug

If you are in a team, you should warn them not to edit the output directory directly by hand, as this action will overwrite any customization.

Hope this info is useful. Greetings.

Community
  • 1
  • 1
jcastro
  • 11
  • 2
1

Presumably you have at least one project in each solution that is unique to that solution. In the Post-Build event of that, copy the contents of each project's output to the required location.

We often to this using a batch file. It's crude but effective. In our project that's unique to the solution we create a Release.bat file. This contains a number of file copies to copy all of the required components from the various output directories of the other projects. You can then just run the batch file in the post build event. We usually copy everything to a "Latest Release" fodler when the solution is built. If this becomes a proper release we will rename the Latest Release folder to the actual release number.

If you have multiple build configurations, or even just use the Debug and Release configurations, you can use an If statement in the Post-Build event to decide which batch file to run. So you could create a Debug.bat, Release.bat etc which do what you need. It can be tedious to set them up and get them working correctly at first, but they are very useful once fully implemented.

Tobsey
  • 3,390
  • 14
  • 24