I am trying to build several c# netstandard2.0 dlls and one netcoreapp3.1 application in DevOps
AssemblyInfo.cs for the .exe contains the following
I can build on my pc.
However the build in DevOps fails with the error
(CoreCompile target) ->
obj\Release\netcoreapp3.1\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute
THe task in DevOps is
- task: DotNetCoreCLI@2
inputs:
command: pack
packagesToPack: '**/SBD.*.csproj'
versioningScheme: byPrereleaseNumber
majorVersion: '$(Major)'
minorVersion: '$(Minor)'
patchVersion: '$(Patch)'
The error comes from the auto-generated file
.NETCoreApp,Version=v3.1.AssemblyAttributes.cs
, I think it has something to with your customAssemblyInfo.cs
file.For
.net core
(new SDK fprmat) project, it doesn't contain theAssemblyInfo.cs
file by default like.net framework
(old legacy format). Instead we can set those values in its project file, and it will generate thexx.AssemblyAttributes.cs
andProjectName.AssemblyInfo.cs
for us. I assume there's conflict between your customAssemblyInfo.cs
and the auto-generated files.So you need to set
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
to use your customAssemblyInfo.cs
file. Check the similar ticket in Github/Dotnet-SDK.