如何在 Visual Studio 2017 项目(新的 .csproj 文件格式)中设置 `OutputPath` 而目标框架不会混淆已解析的路径?

How do I set `OutputPath` in a Visual Studio 2017 project (new .csproj file format) without the target framework cluttering the resolved path?

在新的 Visual Studio 2017 项目格式中设置 OutputPath 会自动在路径中添加目标框架。例如,如果我在项目文件中设置了这些:

<TargetFramework>net462</TargetFramework>
<OutputPath>/build/debug/<OutputPath>

实际输出文件夹将解析为 /build/debug/net462/,而不是旧版本中的 /build/debug/。 如果没有变通办法(例如使用 post 构建操作来移动东西),我该如何解决这个问题?

解决方法是使用AppendTargetFrameworkToOutputPathhttps://www.tabsoverspaces.com/233608-stopping-msbuild-appending-targetframework-to-outputpath/

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

上面的答案是正确的,但您可能还想删除运行时标识符:

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>