本文介绍了相当于 dotnet core/csproj 中的 AssemblyInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从 dotnet 核心移回 .csproj 格式后,有一个新的自动生成的 MyProject.AssemblyInfo.cs,其中包含:

Since dotnet core moved back to the .csproj format, there is a new autogenerated MyProject.AssemblyInfo.cs which contains, among others:

[assembly: AssemblyCompany("MyProject")]
[assembly: AssemblyVersion("1.0.0.0")]

注意每次构建都会自动重新生成.以前,该文件是在/obj/目录中找到的,现在它似乎只在内存中,因为在磁盘上找不到该文件,并且单击错误消息不会打开任何文件.

Note that this is automatically regenerated every build.Previously, the file was found in the /obj/ directory, now it appears to be only in memory as the file can't be found on disk and clicking the error message does not open any file.

这是错误信息:

因为它们是在那里定义的,所以我不能在经典的 AssemblyInfo.cs 中自己定义它们.

Since they are defined there, I can't define them myself in the classical AssemblyInfo.cs.

在哪里/如何定义项目的公司和版本?

Where/how can I define the Company and Version of a project?

推荐答案

您已经注意到,您可以在 .csproj 中控制大部分设置.

As you've already noticed, you can control most of these settings in .csproj.

如果您希望将这些保留在 AssemblyInfo.cs 中,您可以关闭自动生成的程序集属性.

If you'd rather keep these in AssemblyInfo.cs, you can turn off auto-generated assembly attributes.

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

如果您想了解幕后发生的事情,请查看 Microsoft.NET.GenerateAssemblyInfo.targets 位于 Microsoft.NET.Sdk 中.

If you want to see what's going on under the hood, checkout Microsoft.NET.GenerateAssemblyInfo.targets inside of Microsoft.NET.Sdk.

这篇关于相当于 dotnet core/csproj 中的 AssemblyInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 00:38