Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move intermediates directory on C# projects in Visual Studio

I'm currently in the process of stripping down, refactoring and cleaning up a medium sized (15 ish projects) Visual Studio solution. The solution contains projects in both C++ and C#.

I'm keen to keep things as neat as possible in terms of output - seperating anything compiler created from source code, as it helps subversion (okay, I can tell it to ignore files, but I still feel it's messy) from freaking out.

The output I would like to achieve is as follows:

SolutionDir/
SolutionDir/src/project1/{ Code here }
SolutionDir/int/project1/configuration/{.obj files and other misc compiler junk here}
SolutionDir/bin/project1/configuration/{The fun stuff goes here}

This seems trivial with C++ projects as you can specify both the output and the intermediates directory. However with C#, at least through the Visual Studio 2008 User Interface it seems impossible to move the obj directory?

After doing some digging, I added

<IntermediateOutputPath>..\..\int\ProjectName\Debug\</IntermediateOutputPath>

to the C# .csproj

This appears to work, sort of. It's true the intermediates appear to end up there, but a directory 'obj' and under it a configuration directory (e.g. 'debug') and then a 'TempPE' directory are created in the old location - all of which are empty.

This isn't really a big deal, but it would be nice to know the cause of this behavior and if possible a way to fix it.

Thanks in advance!

like image 935
Ali Parr Avatar asked May 02 '09 15:05

Ali Parr


People also ask

How do I change the solution path in Visual Studio?

In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.

What is Copytooutputdirectory?

"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.

What is OutDir Visual Studio?

$(OutDir) is a Visual Studio Build Property Macro. You can see the values of macros using the Macros >> button in many Properties dialogs. For instance, in Properties->General->Output Directory, click the dropdown in the value text box, choose Edit..., and in the resulting dialog, click the Macros >> button.


1 Answers

If you add both of the following lines to each build configuration then the "obj" folder is not created by default and there is no need for a post-build action:

<IntermediateOutputPath>Assembly\obj\Debug\</IntermediateOutputPath>
<BaseIntermediateOutputPath>Assembly\obj\Debug\</BaseIntermediateOutputPath>

SVN / SCC ignore properties are also useful if desired

like image 59
sean2078 Avatar answered Oct 13 '22 22:10

sean2078