Unable to build Windows Workflow project in windows docker. Error - XamlBuildTask.dll not found

328 Views Asked by At

This is my docker file -

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
RUN net user admin /ADD
RUN net localgroup Administrators /add admin
USER admin

RUN C:\TEMP\vs_buildtools.exe modify`
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" ^ `
--add Microsoft.VisualStudio.Component.Workflow.BuildTools ^ `
--quiet --norestart --nocache --wait `

SHELL ["cmd", "/C"]

CMD [ "cmd" ]

I want to install the Workflow.BuildTools component but this does not work. The build succeeds and I still get a failure when building workflow projects.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Xaml.targets(193,5): error MSB4062: The "Microsoft.Build.Tasks.Xaml.PartialClassGenerationTask" task could not be loade 
d from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\XamlBuildTask.dll. Could not load file or assembly 'file:///C:\Progr 
am Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\XamlBuildTask.dll' or one of its dependencies. 

What can I do to fix this?

2

There are 2 best solutions below

0
Vinicius Apolinario On

Have you checked the official documentation on this topic: https://learn.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2022

There's a sample dockerfile, with additional instructions. A few things to notice: The default shell on 4.8 images is PowerShell. Also, you might want to ensure you're cleaning up your image so you reduce the size.

0
ChrisPy On

This worked for me:

In command prompt

curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe
start /w vs_buildtools.exe --quiet --wait --norestart --nocache --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" --add Microsoft.VisualStudio.Component.Workflow.BuildTools