Joel in Gö
Joel in Gö

Reputation: 7570

VisualStudio: How to save the obj folder somewhere else

Does anyone know how to tell VS(2008) where to save the obj folder when building the solution? We have it save the bin folder to another path in order to keep the source file folders small (ie. emailable), but can't find any way to tell it to do the same with obj...

Upvotes: 62

Views: 45619

Answers (6)

TTT
TTT

Reputation: 28944

I'd like to offer a slight tweak to some of the existing answers, so that your drive letter can be dynamic:

<BaseIntermediateOutputPath>$(ProjectDir.Substring(0,2))\Publish\Web\obj\</BaseIntermediateOutputPath>

This is helpful because if you hardcode a drive letter, and you open the project on a machine that doesn't have that drive letter, Visual Studio will automatically modify your project file to use a temporary location that your user has access to. This issue can be avoided by dynamically selecting the current drive letter, using the first 2 characters of the $(ProjectDir) variable.

Upvotes: 0

pixelgrease
pixelgrease

Reputation: 2118

In Visual Studio 2013, this is specified in project "Configuration Properties/General/Intermediate Directory".

enter image description here

Upvotes: 0

Dominik Antal
Dominik Antal

Reputation: 3391

  1. You add this to your project file below <OutputPath> tag:

    <IntermediateOutputPath>..\Whatever\obj\</IntermediateOutputPath>
    
  2. VS will still create obj folder , so you have to delete it every time after a build. This can be done by putting the following script to the post-build part in VS :

    rd "$(ProjectDir)obj" /S /Q
    

Upvotes: 29

fhe
fhe

Reputation: 6187

It's the Output Directory under Properties > General of the project settings.

Edit: it seems like there is a difference between the project settings for native C++ projects (which I'm using) and CLR based projects (which might be what the OP is referring to).

Upvotes: 1

Alexander Kojevnikov
Alexander Kojevnikov

Reputation: 17732

Do you use version control? If you do, there's an alternative:

You can exclude bin/ and obj/ from version control and check out your project instead of e-mailing. If you use Subversion, you could also Export your project and e-mail the exported and zipped folder.

Upvotes: 5

S&#246;ren Kuklau
S&#246;ren Kuklau

Reputation: 19930

Use the BaseIntermediateOutputPath property in the project file (.csproj, .vbproj, etc.), as explained at http://msdn.microsoft.com/en-us/library/bb629394.aspx. You'll have to manually edit the XML document using a text editor, then reload it in Visual Studio. It may still create the obj folder (that's a known bug), but will leave it empty and put the actual obj files in your specified folder.

Upvotes: 88

Related Questions