question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
martincostellocommented, May 26, 2023
1reaction
ViktorHofercommented, May 25, 2023

@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/

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet pack fails using UseArtifactsOutput=true with multi- ...
dotnet pack seems to be trying to add the same compiler-generating global using files for each TFM to the symbols package and emitting...
Read more >
c# - dotnet pack seems to use outdated sourcecode, even ...
The real problem seems to have been that dotnet used an outdated build in the Release folder to generate the .nupkg.
Read more >
'dotnet pack' uses Release configuration - .NET
Learn about a breaking change in the .NET 8 SDK where 'dotnet pack' uses the 'Release' configuration by default.
Read more >
dotnet pack command - .NET CLI
The dotnet pack command creates NuGet packages for your .NET project.
Read more >
Support multiple .NET Framework versions in your project file
Description of the various methods to target multiple .NET Framework versions from within a single NuGet package in your project file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found