saramgsilva
saramgsilva

Reputation: 762

Error in Mac when build a Maui project migrated from Xamarin

I am migrating a Xamarin app to dotnet MAUI, and I have two projects:

In windows when I run the android app I do not have any problem, but in my Mac, when I tried to build the project it gives me the error, which tell to run "dotnet workloads restore", but when I do it this error appears:

*Project "............./MyMobileMaui.csproj" (_GetRequiredWorkloads target(s)):


Project "............./MyMobileMaui.csproj" is building "............./MyMobileMaui.csproj" (_GetRequiredWorkloads target(s)):


Project "............./MyMobileMaui.csproj" is building "............./MyModel.csproj" (_GetRequiredWorkloads target(s)): "............./"............./MyModel.csproj" .csproj" : error MSB4057: The target "_GetRequiredWorkloads" does not existin the project. Done building project "MyModel.csproj" .csproj" -- FAILED. Failed to restore workload for project "............./MyMobileMaui.csproj" : Failed to run MSBuild Target _GetRequiredWorkloads.*

Should my MyModel.cproj a MAUI Class Library?

EDIT YES

But it gives an error

Error: Unable to create package spec for project. '............./MyMobileMaui.csproj' Please see the Package Console for more details. (MyMobileMaui)

Getting restore information for project '............./MyMobileMaui.csproj' /usr/local/share/dotnet/sdk/7.0.311/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 To install these workloads, run the following command: dotnet workload restore /usr/local/share/dotnet/sdk/7.0.311/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 To install these workloads, run the following command: dotnet workload restore /usr/local/share/dotnet/sdk/7.0.311/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 To install these workloads, run the following command: dotnet workload restore Unable to create package spec for project. '............./MyMobileMaui.csproj'

I run the dotnet workloads restore and it gives me

Successfully installed workload(s) maui-tizen maui-ios maui-android maui.

But the same error happens again, and again...(I am using only IOS and Android targets)

Upvotes: 0

Views: 586

Answers (2)

Jianwei Sun - MSFT
Jianwei Sun - MSFT

Reputation: 4312

Well, according to your comment, as an answer:

Error in Mac when build a Maui project migrated from Xamarin, when I tried to build the project it gives me the error, which tell to run "dotnet workloads restore", but when I do it this error appears: .........

Using visual studio code instead of visual studio for Mac can fix the problem.

Upvotes: 0

Rui Marinho
Rui Marinho

Reputation: 1712

You have to move your MyModel.cproj to a net8 project or netstandard2.0 or 2.1

Upvotes: 1

Related Questions