-1

I am getting CS0579 errors from my TFS automated build system. The same build script works fine on my development machine. Build is also successful in Visual Studio. The project is that is erroring is C# netcoreapp3.1 and platform x64

ERROR: Tests.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute

Error is repeated for several other attributes:

  1. System.Reflection.AssemblyInformationalVersionAttribute
  2. System.Reflection.AssemblyProductAttribute
  3. System.Reflection.AssemblyTitleAttribute
  4. System.Reflection.AssemblyVersionAttribute

Am I missing something on my build agent? What could be going on?

Edit: I should have mentioned that there is no AssemblyInfo.cs in the project and that false property is already set in the csproj.

Also, as mentioned above the build script has been run successfully on my workstation. Subsequently it has also been run successfully on another dev workstation. But, fails consistently on the TFS build agent.

Jim Reineri
  • 2,830
  • 3
  • 31
  • 32
  • Can this discussion help you? https://stackoverflow.com/questions/10311347/duplicate-assemblyversion-attribute Basically removing AssemblyInfo.cs file can help it seems. – Koray Elbek Sep 10 '20 at 10:49
  • Does this answer your question? [Duplicate AssemblyVersion Attribute](https://stackoverflow.com/questions/10311347/duplicate-assemblyversion-attribute) – Ian Kemp Sep 10 '20 at 11:11
  • What's the result if you modify the csproj and add this property `false`? Also, try deleting the AssemblyInfo.cs file if your project contains it. – LoLance Sep 11 '20 at 03:36
  • @LanceLi-MSFT we already have that property set in the csproj – Jim Reineri Sep 11 '20 at 11:00
  • @KorayElbek already do not have an AssemblyInfo.cs Sorry should have mentioned that – Jim Reineri Sep 11 '20 at 11:03
  • Have you tried to run, manually, in the machine that has the build agent. Go to the build agent's work folder, and try to run each of the steps. Verify that the source folder is how you imagine it. – XtianGIS Sep 15 '20 at 07:22

1 Answers1

0

The error CS0579: Duplicate 'System.Reflection.xxx' attribute always indicates that there're extra AssenvlyVersion available in your build process.

1.So you need to check if you pass MSbuild arguments like /p:Version /p:AssemblyVersion as build arguments.

2.Make sure you're using Dotnet build task to build the project.

3.Double check to make sure you don't have any xx.AssemblyInfo.cs in project directory.

4.Make sure the bin/obj folder are not checked in source control. Then delete the agent_work folder or _work folder of your build agent to make a clear working directory. Choose Clean=true for your Get Source step.

enter image description here

enter image description here

LoLance
  • 25,666
  • 1
  • 39
  • 73