sdk: dotnet pack fails using UseArtifactsOutput=true with multi-targeting and global usings

Describe the bug

I’m testing out an internal library with .NET 8 preview 4 and UseArtifactsOutput=true and dotnet pack fails with the following error (as we have treat warnings as errors turned on):

[/runner/_work/LambdaWorker/LambdaWorker/src/LambdaWorker/JustEat.LambdaWorker.csproj::TargetFramework=net7.0]
  JustEat.LambdaWorker -> /runner/_work/LambdaWorker/LambdaWorker/artifacts/bin/JustEat.LambdaWorker/release_net6.0/JustEat.LambdaWorker.dll
  JustEat.LambdaWorker -> /runner/_work/LambdaWorker/LambdaWorker/artifacts/bin/JustEat.LambdaWorker/release_net7.0/JustEat.LambdaWorker.dll
  JustEat.LambdaWorker -> /runner/_work/LambdaWorker/LambdaWorker/artifacts/bin/JustEat.LambdaWorker/release_net8.0/JustEat.LambdaWorker.dll
  Successfully created package '/runner/_work/LambdaWorker/LambdaWorker/artifacts/package/release/JustEat.LambdaWorker.8.0.304-preview.293.nupkg'.
Error: /home/runner/.dotnet/sdk/8.0.100-preview.4.23260.5/Sdks/NuGet.Build.Tasks.Pack/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(221,5): error NU5118: Warning As Error: File '/runner/_work/LambdaWorker/LambdaWorker/artifacts/obj/JustEat.LambdaWorker/release_net7.0/JustEat.LambdaWorker.GlobalUsings.g.cs' is not added because the package already contains file 'src/LambdaWorker/JustEat.LambdaWorker.GlobalUsings.g.cs' [/runner/_work/LambdaWorker/LambdaWorker/src/LambdaWorker/JustEat.LambdaWorker.csproj]
Error: /home/runner/.dotnet/sdk/8.0.100-preview.4.23260.5/Sdks/NuGet.Build.Tasks.Pack/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(221,5): error NU5118: Warning As Error: File '/runner/_work/LambdaWorker/LambdaWorker/artifacts/obj/JustEat.LambdaWorker/release_net8.0/JustEat.LambdaWorker.GlobalUsings.g.cs' is not added because the package already contains file 'src/LambdaWorker/JustEat.LambdaWorker.GlobalUsings.g.cs' [/runner/_work/LambdaWorker/LambdaWorker/src/LambdaWorker/JustEat.LambdaWorker.csproj]
  Successfully created package '/runner/_work/LambdaWorker/LambdaWorker/artifacts/package/release/JustEat.LambdaWorker.8.0.304-preview.293.symbols.nupkg'.

dotnet pack seems to be trying to add the same compiler-generating global using files for each TFM to the symbols package and emitting a warning.

To Reproduce

Pending: I haven’t yet worked out what the “magic combination” of factors is that causes this problem to make a simple repro. The repository I’m hitting this with is private so I can’t share as-is.

Exceptions (if any)

None.

Further technical details

.NET SDK 8.0.100-preview.4.23260.5

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

@ViktorHofer That repo doesn’t appear to have Issues enabled - is there an alternative one you’d like me to copy this to?

Sorry, nuget/nuget.client is where the code lives and nuget/home is where issues are filed: https://github.com/NuGet/Home/

I can’t actually find this anywhere in the repo.

It’s because we call dotnet pack with --include-source 🤦