等效于dotnet core / csproj中的AssemblyInfo

编程入门 行业动态 更新时间:2024-10-22 10:56:21
本文介绍了等效于dotnet core / csproj中的AssemblyInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

这是错误消息:

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

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

解决方案

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

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

< 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

本文发布于:2023-11-14 09:23:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586836.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:core   dotnet   AssemblyInfo   csproj

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!