Home > front end >  Creating, building and running MAUI .NET7.0 sample app using dotnet CLI on MS Windows 10
Creating, building and running MAUI .NET7.0 sample app using dotnet CLI on MS Windows 10

Time:11-15

I have MS Windows 10 (v.21H2, build 19044.2251) system with .NET 7.0 SDK and MS Visual Studio 2022 17.4.0 installed and I can create and run a MAUI default sample project from within VS2022.

Now I wanted to create, compile, build and run a sample .NET 7.0 MAUI app as an MS Windows app using dotnet CLI similar to .NET MAUI with .NET CLI (Command Line Interface) but for MS Windows.

By running

dotnet new maui

I'm getting a corrrect MAUI project and solution (I can copy it and build/run it from within VS2022).

What should be the second dotnet CLI command line to build and to run this MAUI sample project

dotnet build -t:??? -f net7.0-windows10.0.19041.0(?)  ...

?

CodePudding user response:

It seems that we couldn't use dotnet cli to build .net maui app targeted on Windows currently. A related discussion on Github can be seen : How to run MAUI on Windows from command line?. You could join them for discussion.

However, good news is that reference to this Github issue : Build Windows target using dotnet build instead of msbuild.exe , we could use the MSBuild command instead of dotnet build command to build the MAUI application. Try the following command :

msbuild -r -p:Configuration=Release -p:RestorePackages=false -p:TargetFramework=net7.0-windows10.0.19041

Hope my answer could help you.

  • Related