尝试将Visual Studio 2019构建工具安装到Docker映像中

问题描述

我正在尝试将Visual Studio Build Tools 2019(版本16_4_5)安装到Docker中,但未安装任何内容

我已按照Microsoft(https://docs.microsoft.com/de-de/visualstudio/install/build-tools-container?view=vs-2019)的指示使用以下构建文件

# escape=`

# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd","/S","/C"]

# Install build tools 16.4.5
ADD https://download.visualstudio.microsoft.com/download/pr/378e5eb4-c1d7-4c05-8f5f-55678a94e7f4/b9619acc0f9a1dfbdc1b67fddf9972e169916ceae237cf95f286c9e5547f804f/vs_BuildTools.exe C:\TEMP\vs_buildtools.exe

# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload,excluding workloads and components with kNown issues.
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
    --installPath C:\BuildTools `
    --add Microsoft.VisualStudio.Workload.AzureBuildTools `
    --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

# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat","&&","powershell.exe","-Nologo","-ExecutionPolicy","Bypass"]

构建非常快,但是没有安装任何工作负载。有人知道如何解决此问题吗?

谢谢。

解决方法

我发现了问题。在基本映像mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019中,安装了Visual Studio构建工具的较新版本。当我们尝试在此基本映像上安装旧版本的构建工具时,它将无法正常工作。