Is there a way to tell Visual Studio to use a different location for the bin
and obj
directories?
For example, if my project is in C:\my\myprojects.csproj, how can I have the obj
and bin
directories in, say, D:\otherdirectory\bin and D:\otherdirectory\obj. The Visual Studio project option offer only to redirect the bin
directory, not the obj
directory.
Also, bonus question: Can I use environment variables, not full or relative paths?
Is this possible?
The obj directory is for intermediate object files and other transient data files that are generated by the compiler or build system during a build. The bin directory is the directory that final output binaries (and any dependencies or other deployable files) will be written to.
Delete bin and obj foldersThe bin and obj folders are usually safe to delete since they are automatically generated when the solution/project is being build by Visual Studio/MSBuild. This feature is off by default, but can easily be enabled in the settings.
"obj" folder is used to store temporary object files and other files used to create the final binary.
Refer to this article and use the nodes BaseOutputPath (for the bin
folder) and BaseIntermediateOutputPath (for the obj
folder) in the .proj file.
Given below is a way to modify your debug and release folders relative to bin
-
In Solution Explorer, select the C# project you want to configure build parameters on.
Next, from the Visual Studio menu bar, select Project → Properties. The Property Pages dialog will appear for your project.
Choose the Configuration (Release/Debug) you want to change and expand the Configuration Properties node in the left hand pane. Select the Studio is placed in the "Output path" attribute of the Outputs property sheet.
Be aware that the output path is specified separately for each kind of build configuration, and that setting it on one configuration doesn't set it on all the remaining ones.
Original source - http://www.eggheadcafe.com/software/aspnet/32040244/how-to-change-the-obj-folder.aspx
To move obj
directories out of your code base to another common folder you can do the following. Create Directory.Build.props
in the root directory of your solution with the following content:
<Project> <PropertyGroup> <BaseIntermediateOutputPath>$(SolutionDir)\_Obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath> </PropertyGroup> </Project>
To keep folder structure in your common obj
directory the same as in your solution you can create files with the same and similar content in every subfolder of your solution. E.g. If you have subfolder Algorithms
which contains several projects you can put file with the following content into it:
<Project> <PropertyGroup> <BaseIntermediateOutputPath>$(SolutionDir)\_Obj\Algorithms\$(MSBuildProjectName)\</BaseIntermediateOutputPath> </PropertyGroup> </Project>
Use BaseOutputPath
for bin
folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With