0

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

  • MyModel.cproj using .net Framwework 4.6.1 (reusing from Xamarin App, but it is a class Library)
  • MyMauiApp.cproj using .net 8.0

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)

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

Rui just update the question, and I followed your recommendation using .net8 project
Can you clean your bin/obj .. if its a git repo do a git clean -fdx . make sure there's none. Is MyModel.cproj a sdk style project? what's the TargetFramework there? maybe post your csproj
I am using visual studio code, and now it works, in visual studio for Mac does not
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.