Reputation: 3775
I am going to have a fairly large solution, with many projects in it, and there are reasons while I my folders with source code in it must have no .obj or .exe or .dll files at any point. So, I came up with this structure:
SolutionDirectory
|- MainProject
|- MainProject.csproj
|- Main.cs
...
|- FirstSlaveProject
|- FirstSlaveProject.csproj
...
|- SecondSlaveProject
|- SecondSlaveProject.csproj
...
|- BuildFolder
|- MainProject
|- bin
|- obj
|- FirstSlaveProject
|- bin
|- obj
|- SecondSlaveProject
|- bin
|- obj
...
The idea is that all source files are inside projects' folders, and all binaries go to "BuildFolder", sorted by project's name. Seems pretty reasonable, right?
So, I reckon when I create a new project inside my solution, I have to write somewhere something like this: %SolutionFolder%\BuildFolder\%ProjectName%\%ProjectConfigName%\bin" and "%SolutionFolder%\BuildFolder\%ProjectName%\%ProjectConfigName%\obj
.
So, where exactly do I write this (and I hope I don't have to write it for each Debug, Release, UnstableSpeedup, etc. configuration separately!), and how exactly? I doubt Visual Studio will recognize %SolutionFolder
.
Is there maybe some sort of a shell script, or a Visual Studio addin, or whatever?
Upvotes: 1
Views: 715
Reputation: 3775
I open the .csproj file and insert this:
<PropertyGroup>
<OutputPath>$(SolutionDir)BuildFolder\$(MSBuildProjectName)\$(Configuration)-$(Platform)\bin\</OutputPath>
<IntermediateOutputPath>$(SolutionDir)BuildFolder\$(MSBuildProjectName)\$(Configuration)-$(Platform)\obj\</IntermediateOutputPath>
</PropertyGroup>
after the last PropertyGroup
tag.
I tested it, and the EXE file indeed appeared inside "SolutionDirectory\BuildFolder\MainProject\Debug-x86\bin"
, and all intermediate stuff went to "SolutionDirectory\BuildFolder\MainProject\Debug-x86\obj"
. Visual Studio still creates an empty "obj" directory inside my source tree though... whatever, since it's empty, it's not a big deal.
Upvotes: 0
Reputation: 210
Once the project is created, right click on the project, then click Properties. On the build tab is a box for the output path.
I don't know if there is a way to automate it for each project.
Upvotes: 1