在.NET核心中设置自定义<OutputPath>(停止添加框架目标)?

mae*_*ove 14 .net c# msbuild visual-studio .net-core

在传统的.NET应用程序中,可以<OutputPath>.csproj文件中(或通过项目属性对话框)设置程序集的自定义.一条例如bin\$(Configuration)\$(Platform)导致的道路bin\Debug\AnyCPU.

我习惯于将这些值设置为独立于当前构建配置(与它本身ItemGroup一起,DocumentationFile等等).

当我在新的.NET核心中设置我的配置时.csproj......

<OutputPath>bin\$(Configuration)\$(Platform)</OutputPath>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
Run Code Online (Sandbox Code Playgroud)

..创建以下文件夹结构:

bin\
  Debug\
    AnyCPU\
      MyAssembly.xml
      netstandard1.0\
        MyAssembly.exe
Run Code Online (Sandbox Code Playgroud)

所以它似乎是msbuild,或任何自动附加的东西TargetFramework,这是相当烦人的.

有没有办法真正自定义输出路径或禁用此行为?

Mar*_*ich 38

您可以通过设置禁用此行为:

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
Run Code Online (Sandbox Code Playgroud)

这种行为起源于Microsoft.NET.Sdk(见其来源)

  • 另外,如果您需要它:`&lt;AppendRuntimeIdentifierToOutputPath&gt;false&lt;/AppendRuntimeIdentifierToOutputPath&gt;` (9认同)