dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

dotnet workload install doesn't handle pack aliases #17205

Closed lewing closed 3 years ago

lewing commented 3 years ago

dotnet workload install microsoft-net-sdk-blazorwebassembly-aot --skip-manifest-update=true

Fails to install all the packs because it doesn't account for the alias-to attributes correctly

dotnet workload install microsoft-net-sdk-blazorwebassembly-aot --skip-manifest-update=true 

Installing pack Microsoft.NET.Runtime.MonoAOTCompiler.Task version 6.0.0-preview.4.21222.10...
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/microsoft.net.runtime.monoaotcompiler.task/index.json
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/registrations2-semver2/microsoft.net.runtime.monoaotcompiler.task/index.json
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/registrations2-semver2/microsoft.net.runtime.monoaotcompiler.task/index.json
[NuGet Manager] [Info]   NotFound https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/registrations2-semver2/microsoft.net.runtime.monoaotcompiler.task/index.json 268ms
[NuGet Manager] [Info]   OK https://api.nuget.org/v3/registration5-gz-semver2/microsoft.net.runtime.monoaotcompiler.task/index.json 290ms
[NuGet Manager] [Info]   OK https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/registrations2-semver2/microsoft.net.runtime.monoaotcompiler.task/index.json 512ms
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.monoaotcompiler.task/index.json
[NuGet Manager] [Info]   OK https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.monoaotcompiler.task/index.json 124ms
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.monoaotcompiler.task/6.0.0-preview.4.21222.10/microsoft.net.runtime.monoaotcompiler.task.6.0.0-preview.4.21222.10.nupkg
[NuGet Manager] [Info]   OK https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.monoaotcompiler.task/6.0.0-preview.4.21222.10/microsoft.net.runtime.monoaotcompiler.task.6.0.0-preview.4.21222.10.nupkg 414ms
Writing workload pack installation record for Microsoft.NET.Runtime.MonoAOTCompiler.Task version 6.0.0-preview.4.21222.10...
Installing pack Microsoft.NET.Runtime.WebAssembly.Sdk version 6.0.0-preview.4.21222.10...
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/microsoft.net.runtime.webassembly.sdk/index.json
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/registrations2-semver2/microsoft.net.runtime.webassembly.sdk/index.json
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/registrations2-semver2/microsoft.net.runtime.webassembly.sdk/index.json
[NuGet Manager] [Info]   NotFound https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/registrations2-semver2/microsoft.net.runtime.webassembly.sdk/index.json 107ms
[NuGet Manager] [Info]   OK https://api.nuget.org/v3/registration5-gz-semver2/microsoft.net.runtime.webassembly.sdk/index.json 242ms
[NuGet Manager] [Info]   OK https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/registrations2-semver2/microsoft.net.runtime.webassembly.sdk/index.json 384ms
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.webassembly.sdk/index.json
[NuGet Manager] [Info]   OK https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.webassembly.sdk/index.json 173ms
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.webassembly.sdk/6.0.0-preview.4.21222.10/microsoft.net.runtime.webassembly.sdk.6.0.0-preview.4.21222.10.nupkg
[NuGet Manager] [Info]   OK https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.runtime.webassembly.sdk/6.0.0-preview.4.21222.10/microsoft.net.runtime.webassembly.sdk.6.0.0-preview.4.21222.10.nupkg 363ms
Writing workload pack installation record for Microsoft.NET.Runtime.WebAssembly.Sdk version 6.0.0-preview.4.21222.10...
Installing pack Microsoft.NETCore.App.Runtime.AOT.Cross.browser-wasm version 6.0.0-preview.4.21222.10...
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/microsoft.netcore.app.runtime.aot.cross.browser-wasm/index.json
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/registrations2-semver2/microsoft.netcore.app.runtime.aot.cross.browser-wasm/index.json
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/registrations2-semver2/microsoft.netcore.app.runtime.aot.cross.browser-wasm/index.json
[NuGet Manager] [Info]   NotFound https://api.nuget.org/v3/registration5-gz-semver2/microsoft.netcore.app.runtime.aot.cross.browser-wasm/index.json 104ms
[NuGet Manager] [Info]   NotFound https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/registrations2-semver2/microsoft.netcore.app.runtime.aot.cross.browser-wasm/index.json 275ms
[NuGet Manager] [Info]   NotFound https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/registrations2-semver2/microsoft.netcore.app.runtime.aot.cross.browser-wasm/index.json 463ms
System.AggregateException: One or more errors occurred. (microsoft.netcore.app.runtime.aot.cross.browser-wasm::6.0.0-preview.4.21222.10 is not found in NuGet feeds https://api.nuget.org/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json",)
 ---> Microsoft.DotNet.ToolPackage.NuGetPackageInstallerException: microsoft.netcore.app.runtime.aot.cross.browser-wasm::6.0.0-preview.4.21222.10 is not found in NuGet feeds https://api.nuget.org/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json",
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetPackageMetadataAsync(String packageIdentifier, NuGetVersion packageVersion, IEnumerable`1 sources, CancellationToken cancellationToken) in dotnet.dll:token 0x6000a15+0x306
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.DownloadPackageAsync(PackageId packageId, NuGetVersion packageVersion, PackageSourceLocation packageSourceLocation, Boolean includePreview) in dotnet.dll:token 0x6000a11+0x180
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) in System.Private.CoreLib.dll:token 0x6002c8a+0x11
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) in System.Private.CoreLib.dll:token 0x6002b9e+0x2b
   at System.Threading.Tasks.Task`1.get_Result() in System.Private.CoreLib.dll:token 0x6002b9c+0x8
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkManagedInstaller.<>c__DisplayClass14_0.<InstallWorkloadPack>b__0() in dotnet.dll:token 0x6000b09+0x41
   at Microsoft.DotNet.Cli.TransactionalAction.<>c__DisplayClass2_0.<Run>b__0() in dotnet.dll:token 0x6000cea+0x0
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback) in dotnet.dll:token 0x600091f+0x35
   at Microsoft.DotNet.Cli.TransactionalAction.Run(Action action, Action commit, Action rollback) in dotnet.dll:token 0x6000920+0x19
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkManagedInstaller.InstallWorkloadPack(PackInfo packInfo, SdkFeatureBand sdkFeatureBand, Boolean useOfflineCache) in dotnet.dll:token 0x60001bc+0x7e
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.<>c__DisplayClass14_1.<InstallWorkloadsWithInstallRecord>b__2() in dotnet.dll:token 0x6000b1a+0x15
   at Microsoft.DotNet.Cli.TransactionalAction.<>c__DisplayClass2_0.<Run>b__0() in dotnet.dll:token 0x6000cea+0x0
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback) in dotnet.dll:token 0x600091f+0x35
   at Microsoft.DotNet.Cli.TransactionalAction.Run(Action action, Action commit, Action rollback) in dotnet.dll:token 0x6000920+0x19
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.InstallWorkloadsWithInstallRecord(IEnumerable`1 workloadIds, SdkFeatureBand sdkFeatureBand) in dotnet.dll:token 0x60001cf+0xb5
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.InstallWorkloads(IEnumerable`1 workloadIds, Boolean skipManifestUpdate) in dotnet.dll:token 0x60001ce+0x61
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.Execute() in dotnet.dll:token 0x60001cb+0x216
   at Microsoft.DotNet.Cli.DotNetTopLevelCommandBase.RunCommand(String[] args) in dotnet.dll:token 0x60008ac+0x5e
   at Microsoft.DotNet.Workloads.Workload.WorkloadCommand.Run(String[] args) in dotnet.dll:token 0x6000145+0x6
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient) in dotnet.dll:token 0x6000915+0x2e8
   at Microsoft.DotNet.Cli.Program.Main(String[] args) in dotnet.dll:token 0x6000913+0x6f

