I am trying to build Windows docker image with Visual Studio Build tools. Build tools is getting installed, however Microsoft.Cpp.Default.props is missing.
*error MSB4019: The imported project "C:\
Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\P
rogram Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.*
Below is the snippet from dockerfile:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
WORKDIR "C:\Users\ContainerUser"
RUN powershell.exe New-Item BuildSoftware -ItemType "directory"
COPY vs_buildtools__1759529960.1620654219.exe "C:\Users\ContainerUser\BuildSoftware"
RUN C:\Users\ContainerUser\SocialBuild\vs_buildtools__1759529960.1620654219.exe --quiet --add --includeRecommended Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --add Microsoft.VisualStudio.Component.Windows10SDK.18362 --add Microsoft.VisualStudio.Workload.VCTools –-includeOptional --add Microsoft.Net.Component.4.7.TargetingPack --add Microsoft.VisualStudio.Workload.OfficeBuildTools --add Microsoft.VisualStudio.Workload.UniversalBuildTools --add Microsoft.VisualStudio.Workload.VisualStudioExtensionBuildTools --add Microsoft.VisualStudio.Workload.MSBuildTools --wait
Even with Microsoft.VisualStudio.Workload.VCTools, cpp files/tools is not getting installed in Docker container.
Also tried installing with npm install --global --production windows-build-tools and below chocolatey commands inside docker conatiner.
choco install vcredist-all -Y
choco install visualstudio2019buildtools -Y
choco install visualstudio2019community -Y*
Looking for the best possible solution to the problem
After lots of Googling and trying, I have created a Dockerfile that includes the *.cpp.props files:
FROM mcr.microsoft.com/dotnet/framework/sdk:3.5-windowsservercore-ltsc2019
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
SHELL ["cmd", "/S", "/C"]
RUN (start /w C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache modify `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" `
--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools `
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended `
--add Microsoft.Component.MSBuild `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
--remove Microsoft.VisualStudio.Component.Windows81SDK `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0)
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
Mark the MSBuild component which has to be explicitly added. The "ManagedDesktopBuildTools" might not be needed, but for my projects I have combined C#/C++ solutions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With