问题
I'm using Visual Studio 2012 RC to work with my C# solution. All my configuration-specific settings are stored within a single .props file which is then included by all my .csproj files.
Yet VS insists on putting this right in front of the include:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<IntermediateOutputPath>C:\Users\xyz\AppData\Local\Temp\vs855E.tmp\Debug\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<IntermediateOutputPath>C:\Users\xyz\AppData\Local\Temp\vs855E.tmp\Release\</IntermediateOutputPath>
</PropertyGroup>
<Import Project="$(MSBuildProjectDirectory)\..\Common.props" />
Why is that?
FYI, my common file looks like this: http://pastebin.com/Uued1XY0
回答1:
Those IntermediateOutputPath's can be inserted when MSBuild is given a bad path.
In our case, we had extra unnecessary slash after SolutionDir for output folders.
What wasn't working for us(note the extra slash):
<OutputPath>$(SolutionDir)\out\bin\</OutputPath>
<IntermediateOutputPath>$(SolutionDir)\out\obj\</IntermediateOutputPath>
What did work:
<OutputPath>$(SolutionDir)out\bin</OutputPath>
<IntermediateOutputPath>$(SolutionDir)out\obj</IntermediateOutputPath>
To help troubleshoot your particular case, try turning on diagnostic MSBuild output and logging under Tools->Options->Projects and Solutions->Build and Run-> MSBuild project build output verbosity. Then, search for the generated folder (ex. "Temp").
Using common proj/props/targets file is a great idea, but it does require fighting Visual Studio a little.
回答2:
So you can override those settings, if needed. If your import came before, Visual Studio's properties would take precedence. In MSBuild, the last definition wins and is used. This is a good thing. Is it causing errors? Or do you just not like it?
回答3:
You have specified the in your project. The Property file will have the BaseIntermediateOutputPath. If you don't specify any value in it will be derived from your Base.
The full intermediate output path as derived from BaseIntermediateOutputPath, if no path is specified. For example, \obj\debug. If this property is overridden, then setting BaseIntermediateOutputPath has no effect.
Refer: http://msdn.microsoft.com/en-us/library/bb629394.aspx
来源:https://stackoverflow.com/questions/11401141/visual-studio-keeps-adding-property-to-my-csproj-why