62

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...

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
Joel in Gö
  • 7,460
  • 9
  • 47
  • 77

6 Answers6

87

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.

Sören Kuklau
  • 19,454
  • 7
  • 52
  • 86
  • 2
    As an addition, if you have the Visual Studio Power Commands installed (available from http://code.msdn.microsoft.com/PowerCommands), you can edit the project file within Visual Studio (right-click, Edit project file). +1 for the link and the bug note. – OregonGhost Nov 04 '08 at 10:55
  • 2
    More than 10 years later: still a bug :( – A K Sep 26 '20 at 09:19
  • It's 2022, still a bug... – Sharif Yazdian Apr 13 '22 at 13:03
28
  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
    
Richard Gadsden
  • 839
  • 1
  • 6
  • 22
Dominik Antal
  • 3,281
  • 4
  • 34
  • 50
5

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.

Alexander Kojevnikov
  • 17,580
  • 5
  • 49
  • 46
1

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).

fhe
  • 6,099
  • 1
  • 41
  • 44
  • 4
    This is only for "bin" directory. Not for "obj". – TcKs Nov 04 '08 at 10:25
  • I've set both Output Directory and Intermediate Directory to a specific path and all *.obj files are stored at this location. – fhe Nov 04 '08 at 10:33
  • For C#, it appears one only needs to set the BaseIntermediateOutputPath Directory, as noted in Soren's post. – AnneTheAgile Aug 20 '12 at 19:42
0

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

enter image description here

pixelgrease
  • 1,940
  • 23
  • 26
  • This thread came up when I was searching the answer for MSVC 2013 and I just spent an hour unsuccessfully trying to get `BaseIntermediateOutputPath` to work when I discovered this setting which worked immediately. BTW, E: is a RAM drive on my system. – pixelgrease Jan 14 '21 at 21:21
0

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.

TTT
  • 22,611
  • 8
  • 63
  • 69