简体   繁体   English

如何在许多 .NET 核心项目的所有 dll 中获得相同的版权和构建日期信息

[英]How to get same copyright & builddate info in all dll's across many .NET Core projects

We have a product consisting of ~100 projects, currently on .NET Framework.我们有一个由大约 100 个项目组成的产品,目前在 .NET 框架上。 To get same build number, copyright and vendor information in all dll's, we have a common GlobalAssemblyInfo.cs referenced by all projects holding the attributes like AssemblyCopyRight, AssemblyVersion and AssemblyFileVersion.为了在所有 dll 中获得相同的内部版本号、版权和供应商信息,我们有一个通用的 GlobalAssemblyInfo.cs,所有项目都引用了它,这些项目包含 AssemblyCopyRight、AssemblyVersion 和 AssemblyFileVersion 等属性。 So we only need to update this single file to get correct information in the DLL's.所以我们只需要更新这个单个文件就可以在 DLL 中获得正确的信息。 Dll specific information is still held in AssemblyInfo.cs. Dll 具体信息仍在 AssemblyInfo.cs 中。

We want to port the product to .NET Core and want to be able to do same thing, but there these attributes are generated from items in the.csproj file, which leads to compile time error due to duplicate definitions.我们希望将产品移植到 .NET Core 并希望能够做同样的事情,但是这些属性是从 .csproj 文件中的项目生成的,这会导致由于重复定义而导致编译时错误。

Is there a way to disable this behavior in .NET Core projects or is there another way to get similar behavior as in .NET Framework?有没有办法在 .NET 核心项目中禁用此行为,或者是否有其他方法可以获得与 .NET 框架中类似的行为?

With .NET Core, there is no AssemblyInfo.cs by default.对于 .NET Core,默认没有 AssemblyInfo.cs。 But that does not stop you from adding one if you want to maintain your settings that way.但是,如果您想以这种方式维护您的设置,这并不能阻止您添加一个。 You should turn-off the assembly attribute generation in the.csproj to avoid duplication.您应该关闭 .csproj 中的程序集属性生成以避免重复。

<PropertyGroup>
   <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

This can also be done the other way round.这也可以反过来进行。 Having the assembly info auto-generated.自动生成程序集信息。 This blog post digs into how that can be achieved. 这篇博文深入探讨了如何实现这一目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM