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.

[8.0 preview 3] NuGet package validation fails when UseArtifactsOutput=true

See original GitHub issue

Describe the bug

If UseArtifactsOutput=true and NuGet package validation is enabled, an error occurs when running dotnet pack.

It appears that the package validation functionality does not understand the new layout of the output, and looks in the wrong folder for the .nupkg file to validate.

Specifically, there appears to be a dangling _ in the name of the folder, I’m guessing because it’s expecting there to be a TFM there.

MSBuild version 17.6.0-preview-23174-01+e7de13307 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: [src\Logging.XUnit\MartinCostello.Logging.XUnit.csproj::TargetFramework=netstandard2.0]
  MartinCostello.Logging.XUnit -> .artifacts\bin\MartinCostello.Logging.XUnit\release_netstandard2.0\MartinCostello.Logging.XUnit.dll
  Successfully created package '.artifacts\package\release\MartinCostello.Logging.XUnit.0.3.1.nupkg'.
  Successfully created package '.artifacts\package\release\MartinCostello.Logging.XUnit.0.3.1.snupkg'.
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ApiCompat.ValidatePackage.targets(58,5): error MSB3371: The file ".artifacts\obj\MartinCostello.Logging.XUnit\release_\Microsoft.NET.ApiCompat.ValidatePackage.semaphore" cannot be created. Could not find a part of the path '.artifacts\obj\MartinCostello.Logging.XUnit\release_\Microsoft.NET.ApiCompat.ValidatePackage.semaphore'. [src\Logging.XUnit\MartinCostello.Logging.XUnit.csproj]

To Reproduce

Exceptions (if any)

C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ApiCompat.ValidatePackage.targets(58,5): error MSB3371: The file ".artifacts\obj\MartinCostello.Logging.XUnit\release_\Microsoft.NET.ApiCompat.ValidatePackage.semaphore" cannot be created. Could not find a part of the path '.artifacts\obj\MartinCostello.Logging.XUnit\release_\Microsoft.NET.ApiCompat.ValidatePackage.semaphore'. [src\Logging.XUnit\MartinCostello.Logging.XUnit.csproj]

Further technical details

❯ dotnet --info
 Version:   8.0.100-preview.3.23178.7
 Commit:    e300b0e1e6

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.3.23178.7\

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

  Version:      8.0.0-preview.3.23174.8
  Architecture: x64
  Commit:       47bad717bd

.NET SDKs installed:
  6.0.116 [C:\Program Files\dotnet\sdk]
  6.0.408 [C:\Program Files\dotnet\sdk]
  7.0.203 [C:\Program Files\dotnet\sdk]
  7.0.300-preview.23179.2 [C:\Program Files\dotnet\sdk]
  8.0.100-preview.3.23178.7 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.15 [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.4 [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.3.23177.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [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.4 [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.3.23174.8 [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 6.0.15 [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.4 [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.3.23178.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:

Learn more:

Download .NET:

Issue Analytics

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

github_iconTop GitHub Comments

dsplaistedcommented, Apr 21, 2023

Thanks for reporting this!

@ericstj @ViktorHofer I think several fixes are needed here. I’ve submitted #31919 to fix the intermediate directory to not try to include the TargetFramework for outer builds, which results in a path such as .artifacts\ProjectName\release_.

However, with the new output path format, the inner build intermediate and output paths are no longer subfolders of the outer build paths. So there’s nothing that guarantees that the intermediate output path will be created. Normally the PrepareForBuild target creates those folders, but that depends on targets like GetFrameworkPaths and GetReferenceAssemblyPaths, which didn’t seem appropriate to run in the outer build. So I think #31906 is the right fix for the package validation failure.

@zivkan I think it may be a good idea to update the pack targets as well. Currently the NuspecOutputPath is set to $(BaseIntermediateOutputPath)$(Configuration)\. When using the artifacts output path, this folder may not be used for anything else, as the artifacts output path constructs the path differently and also converts the Configuration to lower-case.

ViktorHofercommented, Apr 20, 2023

@martincostello thanks for reporting. I submitted to fix the immediate PackageValidation issue.

That said, there appears to be a bigger issue with UseArtifactsOutput when the TargetFramework couldn’t be determined. cc @dsplaisted @rainersigwald

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's new in .NET 8 Preview 3 · Issue #8135 · dotnet/core
This means that if there are multiple errors, the validation process often stops at the first error. As a result, you may have...
Read more > mvc - NuGet Package restore failed for project ...
Based on your error message looks like you are looking for a version that no longer exists and cannot tell which Package source...
Read more >
Package restore intermittently fails with "Unable to find ...
6.15003' of package 'Validation'. Restoring NuGet package xunit.abstractions.2.0.0. WARNING: Unable to find version '' of package ' ...
Read more >
Announcing .NET 8 Preview 3
In preview 4, we'll add the enabling mechanism to the .NET SDK, so that the NuGet package reference isn't required to use the...
Read more >
Package Validation - .NET Blog
In this blog post, I'm going to show the new package validation tooling that will become available with .NET 6. It ensures that...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found