且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更改asp.net核心中的程序集信息?

更新时间:2022-10-28 18:09:17

对现在可以在 .csproj 或使用 AssemblyInfo.cs 定义属性,但是只能使用一个位置,否则






如果要使用 AssemblyInfo.cs ,请将以下内容添加到 .csproj 中,以避免重复错误:

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

如果您感兴趣的是如何工作,请查看 GenerateAssemblyInfo任务






否则,删除 AssemblyInfo.cs 并将以下属性添加到您的 .csproj 文件:

 < PropertyGroup> 
< AssemblyVersion> 1.2.3.4< / AssemblyVersion>
< / PropertyGroup>


I want to versioning my asp.net core app.

I followed this link: http://www.matthiaseinig.de/2013/05/20/auto-generate-fileversion-for-all-projects-in-a-solution-with-t4/ , but I want to remove project assembly info, but I didn't find it.

How to remove duplicated assembly info? I want to override asp core assemblies with another file.



BETTER SOLUTION

After a while I realize that the best solution is to use a T4 file, the version is incremented automatically after each build.

look here:

http://www.matthiaseinig.de/2013/05/20/auto-generate-fileversion-for-all-projects-in-a-solution-with-t4/

Right now properties could be defined in .csproj or using AssemblyInfo.cs, but only the one place could be used, otherwise "Duplicate" errors are generated.


If you want to use AssemblyInfo.cs, add the following into .csproj to avoid duplication errors:

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

If you are interesting how does it work, look into GenerateAssemblyInfo task.


Otherwise, remove AssemblyInfo.cs and add the following property into your .csproj file:

<PropertyGroup>
  <AssemblyVersion>1.2.3.4</AssemblyVersion>
</PropertyGroup>