Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
martincostello opened this issue Apr 19, 2023 · 6 comments · Fixed by #31906 or #31919
Closed

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

martincostello opened this issue Apr 19, 2023 · 6 comments · Fixed by #31906 or #31919
Assignees
Labels
Area-ApiCompat untriaged Request triage from a team member
Milestone

Comments

@martincostello
Copy link
Member

martincostello commented Apr 19, 2023

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: https://aka.ms/dotnet-support-policy [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
.NET SDK:
 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.

Host:
  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:
  C:\Coding\martincostello\xunit-logging\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NuGet untriaged Request triage from a team member labels Apr 19, 2023
@ghost
Copy link

ghost commented Apr 19, 2023

Thanks for creating this issue! We believe this issue is related to NuGet tooling, which is maintained by the NuGet team. Thus, we closed this one and encourage you to raise this issue in the NuGet repository instead. Don’t forget to check out NuGet’s contributing guide before submitting an issue!

If you believe this issue was closed out of error, please comment to let us know.

Happy Coding!

@ghost ghost closed this as completed Apr 19, 2023
@ghost
Copy link

ghost commented Apr 19, 2023

@dotnet/area-infrastructure-libraries a new issue has been filed in the ApiCompat area, please triage

@baronfel baronfel reopened this Apr 19, 2023
@baronfel
Copy link
Member

Reopening because the error is triggered from ApiCompat, not NuGet.

@ViktorHofer
Copy link
Member

@martincostello thanks for reporting. I submitted #31906 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

@ViktorHofer
Copy link
Member

ViktorHofer commented Apr 20, 2023

The following logic is incorrect @dsplaisted:

<!-- Include the TargetFramework in the pivots if the project is multi-targeted (ie TargetFrameworks) is defined -->
<ArtifactsPivots Condition="'$(TargetFrameworks)' != ''"
>$(ArtifactsPivots)_$(TargetFramework.ToLowerInvariant())</ArtifactsPivots>

A TargetFrameworks property set doesn't necessarily imply that TargetFramwork is also set, i.e.

dotnet new classlib -n pkgtest
// Change TargetFramework to TargetFrameworks
dotnet pack /p:UseArtifactsOutput=true /bl

IntermediateOutputPath and OutputPath are then both incorrect in an outer build in which NuGet runs its Pack target:

image

image

@dsplaisted
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-ApiCompat untriaged Request triage from a team member
Projects
None yet
4 participants