Visual Studio不断向我的csproj添加属性.为什么?

Fil*_*ącz 11 .net msbuild csproj visual-studio visual-studio-2012

我正在使用Visual Studio 2012 RC来处理我的C#解决方案.我所有配置特定的设置都存储在一个.props文件中,然后由我的所有.csproj文件包含.

然而VS坚持将这一权利放在包括:

<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" />
Run Code Online (Sandbox Code Playgroud)

这是为什么?

仅供参考,我的常见文件如下:http://pastebin.com/Uued1XY0

小智 7

当MSBuild被赋予错误路径时,可以插入那些IntermediateOutputPath.

在我们的例子中,我们在SolutionDir之后为输出文件夹添加了额外的不必要的斜杠.

什么不适合我们(注意额外的斜线):

<OutputPath>$(SolutionDir)\out\bin\</OutputPath>
<IntermediateOutputPath>$(SolutionDir)\out\obj\</IntermediateOutputPath>
Run Code Online (Sandbox Code Playgroud)

做了什么工作:

<OutputPath>$(SolutionDir)out\bin</OutputPath>
<IntermediateOutputPath>$(SolutionDir)out\obj</IntermediateOutputPath>
Run Code Online (Sandbox Code Playgroud)

要帮助解决您的特定情况,请尝试打开诊断MSBuild输出并在工具 - >选项 - >项目和解决方案 - >构建和运行 - > MSBuild项目构建输出详细程度下进行记录.然后,搜索生成的文件夹(例如"Temp").

使用常见的proj/props/targets文件是一个好主意,但它确实需要对Visual Studio进行一些攻击.


Aar*_*sen 0

因此,如果需要,您可以覆盖这些设置。如果您的导入之前发生,则 Visual Studio 的属性将优先。在 MSBuild 中,最后一个定义获胜并被使用。这是一件好事。它会导致错误吗?或者你只是不喜欢它?