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

Improve error messages reported when a workload is missing #30230

Closed
Tracked by #30008
tmat opened this issue Jan 31, 2023 · 8 comments
Closed
Tracked by #30008

Improve error messages reported when a workload is missing #30230

tmat opened this issue Jan 31, 2023 · 8 comments
Assignees

Comments

@tmat
Copy link
Member

tmat commented Jan 31, 2023

When a repo is cloned that requires certain workload to be installed (e.g. vsmac) that is not currently installed, dotnet restore reports the following error:

C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5):
error NETSDK1147: To build this project, the following workloads must be installed: macos

C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5):
error NETSDK1147: To install these workloads, run the following command: dotnet workload restore

Following the suggestion and running dotnet workload restore fails with a cryptic error:

C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1226,3):
error MSB4019: The imported project "C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\13.1.1024\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found. 
Confirm that the expression in the Import declaration ";..\13.1.1024\targets\Xamarin.Shared.Sdk.MultiTarget.targets" is correct,
and that the file exists on disk.

The actual command that's need to build the repo is: dotnet workload install macos

The error message should be fixed to point the user the right direction.

Further technical details

D:\vsmac>dotnet --info
.NET SDK:
 Version:   7.0.102
 Commit:    4bbdd14480

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.102\

Host:
  Version:      8.0.0-alpha.1.22559.2
  Architecture: x64
  Commit:       dd7fdb723d

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]
  5.0.405 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]
  6.0.113 [C:\Program Files\dotnet\sdk]
  6.0.308 [C:\Program Files\dotnet\sdk]
  6.0.405 [C:\Program Files\dotnet\sdk]
  7.0.102 [C:\Program Files\dotnet\sdk]
  7.0.200-preview.22628.1 [C:\Program Files\dotnet\sdk]
  8.0.100-alpha.1.22577.1 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.22 [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.0-rc.1.20451.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.14 [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.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-alpha.1.22558.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.22 [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.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.14 [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.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-alpha.1.22559.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.14 [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.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0-alpha.1.22552.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

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

Environment variables:
  Not set

global.json file:
  D:\vsmac\global.json

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

Download .NET:
  https://aka.ms/dotnet/download
@sandyarmstrong
Copy link
Member

sandyarmstrong commented Feb 6, 2023

An alternate title for this issue might be "workload restore is broken with macos workload; workload install must be used instead". It would be great to see workload restore fixed since apparently that is what VS uses.

@sandyarmstrong
Copy link
Member

@marcpopMSFT @rolfbjarne @dalexsoto @baronfel I'd love to understand how to move forward here. Not being able to restore workloads from the IDE is a barrier for multiple collaboration efforts between the VSMac and VSWin teams. We need developers on Windows to be able to load solutions that include projects that multi-target netX.0-macos without having to get their command line environment just right and then launch VS from there.

@rolfbjarne
Copy link
Member

rolfbjarne commented Feb 20, 2023

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\13.1.1024\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found.

This particular error message should disappear with this fix: xamarin/xamarin-macios#17498

That said, I don't know if that would help the underlying issue (that the suggested solution from the error message doesn't work).

@dsplaisted
Copy link
Member

The dotnet workload restore command needs to run a target in the project in order to determine which workloads should be installed, and that's failing here. It sounds like this is fixed in the Xamarin targets.

@rolfbjarne Would it be possible to move the code that adds to AfterMicrosoftNETSdkTargets from the workload manifest to a target inside the actual workload? I think that would be a more robust way of avoiding an error like this.

@baronfel baronfel removed the untriaged Request triage from a team member label Feb 22, 2023
@rolfbjarne
Copy link
Member

@dsplaisted I changed it to only add to AfterMicrosoftNETSdkTargets if the file to be added actually exists: xamarin/xamarin-macios@bef4867, I suppose that should work as well?

@dsplaisted
Copy link
Member

@dsplaisted I changed it to only add to AfterMicrosoftNETSdkTargets if the file to be added actually exists: xamarin/xamarin-macios@bef4867, I suppose that should work as well?

It probably works, but it looks like the import path depends on a property that is set in the workloads, so when the workloads aren't imported the property is blank so its trying to import from a path relative to the workload manifest targets instead. So it's not checking the existence of the file it's actually trying to import, it's checking a different file path which will probably never exist.

It seems like it would be more precise to check if the property was set, or to move the logic to the import targets where you know it will be set.

@rolfbjarne
Copy link
Member

@dsplaisted I changed it to only add to AfterMicrosoftNETSdkTargets if the file to be added actually exists: xamarin/xamarin-macios@bef4867, I suppose that should work as well?

It probably works, but it looks like the import path depends on a property that is set in the workloads, so when the workloads aren't imported the property is blank so its trying to import from a path relative to the workload manifest targets instead. So it's not checking the existence of the file it's actually trying to import, it's checking a different file path which will probably never exist.

It seems like it would be more precise to check if the property was set, or to move the logic to the import targets where you know it will be set.

Ok, I've filed an issue to see if we can get this done: xamarin/xamarin-macios#17618

@baronfel
Copy link
Member

baronfel commented Mar 8, 2023

Thanks everyone for digging into this. Happy that we found a resolution.

@baronfel baronfel closed this as completed Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants