How to build the MAUI project using Cake plugin? #3384
-
I have a simple MAUI project template and trying to build a .sln project using MS build method, but it leads to the error. My machine was configured with MAUI platform and i can be able to run simple MAUI sample in Visual Studio.
Also, I have tried with command line dotnet build MauiApp1.sln to build a solution project. I don't work. I have attached the simple MAUI project with cake file under the build folder. Machine config: Visual Studio 2019 16.11.0 Preview 1 Can you please help me on how to run MAUI project using Cake plugin? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
For Cake to build your app, you first need to find out how your app is build. |
Beta Was this translation helpful? Give feedback.
-
For building Maui app I would recomend using the .NET CLI instead of MSBuild A script could look something like this public record BuildData(
string Configuration,
FilePath Solution
);
Setup(
context => new BuildData(
"Release",
"./MauiApp1.sln"
)
);
Task("Clean")
.Does<BuildData>((context, data) => {
CleanDirectories("./src/**/bin/" + data.Configuration);
CleanDirectories("./src/**/obj");
});
Task("Restore")
.IsDependentOn("Clean")
.Does<BuildData>((context, data) => DotNetCoreRestore(data.Solution.FullPath));
Task("Build")
.IsDependentOn("Restore")
.Does<BuildData>((context, data) => DotNetCoreBuild(
data.Solution.FullPath,
new DotNetCoreBuildSettings {
NoRestore = true,
Configuration = data.Configuration
})
);
Task("Default")
.IsDependentOn("Build");
RunTarget(Argument("target", "Default")); Also a great tip is to utilize the .NET Global tool dotnet-maui-check, as it will ensure you've got all your SDKs and dependencies in order. This can also be used as part of your CI process |
Beta Was this translation helpful? Give feedback.
-
Hi Team, Thanks for your solution, it works fine. |
Beta Was this translation helpful? Give feedback.
For building Maui app I would recomend using the .NET CLI instead of MSBuild
A script could look something like this