此问题与设置.NET Core项目的版本号非常相似,但不相同.在编写(1.1)和VS2017时,使用最新的稳定版.NET Core,.NET Core已从基于JSON的项目文件切换到CSPROJ文件.
所以 - 我想要做的是建立一个CI环境,我希望能够在构建之前修改某些内容,以使用正确的版本号标记我的构建.
如果我使用这样的属性旧(SharedAssemblyInfo.cs技巧):
[assembly: AssemblyFileVersion("3.3.3.3")]
[assembly: AssemblyVersion("4.4.4.4")]
Run Code Online (Sandbox Code Playgroud)
某处项目时,我得到的
CS0579 - Duplicate 'System.Reflection.AssemblyFileVersionAttribute'
和
CS0579 - Duplicate 'System.Reflection.AssemblyVersionAttribute'
错误的时候建设.
在深入挖掘它时,我发现在构建过程中有一个看起来像这样的文件(在构建之前它不存在)\obj\Debug\netcoreapp1.1:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("TestApplication")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("Package Description")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.1.99.0")] …Run Code Online (Sandbox Code Playgroud)