Reputation: 25349
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?
Upvotes: 5
Views: 4675
Reputation: 46
for me the below one works for windows app. first you need to build the App using the dotnet command line from the project folder:
dotnet build -f net8.0-windows10.0.19041.0 -c Debug -p:PublishReadyToRun=true -p:WindowsPackageType=None
and then the replace the build with run the usual way or you can directly use the run command in a single step. usually i follow build and run
dotnet run -f net8.0-windows10.0.19041.0 -c Debug -p:PublishReadyToRun=true -p:WindowsPackageType=None
i dont know if anyone looking for this answer anymore. :)
Upvotes: 0
Reputation: 10063
This is a known issue
that being tracked in these two threads: Unable to run Windows application from command line , Unable to run Windows application from .NET SDK command line, feel free to follow up with them. BTW, it might be related to the settings in the launchSettings.json
file. You can refer to Error after modifying launchSettings: The launch profile "(Default)" could not be applied.
Upvotes: 3