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

43

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

我习惯于独立设置这些值,与当前的构建配置无关(在自己的ItemGroup中,连同DocumentationFile等一起设置)。

当我像这样设置新的.NET core .csproj配置时......

<OutputPath>bin\$(Configuration)\$(Platform)</OutputPath>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>

以下文件夹结构将被创建:

bin\
  Debug\
    AnyCPU\
      MyAssembly.xml
      netstandard1.0\
        MyAssembly.exe

看起来msbuild或其他自动添加了TargetFramework,这相当令人烦恼。

是否有一种方法可以真正自定义输出路径或禁用此行为?

1个回答

106

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

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

此行为源自于Microsoft.NET.Sdk(请参见其源代码


16
如果需要的话,还有这个:<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> - Dave Thieben

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接