With typical web apps we do the following.
dotnet new webapp --name ./MyNewWebApp --framework net6.0
cd MyNewWebApp
dotnet build ./MyNewWebApp.csproj
dotnet run --project ./MyNewWebApp.csproj
And it works. Now I trying to play around with dotnet MAUI projects.
With MAUI the project file is complex when compared to a web project.
It has multiple target frameworks, and the csproj file looks as follows.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
...
</PropertyGroup>
<ItemGroup>
...
</ItemGroup>
</Project>
Further more, the launchSettings.json file is quite simple.
"profiles": {
"Windows Machine": {
"commandName": "MsixPackage",
"nativeDebugging": false
}
}
With visual studio I am able to create and run them. The Visual Studio launch tool bar shows the following.
So now with MAUI project, build command works fine.
dotnet build ./MauiCliBasic.csproj
But when I execute the run command, I get the following errors.
dotnet run --project ./MauiCliBasic.csproj
The launch profile "(Default)" could not be applied. A usable launch profile could not be located.
Unable to run your project Your project targets multiple frameworks. Specify which framework to run using '--framework'.
And when I specify the framework I still get the errors.
dotnet run --project ./MauiCliBasic.csproj --framework net6.0-windows10.0.19041.0
The launch profile "(Default)" could not be applied. A usable launch profile could not be located.
So what am I missing?