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

Dung Do Tien May 12 2021 357

I have a project web, be developing with Asp.net 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  
D:\GameOBJ\obj\Debug\netcoreapp3.1\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs

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.
  • 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> :

    <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>

    And then save this file, clear and rebuild project.

    I hope it helpful for you.

  • W

    Watcharapong Jakkawannorasing May 12 2021

    Add the following two lines to the <PropertyGroup>.

    <PropertyGroup>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
        <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>    
    </PropertyGroup>

    I try it and fixed it for me.

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