Azure devops CS0579:重复';全局::System.Runtime.Versioning.TargetFrameworkAttribute';
我正在尝试在DevOps中构建几个c#netstandard2.0 DLL和一个netcoreapp3.1应用程序 .exe的AssemblyInfo.cs包含以下内容 我可以建立在我的电脑上 但是,在DevOps中构建失败,并出现错误Azure devops CS0579:重复';全局::System.Runtime.Versioning.TargetFrameworkAttribute';,azure-devops,dotnet-core-pack,Azure Devops,Dotnet Core Pack,我正在尝试在DevOps中构建几个c#netstandard2.0 DLL和一个netcoreapp3.1应用程序 .exe的AssemblyInfo.cs包含以下内容 我可以建立在我的电脑上 但是,在DevOps中构建失败,并出现错误 (CoreCompile target) -> obj\Release\netcoreapp3.1\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12): error CS0579
(CoreCompile target) ->
obj\Release\netcoreapp3.1\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute
DevOps中的任务是
- task: DotNetCoreCLI@2
inputs:
command: pack
packagesToPack: '**/SBD.*.csproj'
versioningScheme: byPrereleaseNumber
majorVersion: '$(Major)'
minorVersion: '$(Minor)'
patchVersion: '$(Patch)'
错误来自自动生成的文件
.NETCoreApp,Version=v3.1.AssemblyAttributes.cs
,我认为它与您的自定义AssemblyInfo.cs
文件有关
对于.net core
(新SDK fprmat)项目,默认情况下它不包含AssemblyInfo.cs
文件,如.net framework
(旧的旧格式)。相反,我们可以在其项目文件中设置这些值,它将为我们生成xx.AssemblyAttributes.cs
和ProjectName.AssemblyInfo.cs
。我假设您的自定义AssemblyInfo.cs
和自动生成的文件之间存在冲突
因此,您需要设置false
以使用自定义AssemblyInfo.cs
文件。检查Github/Dotnet SDK中的应用程序。这对我很有用
我在.cproj的一个文件中注释(删除)了属性。如果我们在csproj的propertyGroup中将此msbuild属性设置为false会怎么样<代码>错误我已经将其设置为错误,所以我刚刚删除了AssemblyInfo.cs