如何在Docker中安装Visual Studio 12 BuildTools

如何在Docker中安装Visual Studio 12 BuildTools,docker,visual-studio-2012,docker-for-windows,Docker,Visual Studio 2012,Docker For Windows,我是Docker的新手,我正在准备我的项目的可能迁移,该项目目前正在使用Visual Studio 2012(更新4)构建,以在Docker容器中运行。我已经在Windows Server 2019中安装了Docker,它在我的机器上的HyperV VM中运行。我是为安装VS构建工具而来的 # escape=` # Copyright (C) Microsoft Corporation. All rights reserved. # Licensed under the MIT license

我是Docker的新手,我正在准备我的项目的可能迁移,该项目目前正在使用Visual Studio 2012(更新4)构建,以在Docker容器中运行。我已经在Windows Server 2019中安装了Docker,它在我的机器上的HyperV VM中运行。我是为安装VS构建工具而来的

# escape=`

# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.

ARG FROM_IMAGE=microsoft/dotnet-framework:3.5-sdk-windowsservercore-1709
FROM ${FROM_IMAGE}

# Reset the shell.
SHELL ["cmd", "/S", "/C"]

# Set up environment to collect install errors.
COPY Install.cmd C:\TEMP\
ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe

# Install Node.js LTS
ADD https://nodejs.org/dist/v8.11.3/node-v8.11.3-x64.msi C:\TEMP\node-install.msi
RUN start /wait msiexec.exe /i C:\TEMP\node-install.msi /l*vx "%TEMP%\MSI-node-install.log" /qn ADDLOCAL=ALL

# Download channel for fixed install.
ARG CHANNEL_URL=https://aka.ms/vs/15/release/channel
ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman

# Download and install Build Tools for Visual Studio 2017 for native desktop workload.
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
    --channelUri C:\TEMP\VisualStudio.chman `
    --installChannelUri C:\TEMP\VisualStudio.chman `
    --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
    --installPath C:\BuildTools

# Use developer command prompt and start PowerShell if no other command specified.
ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat &&
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
最初,我收到一个错误,说我的操作系统版本不匹配
容器操作系统与主机操作系统不匹配
,因此我更改了以下行:

ARG FROM_IMAGE=microsoft/dotnet framework:3.5-sdk-windowsservercore-1709

下表:

ARG FROM_IMAGE=mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

然后,构建工具似乎能够安装。现在我想修改docker文件以创建VS2012的构建工具。所以我在下面一行做了修改:

# Download channel for fixed install.
ARG CHANNEL_URL=https://aka.ms/vs/15/release/channel
ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman

# Download and install Build Tools for Visual Studio 2017 for native desktop workload.
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
    --channelUri C:\TEMP\VisualStudio.chman `
    --installChannelUri C:\TEMP\VisualStudio.chman `
    --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
    --installPath C:\BuildTools
至以下(将版本15替换为11)

在进行上述更改后,当我再次运行docker build-t BuildTools 2012 Native:latest-m 2GB.时,出现以下错误:

Step 11/13 : RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache     --channelUri C:\TEMP\VisualStudio.chman     --installChannelUri C:\TEMP\VisualStudio.chman     --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended    --installPath C:\BuildTools
 ---> Running in 0bb58dcd923f
This version of C:\TEMP\vs_buildtools.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
Microsoft (R) Visual Studio/.NET Log Collection Tool version 16.0.28407.115
Copyright (C) Microsoft Corporation. All Rights Reserved.
请帮助我了解如何解决此问题? 此外,我可以在不同的机器上构建我的应用程序(Windows服务和GUI应用程序)和相关DLL并在docker内部运行吗

Step 11/13 : RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache     --channelUri C:\TEMP\VisualStudio.chman     --installChannelUri C:\TEMP\VisualStudio.chman     --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended    --installPath C:\BuildTools
 ---> Running in 0bb58dcd923f
This version of C:\TEMP\vs_buildtools.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
Microsoft (R) Visual Studio/.NET Log Collection Tool version 16.0.28407.115
Copyright (C) Microsoft Corporation. All Rights Reserved.