This project has moved and is read-only. For the latest updates, please go here.

How to change directory where output files are placed?

Aug 20, 2014 at 10:46 AM
The directories obj and bin are created in the python project folder.

Is there any way to place it elsewhere?

For standard c++ project we usually place them outside the project to some directory like .out via "Output Directory" and "Intermediate Directory" options. We would like to keep the project directory clean (easier custom deployment, ...).

Pavel Machyniak
Aug 20, 2014 at 6:11 PM
PTVS uses Microsoft.Common.targets, same as C# and VB projects, so it shares the default setup with them, and same customization techniques can be applied. The obj directory, in particular, is the default value of the BaseIntermediateOutputPath MSBuild property, which you can override in your project file.

If I remember correctly, bin only shows up for web and cloud service projects (and even then only used for publishing and running under Azure emulator). That one is not customizable, because that folder hierarchy has to be maintained on publish destination for things to work.
Marked as answer by machyniak on 8/21/2014 at 2:41 AM
Aug 20, 2014 at 6:41 PM
We should support setting OutputPath and IntermediateOutputPath in the project file. I believe OutputPath is already in the templates, but is empty and generally unused.

These haven't had much testing outside of web projects, where as pminaev says we have to adhere to the layout required by the publishing tools, so you may find some bugs once you start changing them. Let us know if you do - we'd love to fix them, and we can normally provide workarounds or manual fixes for bugs in MSBuild files.
Aug 20, 2014 at 6:48 PM
It seems like we do actually support IntermediateOutputPath (largely because we just use it in our .targets, and rely on Common.targets to set it).
Aug 21, 2014 at 10:41 AM
Edited Aug 21, 2014 at 10:42 AM
Thanks for the help.

To clarify the situation:
  • we are currently using MSVS2010
  • it is django python web project
In our project file *.pyproj there was option <OutputPath>.</OutputPath> already. Modifying this settings does nothing, except that the specified directory is created.

After adding <BaseIntermediateOutputPath>..\..\..\.out\code\server\web</BaseIntermediateOutputPath> and OutputPath to the same directory, the files are created at the correct place.

  • Debug/Release configuration sub directories are created there as well
  • Using $(ProjectDir) for rooting the path did not work, the files were created in the root of the drive
  • Alternatively using IntermediateOutputPath instead of BaseIntermediateOutputPath and adding $(Configuration) at the end of the path works the same way
  • The bin directory is unfortunately still in the project directory, created when running the web project
Aug 21, 2014 at 5:59 PM
Those notes are all expected behaviour except for ProjectDir not working. I'll create an issue to look into that.
Aug 21, 2014 at 6:48 PM
It looks like the value of $(ProjectDir) depends on where you use it. Because we only have the one targets file, it is undefined before we import it, but it is defined after the import. However, all processing of BaseIntermediateOutputPath has happened by this point, so you can probably only change IntermediateOutputPath by then.

However, all paths should be automatically rooted in $(ProjectHome) (or more strictly, $(QualifiedProjectHome), which is only defined after the import). This includes input files, and is our mechanism for keeping the .pyproj file separate from the source files. So if you're okay with paths being relative to ProjectHome, then you can just specify them as relative.