the failing pack (in the baseline manifest is)

    "Microsoft.NETCore.App.Runtime.AOT.Cross.browser-wasm": {
      "kind": "Sdk",
      "version": "6.0.0-preview.4.21222.10",
      "alias-to": {
        "win-x86": "microsoft.netcore.app.runtime.aot.win-x86.cross.browser-wasm",
        "win-x64": "microsoft.netcore.app.runtime.aot.win-x64.cross.browser-wasm",
        "linux-x64": "microsoft.netcore.app.runtime.aot.linux-x64.cross.browser-wasm",
        "osx-x64": "microsoft.netcore.app.runtime.aot.osx-x64.cross.browser-wasm"
      }
    },

so it should be trying to install

microsoft.netcore.app.runtime.aot.osx-x64.cross.browser-wasm.6.0.0-preview.4.21222.10 not microsoft.netcore.app.runtime.aot.cross.browser-wasm.6.0.0-preview.4.21222.10

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

mhutch commented 3 years ago

This exposes a limitation in the WorkloadResolver APIs. On PackInfo instances, the Path uses the resolved ID (which takes aliasing into account) so that it's the path to the actual files on disk. However the Id is the original unresolved ID.

One option would be to change the PackInfo.Id to the resolved ID. I don't particularly like that, as aliases are supposed to be transparent. An alternative would be to add a new property called NuGetPackageId or AliasedPackageId or something specifically for the installer to use.

