Reputation: 5006
I have a solution containing a large number of projects.
To separate binaries from the sources, I changed BaseOutputPath
to "..\bin" and BaseIntermediateOutputPath
property in all projects to "..\obj".
It worked for the BaseOutputPath
- all binaries are in the common directory.
For the intermediate path it didn't work at all. It broke the projects, because the obj
directory is still created in the project folders, but now the files are not excluded from the project and appear as commitable for Git.
What am I doing wrong? Is it normal behavior? I don't want obj directories created in project directories. How can I achieve that behavior?
For now I just removed the property from projects. At least the obj
folders are not shown as project folders.
Upvotes: 1
Views: 1433
Reputation: 2085
You need to use MSBuild macros such as $(SolutionDir) or $(MSBuildThisFileDirectory) and similar, if you do not want relative paths to start from your project file.
For example, you could set "BaseIntermediateOutputPath" to $(SolutionDir)\obj or better still to $(SolutionDir)\obj-$(Configuration). This way you will separate Debug and Release builds, which, if you don't, will get you into a lot of trouble.
Here is what I use in a particular "Directory.Build.props". Note the <OutDir>
entry. This will change the output directory for all projects under this directory to the stage64\lib
directory.
<PropertyGroup>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<OutDir>$(SolutionDir)..\stage64\lib\</OutDir>
</PropertyGroup>
Upvotes: 0