MSBuild compilation setting for WinUI net5.0 desktop applications #3016
Replies: 6 comments 1 reply
-
Cake only shells out to MSBuild, so impossible to know for sure what's not working without a minimal reproducable example. I think the best approach would be to figure out how to build it from command line calling |
Beta Was this translation helpful? Give feedback.
-
Hi, I've created a simple winui destop project with cake build files and replicated the issue. And I tried DotNetCoreBuild with the parameters, there were still issues. Please find the reproducible sample below. |
Beta Was this translation helpful? Give feedback.
-
@KanniyappanP Before you can make the build process work with Cake, you need to understand how you can build your project outside of Visual Studio, via the command-line. Once you get there, we can help you write a Cake script that runs these commands. AFAIK, UWP projects at the moment don't build with Try to run something like this via the command-line, to see what you get. msbuild /t:restore Test_WinUI_Project_CakeBuild_Compilation_Net50.sln
msbuild /t:build Test_WinUI_Project_CakeBuild_Compilation_Net50.sln The final command might look something like: msbuild Test_WinUI_Project_CakeBuild_Compilation_Net50.sln /t:WapProjTemplate1:Rebuild /p:Configuration=Release /p:UapAppxPackageBuildMode=StoreAndSideload /p:AppxBundlePlatforms=“x86|x64” /p:AppxBundle=Always /p:AppxSymbolPackageEnabled=True /p:AppxPackageSigningEnabled=True |
Beta Was this translation helpful? Give feedback.
-
I tried the above commands via the command-line(VS2019) and the compilation of the project was successful. But the cake process has only failed for the projects. |
Beta Was this translation helpful? Give feedback.
-
@augustoproiete I used the
Compiled a project using below commands. Restore a project:
Build a project:
Final command:
Note: I can automate uwp winui projects using |
Beta Was this translation helpful? Give feedback.
-
@KanniyappanP Glad you found the right MSBuild command-line for your project! So assuming your final command above works, to run it through Cake, it should be straightforward using one of the MSBuild aliases with the corresponding settings to match your command-line arguments. E.g.: MSBuild("./Test_WinUI_Project_CakeBuild_Compilation_Net50.sln", settings => settings
.UseToolVersion(MSBuildToolVersion.VS2019)
.SetConfiguration("Release")
.WithRestore()
.WithTarget("Build")
.WithProperty("UapAppxPackageBuildMode", "StoreAndSideload")
.WithProperty("AppxBundlePlatforms", "x86|x64")
.WithProperty("AppxBundle", "Always")
.WithProperty("AppxSymbolPackageEnabled", "True")
.WithProperty("AppxPackageSigningEnabled", "True")
); NB: You could also run the |
Beta Was this translation helpful? Give feedback.
-
In the build system, I'm trying to automate the Winui desktop projects using the cake(v0.38.4) MSBuild() and the desktop projects that failed to build. If I run net5.0 desktop projects with the latest VS2019 and VS2019 preview, both will be successful
locally. But the following issues failed in our build system.
I am using below configuration in my build systems.
MSBuildToolVersion VS2019 (tried with Default).
SetConfiguration: Release-Xml (tried with Release).
cake.MSBuild(csProject.FullName, settings => settings.SetConfiguration("Release-Xml"). UseToolVersion(MSBuildToolVersion.VS2019). WithProperty("SetMSBuildPlatform", "AnyCPU"). WithProperty("referencepath", referencepath). WithProperty("PreBuildEvent", ""). WithProperty("GenerateLibraryLayout", "true"). WithProperty("CodeAnalysisRuleSet", $"{csProject.Directory}/FxCop.ruleset"). WithProperty("StyleCopOverrideSettingsFile", $"{csProject.Directory}/settings.StyleCop"). AddFileLogger(new MSBuildFileLogger { LogFile = warningLog, MSBuildFileLoggerOutput = MSBuildFileLoggerOutput.WarningsOnly }). AddFileLogger(new MSBuildFileLogger { LogFile = errorLog, MSBuildFileLoggerOutput = MSBuildFileLoggerOutput.ErrorsOnly }). WithProperty("WarningLevel", assembly.WarningLevel.ToString()). WithProperty("TreatWarningsAsErrors", assembly.TreatWarningsAsErrors.ToString()). WithProperty("OutputPath", projoutputpath). WithProperty("IntermediateOutputPath", intermediateOutputPath). SetVerbosity(Cake.Core.Diagnostics.Verbosity.Minimal));
For MSBuild compilation:
C:\Program Files\dotnet\sdk\5.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5)
: error NETSDK1005: Assets file 'D:\WIN UI\winui ci work\WPF FxCop Issue\core-desktop\WinUI\Core.WinUI\Src\obj\project.
assets.json' doesn't have a target for 'net5.0-windows10.0.18362.0'. Ensure that restore has run and that you have incl
uded 'net5.0-windows10.0.18362.0' in the TargetFrameworks for your project. [D:\WIN UI\winui ci work\WPF FxCop Issue\co
re-desktop\WinUI\Core.WinUI\Src\Syncfusion.Core.WinUI_Net50.csproj]
Also checked with updated Cake (Cake v1.0.0-rc0002) in my build system and projects (toos/package.config) and DotNetCoreBuild method tried to compile net5.0, but below the issue raised when compiling net projects.
Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreBuild(context, csProject.FullName, new DotNetCoreBuildSettings { Framework = "net5.0-windows10.0.18362.0", Configuration = "Release" });
C:\Program Files\dotnet\sdk\5.0.101\Microsoft.Common.CurrentVersion.targets(2444,6): error MSB4062: The "Microsoft.Build.Tasks.FindInvalidProjectReferences" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\WIN UI\winui ci work\WPF FxCop Issue\core-desktop\WinUI\Core.WinUI\Src\Syncfusion.Core.WinUI_Net50___.csproj]
WinUI net5.0 project setting:
Visual Studio Configuration: In both environments below, I can run projects.
Visual Studio 2019 v16.8.3 (For the previous VS2019 v16.7.4, the compilation of projects failed)
SDK 5.0.100-preview.8
Visual Studio 2019 Preview v16.9
SDK 5.0.100-preview.8
Please suggest how to configure the WinUI net5.0 desktop projects in cake build systems?
Does Cake (0.38.4 or 1.0.0 rc2) build system support the WinUI net5.0 desktop projects? if yes Please share the cake build setting (VS2019 or VS2019 preview) the WinUI net5.0 desktop projects?
Beta Was this translation helpful? Give feedback.
All reactions