Core: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' atribute

Dung Do Tien May 12 2021 1173

I have a project web, be developing with Core 3.1.

Everything work well but one day I got the latest code from Git and builds I got an error Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute.

 Error  CS0579  Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute  

The following code is autogenerated in the obj/Debug/netcoreapp3.1 folder

 // using System; using System.Reflection; 
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]

I checked all project versions but nothing change. I also tried to clear and rebuild all solutions but it still not work for me.

Thanks for any suggestion.

Have 2 answer(s) found.
  • W

    Watcharapong Jakkawannorasing May 12 2021

    Add the following two lines to the <PropertyGroup>.


    I try it and fixed it for me.

  • S

    Sáng Cao May 12 2021

    I got the same error in VS2019, to resolve this issue you can open .csproj and add line code below inside tag <PropertyGroup> :


    And then save this file, clear and rebuild project.

    I hope it helpful for you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close