admin管理员组

文章数量:1278948

These commands fail with the errors:

dotnet new webapi
dotnet new classlib -o Lib
dotnet add reference Lib/Lib.csproj
dotnet build (SUCCESS)
dotnet build (ERRORS)

  test failed with 8 error(s) (0,3s)
    C:\prj\test\obj\Debug\net9.0\.NETCoreApp,Version=v9.0.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute
    C:\prj\test\obj\Debug\net9.0\test.AssemblyInfo.cs(13,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute
    C:\prj\test\obj\Debug\net9.0\test.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute
    C:\prj\test\obj\Debug\net9.0\test.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
    C:\prj\test\obj\Debug\net9.0\test.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
    C:\prj\test\obj\Debug\net9.0\test.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute
    C:\prj\test\obj\Debug\net9.0\test.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
    C:\prj\test\obj\Debug\net9.0\test.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute

The first dotnet build succeeds, any subsequent dotnet build (even with clean/restore) fail.

If I place the webapi in a folder on its own, it works:

dotnet new webapi -o Api
dotnet new classlib -o Lib
cd Api
dotnet add reference ../Lib/Lib.csproj
dotnet build (SUCCESS)
dotnet build (SUCCESS)

I am using the latest 9.0 SDK

Deleting the Lib/obj, Lib/bin resolves this (once).

What am I missing here?

本文标签: netdotnet build assembly error in nested projectsStack Overflow