如何使用新的 csproj 构建系统在 csproj 中定义 AssemblyProduct

How to define AssemblyProduct in csproj with the new csproj build system

在 "old" 世界中,我会定义一个 AssemblyProductAttributeAssemblyTrademarkAttribute,它们将在文件属性中显示为 "Product name" 和 "Legal trademarks" windows 探索者。

在 Visual Studio 2017 年用于 netstandard 项目的新简化 msbuild 系统中,首选方法是定义所有这些程序集级别属性 in the csproj directly 并让 msbuild 生成实际属性。

但是csproj中好像没有办法定义"Product name"和"Legal trademarks"。或者有吗? This msbuild target 似乎暗示它至少应该为 AssemblyProductAttribute 工作。

我怎样才能添加这两个东西?

更新: 好的,对于 AssemblyProductAttribute,可以将 <Product>Foo</Product> 直接写入 csproj 文件。但是 AssemblyTrademarkAttribute 呢?

您可以为这些目标尚未发出的程序集属性添加一个项目:

<ItemGroup>
  <AssemblyAttribute Include="System.Reflection.AssemblyTrademarkAttribute">
    <_Parameter1>My Trademark</_Parameter1>
  </AssemblyAttribute>
</ItemGroup>

可以查看示例 here 了解如何使用它生成 InternalsVisibleTo 属性。