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

I got the following errors today while working on a new project:

Error CS0579 Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0\MyAzureFunction.AssemblyInfo.cs 20 Active

Error CS0579 Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0.NETCoreApp,Version=v6.0.AssemblyAttributes.cs 4 Active

Error CS0579 Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0\MyAzureFunction.AssemblyInfo.cs 14 Active

Error CS0579 Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0\MyAzureFunction.AssemblyInfo.cs 15 Active

Error CS0579 Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0\MyAzureFunction.AssemblyInfo.cs 16 Active

Error CS0579 Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0\MyAzureFunction.AssemblyInfo.cs 17 Active

Error CS0579 Duplicate 'System.Reflection.AssemblyProductAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0\MyAzureFunction.AssemblyInfo.cs 18 Active

Error CS0579 Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute MyAzureFunction C:\Repos\Test\MyAzureFunction\obj\Debug\net6.0\MyAzureFunction.AssemblyInfo.cs 19 Active

and it looked like the following in the error list:

duplicate-attribute-build-error

I figured out that I had created a project within my project by mistake. I had two projects "MyAzureFunction" and "YahooFinanceApi". The project structure looked like the following:

BaseFolder
   MyAzureFunction
      MyAzureFunction.csproj
      YahooFinanceApi
         YahooFinanceApi.Csjproj
      solution.sln

What solved the above for me was changing the above to the following:

BaseFolder
   MyAzureFunction
      MyAzureFunction.csproj
   YahooFinanceApi
      YahooFinanceApi.csproj
   solution.sln

This way the YahooFinanceApi project was not built within the MyAzureFunction project. For some reason this made the MyAzureFunction project fail with the duplicate error when built.

I hope this helps someone out there :)