I'm attempting to build Microsoft's cs-winui-unpackaged sample from within a Windows Docker container running on a Windows 10 Pro 19045.3208 host, however it's failing due to the following error:
MSBuild version 17.3.2+561848881 for .NET
Determining projects to restore...
Restored C:\application\SelfContainedDeployment.csproj (in 12.09 sec).
C:\Users\ContainerUser\.nuget\packages\microsoft.windowsappsdk\1.3.230331000\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(590,9): error MSB3073: The command ""C:\Users\ContainerUser\.nuget\packages\microsoft.windowsappsdk\1.3.230331000\buildTransitive\..\tools\net5.0\..\net472\XamlCompiler.exe" "obj\arm64\Release\net6.0-windows10.0.19041.0\win10-arm64\\input.json" "obj\arm64\Release\net6.0-windows10.0.19041.0\win10-arm64\\output.json"" exited with code -1073741515. [C:\application\SelfContainedDeployment.csproj]
I'm using the following command on the host machine to run the build:
docker run `
--platform windows `
--rm `
--interactive `
--tty `
--mount "type=bind,source=$PWD,target=C:\application" `
--workdir /application `
mcr.microsoft.com/dotnet/sdk:6.0 `
dotnet publish --configuration Release
So far I haven't been able to find any concrete information about the XamlCompiler error code in question.
What does this error mean, and what do I need to do to fix the build?
TL;DR: you must use an image bases on server-core like mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022
Microsoft.UI.Xaml.Markup.Compiler.interop.targets from the windows-app-sdk nuget contains a hard-coded path to net472\XamlCompiler.exe
.
<PropertyGroup Condition="$(XamlCompilerExePath) == ''">
<XamlCompilerExePath>$(_MuxPackageToolsFolder)..\net472\XamlCompiler.exe</XamlCompilerExePath>
</PropertyGroup>
It's still this way in 1.5!:
Nanoserver does not contain the classic net framework.
You must use an image bases on WindowsServerCore which contains a full net framework.
/p:UseXamlCompilerExecutable=false
should workThis forces msbuild to use the net5 assemblies instead of the 4.7 exe.
The switch works, but it leads to a new issue.
c:\cache\nuget_packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(505,9): error MSB4062: The "Microsoft.UI.Xaml.Markup.Compiler.Tasks.CompileXaml" task could not be loaded from the assembly c:\cache\nuget_packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive\..\tools\net5.0\Microsoft.UI.Xaml.Markup.Compiler.dll. Could not load file or assembly 'System.Security.Permissions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. Confirm that the <UsingTask> 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. [C:\builds\MyProject\MyProject.app\src\MyProjectApp\MyProjectApp\MyProjectApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]