sfoslund commented 3 years ago

Fixed by #17227

radu-matei commented 3 years ago

With the new .NET 6 preview 4, this now fails as well:

➜ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.4.21255.9
 Commit:    950e4949a7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-preview.4.21255.9\

Host (useful for support):
  Version: 6.0.0-preview.4.21253.7
  Commit:  bfd6048a60

.NET SDKs installed:
  6.0.100-preview.4.21255.9 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0-preview.4.21253.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.4.21253.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.4.21254.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

➜ dotnet workload install microsoft-net-sdk-blazorwebassembly-aot

Installing pack Microsoft.NET.Runtime.MonoAOTCompiler.Task version 6.0.0-preview.4.21253.7...
System.AggregateException: One or more errors occurred. (No NuGet sources are defined or enabled)
 ---> Microsoft.DotNet.ToolPackage.NuGetPackageInstallerException: No NuGet sources are defined or enabled
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.LoadNuGetSources(PackageSourceLocation packageSourceLocation) in dotnet.dll:token 0x6000a18+0xfd
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.DownloadPackageAsync(PackageId packageId, NuGetVersion packageVersion, PackageSourceLocation packageSourceLocation, Boolean includePreview) in dotnet.dll:token 0x6000a14+0x2f
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) in System.Private.CoreLib.dll:token 0x6002d42+0x11
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) in System.Private.CoreLib.dll:token 0x6002c56+0x2b
   at System.Threading.Tasks.Task`1.get_Result() in System.Private.CoreLib.dll:token 0x6002c54+0x8
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkManagedInstaller.<>c__DisplayClass14_0.<InstallWorkloadPack>b__0() in dotnet.dll:token 0x6000b0e+0x41
   at Microsoft.DotNet.Cli.TransactionalAction.<>c__DisplayClass2_0.<Run>b__0() in dotnet.dll:token 0x6000cef+0x0
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback) in dotnet.dll:token 0x6000922+0x35
   at Microsoft.DotNet.Cli.TransactionalAction.Run(Action action, Action commit, Action rollback) in dotnet.dll:token 0x6000923+0x19
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkManagedInstaller.InstallWorkloadPack(PackInfo packInfo, SdkFeatureBand sdkFeatureBand, Boolean useOfflineCache) in dotnet.dll:token 0x60001bc+0x7e
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.<>c__DisplayClass14_1.<InstallWorkloadsWithInstallRecord>b__2() in dotnet.dll:token 0x6000b1f+0x15
   at Microsoft.DotNet.Cli.TransactionalAction.<>c__DisplayClass2_0.<Run>b__0() in dotnet.dll:token 0x6000cef+0x0
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback) in dotnet.dll:token 0x6000922+0x35
   at Microsoft.DotNet.Cli.TransactionalAction.Run(Action action, Action commit, Action rollback) in dotnet.dll:token 0x6000923+0x19
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.InstallWorkloadsWithInstallRecord(IEnumerable`1 workloadIds, SdkFeatureBand sdkFeatureBand) in dotnet.dll:token 0x60001cf+0xb5
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.InstallWorkloads(IEnumerable`1 workloadIds, Boolean skipManifestUpdate) in dotnet.dll:token 0x60001ce+0x58
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand.Execute() in dotnet.dll:token 0x60001cb+0x216
   at Microsoft.DotNet.Cli.DotNetTopLevelCommandBase.RunCommand(String[] args) in dotnet.dll:token 0x60008af+0x5e
   at Microsoft.DotNet.Workloads.Workload.WorkloadCommand.Run(String[] args) in dotnet.dll:token 0x6000145+0x6
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient) in dotnet.dll:token 0x6000918+0x2e8
   at Microsoft.DotNet.Cli.Program.Main(String[] args) in dotnet.dll:token 0x6000916+0x6f
sfoslund commented 3 years ago

It looks like the error is:

NuGetPackageInstallerException: No NuGet sources are defined or enabled

This indicates that your nuget configuration is probably flawed, do you have a nuget.config file that's being picked up? If so, what is the content?