.csproj 文件中自动生成的 IntermediateOutputPath

Autogenerated IntermediateOutputPath in the .csproj file

从 Git 更新代码后,csproj 出现错误,因为 file 路径不存在。这是启动错误的代码:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ZAL_Release|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>..\Release\bin\soft\</OutputPath>
    <DefineConstants>TRACE;ZAL</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Optimize>true</Optimize>
    <IntermediateOutputPath>C:\Users\HARRY~1\AppData\Local\Temp\vs543E.tmp\x64\ZAL_Release\</IntermediateOutputPath>
</PropertyGroup>

这个 filepath 存在于 Harry 的计算机上,但不存在于我的计算机上。这个名字的人不知道他是如何创建它的,所以我假设 Visual Studio 创建了它。这就是为什么我有三个问题:

1. csproj 中的 IntermediateOutputPath 标签的目的是什么? (我已经查了MSDN的文档,还是不清楚)

2. Harry 是如何生成密码的(因为他不知道)?

3. 是否可以使用通用变量来获取每个人都可以使用的文件路径?在这种情况下,这个 IntermediateOutputPath 对程序来说是强制性的 运行 吗?

  1. 项目文件中的一个 OutputPath

    Specifies the path to the output directory, relative to the project directory, for example, "bin\Debug".

    BaseOutputPath

    Specifies the base path for the output file. If it is set, MSBuild will use OutputPath = $(BaseOutputPath)$(Configuration). Example syntax: c:\xyz\bin\

    BaseIntermediateOutputPath

    The top-level folder where all configuration-specific intermediate output folders are created. The default value is obj. The following code is an example: c:\xyz\obj\

    IntermediateOutputPath

    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.

    你可以阅读这篇文章 here。一般来说,这些路径应该是相对的,绝不会导致任何主文件夹或其他用户特定的路径。

  2. 请参阅 this question 了解如何将 IntermediateOutputPath 插入到您的 csproj 文件中。

    编辑:实际上,这是一个模糊的解释,但我找不到关于此的任何其他信息。密切关注 csproj 文件的变化以确定变化的原因。

  3. 可以设置IntermediateOutputPath为相对路径。但是,您也可以只删除整个标签并使用默认标签。在我们的 Visual Studio 2015 项目文件中,我们只设置了基础 OutputPath,一切正常。我认为中间对象的默认位置是 /obj.