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

[net7.0-rc2] Creating a cross-targeted library with net6.0-mac fails with an obscure error #16400

Closed
jeromelaban opened this issue Oct 20, 2022 · 10 comments · Fixed by #17498
Closed
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@jeromelaban
Copy link
Contributor

Steps to Reproduce

Without having the macos SDK installed, build the following:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFrameworks>net6.0-macos</TargetFrameworks>
	</PropertyGroup>
</Project>

Expected Behavior

An error from .NET SDK to flag that a workload is missing.

Actual Behavior

1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1220,3): 
error MSB4019: The imported project "C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\12.3.1186-rc.2\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found. 
Confirm that the expression in the Import declaration ";..\12.3.1186-rc.2\targets\Xamarin.Shared.Sdk.MultiTarget.targets" is correct, and that the file exists on disk.

Environment

dotnet --version
7.0.100-rc.2.22477.23
dotnet workload list

Installed Workload Id      Manifest Version                         Installation Source
---------------------------------------------------------------------------------------
ios                        16.0.1271-rc.2-xcode14/7.0.100-rc.2      VS 17.4.33015.44
maui-android               7.0.0-rc.2.6866/7.0.100-rc.2             VS 17.4.33015.44
maui-windows               7.0.0-rc.2.6866/7.0.100-rc.2             VS 17.4.33015.44
maui-maccatalyst           7.0.0-rc.2.6866/7.0.100-rc.2             VS 17.4.33015.44
android                    33.0.0-rc.2.202/7.0.100-rc.2             VS 17.4.33015.44
maccatalyst                15.4.1186-rc.2/7.0.100-rc.2              VS 17.4.33015.44
maui-ios                   7.0.0-rc.2.6866/7.0.100-rc.2             VS 17.4.33015.44

Use `dotnet workload search` to find additional workloads to install.

Build Logs

@jeromelaban jeromelaban changed the title [net7.0-rc2] Creating a cross-targeted library with net6.0-mac fails [net7.0-rc2] Creating a cross-targeted library with net6.0-mac fails with an obscure error Oct 20, 2022
@rolfbjarne
Copy link
Member

Can you get a binlog from a command line build?

$ dotnet build /bl:msbuild.binlog

That will tell us exactly what you have installed and what's loaded during the build.

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Oct 20, 2022
@ghost
Copy link

ghost commented Oct 20, 2022

Hi @jeromelaban. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jeromelaban
Copy link
Contributor Author

I wish I had taken the binlog before creating the issue and fixing it :) I'll see if I can remove the workload to repro.

@ghost ghost added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Oct 20, 2022
@jeromelaban
Copy link
Contributor Author

Here's some update.

The above message only happens when built from VS windows, not on the CLI.

Here's the binlog captured from VS: issue16400.zip and the CLI: 16400-msbuild-cli.zip

@dalexsoto dalexsoto added this to the Future milestone Oct 21, 2022
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Oct 25, 2022
@rolfbjarne
Copy link
Member

Looks like this happens when the IDE executes the _SdkGetRidsPerTargetFramework target. It should be fairly easy to work around on our side (check if the corresponding file exists before trying to import it), but this is in a rather sensitive code path, and since it seems to be easy enough to work around (install the macOS workload), I'm going to target .NET 8 for the fix.

@rolfbjarne rolfbjarne added bug If an issue is a bug or a pull request a bug fix and removed need-attention An issue requires our attention/response labels Oct 25, 2022
@rolfbjarne rolfbjarne modified the milestones: Future, .NET 8 Oct 25, 2022
@rolfbjarne
Copy link
Member

Tentative fix: rolfbjarne@af47d23 (for .NET 8).

@steowens
Copy link

steowens commented Dec 19, 2022

This happens with most of the visual studio templates. About the only thing that works is the WSP. The other stuff is just vaporware. For example on a fresh project with a fresh install of the latest Visual Studio 2022, when you build the multi platform solution you get:

Failed to restore C:\Users\steve\source\repos\NotitraceClient\NotitraceClient.csproj (in 3 ms).
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
1>C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1220,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\16.1.1477\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found. Confirm that the expression in the Import declaration ";..\16.1.1477\targets\Xamarin.Shared.Sdk.MultiTarget.targets" is correct, and that the file exists on disk.
1>Done building project "NotitraceClient.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maui-android
1>C:\Program Files\dotnet\sdk\7.0.101\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
1>Done building project "NotitraceClient.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1220,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\16.1.1477\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found. Confirm that the expression in the Import declaration ";..\16.1.1477\targets\Xamarin.Shared.Sdk.MultiTarget.targets" is correct, and that the file exists on disk.
1>Done building project "NotitraceClient.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maui-tizen
1>C:\Program Files\dotnet\sdk\7.0.101\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
1>Done building project "NotitraceClient.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:01.291 ==========

@lukasf
Copy link

lukasf commented Jan 30, 2023

I am hitting this error message, even though the macos workload is installed:

Installierte Workload-ID      Manifestversion        Installationsquelle
-----------------------------------------------------------------------------------
android                       33.0.4/7.0.100         SDK 7.0.100, VS 17.4.33213.308
ios                           16.1.1477/7.0.100      SDK 7.0.100, VS 17.4.33213.308
maccatalyst                   16.1.1477/7.0.100      SDK 7.0.100, VS 17.4.33213.308
macos                         13.0.2032/7.0.100      SDK 7.0.100
maui-windows                  7.0.52/7.0.100         VS 17.4.33213.308
maui-maccatalyst              7.0.52/7.0.100         VS 17.4.33213.308
maui-ios                      7.0.52/7.0.100         VS 17.4.33213.308
maui-android                  7.0.52/7.0.100         VS 17.4.33213.308

Build error:

1>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.0.2032\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found. Confirm that the expression in the Import declaration ";..\13.0.2032\targets\Xamarin.Shared.Sdk.MultiTarget.targets" is correct, and that the file exists on disk.

I am trying to create a new cross-platform UNO library, but hitting this bug. Any ideas? How can I work around this?

@jeromelaban
Copy link
Contributor Author

@lukasf this generally happens because VS does not install the macos workload by default (among some other unknown parts).

You can try going into the .Mobile folder, then run dotnet workload install macos.

@lukasf
Copy link

lukasf commented Jan 30, 2023

Thank you. This solved my problem. It is a bit weird though, that I have to install the macos workload when it is already shown in the list of installed workloads. When running the command, I even got a warning that it is already installed, but then it started installing a whole lot of stuff and now it builds correctly.

vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Feb 13, 2023
rolfbjarne added a commit that referenced this issue Feb 14, 2023
…arget.targets file if it exists. Fixes #16400. (#17516)

Hopefully fixes #16400.

Backport of #17498

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
@ghost ghost locked as resolved and limited conversation to collaborators Mar 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
5 participants