等效于dotnet core / csproj中的AssemblyInfo [英] Equivalent to AssemblyInfo in dotnet core/csproj

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

问题描述

由于dotnet核心移回了 .csproj 格式,因此有一个新的自动生成的 MyProject.AssemblyInfo.cs

  [assembly:AssemblyCompany( MyProject)] 
[assembly:AssemblyVersion( 1.0。 0.0)]

请注意,这会在每个版本中自动重新生成。
以前,该文件是在/ obj /目录中找到的,但现在似乎只存在于内存中,因为在磁盘上找不到该文件,并且单击错误消息无法打开任何文件。



这是错误消息:



由于已定义在那里我无法在经典的 AssemblyInfo.cs 中定义它们。



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

解决方案

您已经注意到,可以在.csproj中控制大多数这些设置。



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



< pre class = lang-xml prettyprint-override> < PropertyGroup>
< GenerateAssemblyInfo> false< / GenerateAssemblyInfo>
< / PropertyGroup>

如果您想了解引擎盖下发生的事情,请结帐 Microsoft.NET.GenerateAssemblyInfo.targets 在Microsoft.NET.Sdk中。


Since dotnet core moved back to the .csproj format there is a new autogenerated MyProject.AssemblyInfo.cs which contain among other.

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

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.

This is the error message:

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?

解决方案

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

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

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

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