I'm trying to organize my workspace and want my intermediate objects to be put in the ..\build\obj
folder in relation to my .csproj file. So I put:
<IntermediateOutputPath>..\build\obj\Debug</IntermediateOutputPath>
in the .csproj file. The intermediate objects are now put in that location when the solution is built, but the problem is that an obj
directory is still created in the directory the .csproj file is in (something to the effect of obj\Debug\T开发者_StackOverflow中文版empPE
) when the solution is opened. What is this directory for, and how can I relocate it?
You could try to do this (don't forget that there are Debug and Release sections which will be used depending on what type of build you are targeting):
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<BaseIntermediateOutputPath>..\build\obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
<BaseIntermediateOutputPath>..\build\obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
Do this like Microsoft:
<PropertyGroup>
<IntermediateOutputPath Condition=" '$(PlatformName)' == 'AnyCPU' ">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition=" '$(PlatformName)' != 'AnyCPU' ">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
According to this post, a file named Directory.Build.props
can be created in the folder that containes the .csproj
project file. In order to relocate the obj
folder, we can add
<BaseOutputPath>..\Build</BaseOutputPath>
to the PropertyGroup
section in .csproj
project file, and write
<?xml version="1.0"?>
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>..\Intermediate\obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
<!--The following is the default configuration for "MSBuildProjectExtensionsPath"-->
<!--<MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>-->
</PropertyGroup>
</Project>
to the Directory.Build.props
file.
I've used:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>$(OBJDIR)\$(SolutionName)\bin\$(Configuration)\</OutputPath>
<BaseIntermediateOutputPath>$(OBJDIR)\$(SolutionName)\obj\$(Configuration)\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
(In Visual Studio 2012 Beta, FWIW), and it works fine.
The OBJDIR on my machine points to E:\BuildOutput
.
精彩评论