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.

OutputPath contains double path separator leading to NU5019 in nuget pack

See original GitHub issue

Describe the bug

.NET 8 Preview 4 SDK Requires: A .NET SDK project with multi-targeting (TargetFrameworks plural) and a custom .nuspec The OutputPath property ends up with a double slash (path separator) because PlatformName is undefined. Nuget pack doesn’t like the double-slash, leading to a NU5019 (file not found) error.

To Reproduce

Here’s a gist: https://gist.github.com/pharring/aef107238843a1c6c7ea9f0be87795d6

Copy the three files to a local directory and build it with dotnet build Output:

Build FAILED.

C:\Program Files\dotnet\sdk\8.0.100-preview.4.23260.5\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): error NU5019: File not found: 'b
in\\Debug\foo.txt'. [C:\throwaway\foo2\foo.csproj]

Exceptions (if any)

Note that this repros only with multitargeting. If you change TargetFrameworks to TargetFramework (singular), then it works. The problem seems to be that PlatformName is not set in the multitargeting case (it should default to AnyCpu) so OutputPath gets initialized with a double path separator.

Further technical details

  • Output of dotnet --info:
.NET SDK:
 Version:   8.0.100-preview.4.23260.5
 Commit:    2268e7b15c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-preview.4.23260.5\

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.0-preview.4.23259.5
  Architecture: x64
  Commit:       84a3d0e37e

.NET SDKs installed:
  7.0.400-preview.23274.1 [C:\Program Files\dotnet\sdk]
  8.0.100-preview.4.23260.5 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-preview.4.23260.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-preview.4.23259.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0-preview.4.23260.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found
  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version: VS 2022 17.7 Preview 2

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dsplaistedcommented, Jun 2, 2023

Thanks folks for the report, this was an SDK regression. I’ve sent #33003 to fix it.

0reactions
baronfelcommented, Jun 2, 2023

@dsplaisted NuGet thinks this is related to the output path changes, can you check?

Read more comments on GitHub >

github_iconTop Results From Across the Web

OutputPath contains double path separator leading to ...
The OutputPath property ends up with a double slash (path separator) because PlatformName is undefined. Nuget pack doesn't like the double-slash ...
Read more >
NuGet Error NU5019
Issue. The nuspec file used to create the NuGet pack operation contained files that do not exist.
Read more >
OutputPath error with nuget pack in nuget 2.2.3
MyProject does live within a larger solution, but it has no dependencies on any other projects in that solution. How can I get...
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