I'm using Visual Studio 2019 and .Net 5.0, however I'm a newbie, so please talk to me like to a newbie. I downloaded a library from GitHub and included it sucesfully to my project - Visual Studio sees both the library and functions from the library. However the code doesn't compile. I obtain Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute error. More specifically I obtain 3 such errors (I've got 3 .csproj files, however the Visual Studio always says it concerns one project (sometimes this, sometimes another)).
I googled this error and most people advise to add <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> to the .csproj file, but it doesn't work for me. I'm adding this line everywhere like a maniac, but only one error disappeared - there are two now. Here is how it looks like: 
Some people advise to also add some other lines, but it doesn't work for me either. CreepyGnome out here: https://github.com/dotnet/sdk/issues/12297 wrote that he delated the directory and re-cloned the repository (from GitHub?) and it worked for him without adding any lines, but I don't know what it exactly means, because, as I said, I'm a newbie.
Please help me to get rid of this, because I'm going to lose my mind.
Ok, following an advice from another thread I solved the problem. I'll write it here, because it's maybe not enough clear there:
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
to all .csproj files of my projects betweeen <PropertyGroup> and </PropertyGroup>.
bin ond obj folders in my projects.The crucial thing is to do both these things and in exactly this order. When I only added the lines, it didn't help much. When I delated the directories it worked once till the second compilation. When I tried to compile it second time - it stopped working, because compilation creates bin and obj directories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With