sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Local build failure: error CS0579: Duplicate TargetFrameworkAttribute

Open tmat opened this issue 3 years ago • 4 comments

Describe the bug

Local build fails with

D:\sdk\artifacts\obj\Debug\Sdks\Microsoft.NET.Sdk.Publish\tools\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [D:\sdk\src\WebSdk\Publish\Tasks\Microsoft.NET.Sdk.Publish.Tasks.csproj]

To Reproduce

Clone the repo and run build from the root and open in VS.

image

\\mlangfs1\public\tomat\Bugs\sdk27749\build.binlog

Turns out VS created sdk\src\WebSdk\Publish\Tasks\obj directory during design-time build and generated obj\Debug\net472\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs and obj\Debug\net472\Microsoft.NET.Sdk.Publish.Tasks.AssemblyInfo.cs there. Then <Compile Include="**\*.cs" /> included these files.

tmat avatar Sep 08 '22 01:09 tmat

By build I assume you mean dotnet build. No one on our team uses dotnet build to build the SDK, we all use the build.cmd script. Thanks for the detailed report, it would help us fix that. But I don't think we would prioritize fixing that right now, as you can just do git clean -xdf and use our build script to fix this.

nagilson avatar Sep 14 '22 18:09 nagilson

This is likely a production bug though, not a repo infrastructure issue. Might be in the SDK targets or VS Project System. The core issue is that design time build run from VS generated files to incorrect intermediate output path. Likely the targets file that customizes the intermediate output path was not loaded correctly during the design time build.

tmat avatar Sep 14 '22 18:09 tmat

I see, we will be discussing this in triage later today then. Thanks for clarifying!

nagilson avatar Sep 14 '22 19:09 nagilson

@tmat Daniel's guess is that this is caused by the arcade sdk not getting loaded into VS DTB. He thinks it may not have been downloaded yet when first resolved and so the intermediate output path was not fully configured yet. I think @jeffkl was proposing a change in VS that would hard fail in this situation preventing you from getting into this state. That's probably the right way to solve this potentially (best guess).

marcpopMSFT avatar Sep 14 '22 21:09 marcpopMSFT