是否可以在Windows容器中安装Visual Studio

问题描述 投票:50回答:5

是否可以在Windows Server上的Windows Container中安装任何版本的Visual Studio?

其动机是使用Windows Containers在持续集成系统中构建软件,以便构建环境标准化。

visual-studio docker continuous-integration containers windows-server
5个回答
18
投票

Visual Studio在Core Server上似乎是to not be supported officially,但我同意能够做到这一点真的很棒。我们试试吧:

FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell"]

RUN Invoke-WebRequest "https://aka.ms/vs/15/release/vs_community.exe" -OutFile "$env:TEMP\vs_community.exe" -UseBasicParsing
RUN & "$env:TEMP\vs_community.exe" --add Microsoft.VisualStudio.Workload.NetWeb --quiet --wait --norestart --noUpdateInstaller | Out-Default

RUN & 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe' /version

CMD ["powershell"]

(我将这张图片推入lukaslansky/visualstudio-netwebworkload,谨慎使用。)

构建的输出是:

[...]
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

所以这似乎有效!您应该使用那些--add安装程序参数来指定您为构建准确需要的组件,它们对应于您在GUI中看到的工作负载和组件。 See the documentation.


2
投票

Windows容器当前不包含GUI应用程序。限制是在Microsoft上,而不是在Docker上。

例如,尝试一些简单的操作,例如运行记事本(在Windows Server Core容器中)。该过程已启动,但未显示任何GUI。

Notepad launched, but no GUI shows up


1
投票

只是为了记录MS不计划支持VS内容器,你有最好的选择是MsBuild。几个月前是可能的,但VS的最新版本是不可能的。资料来源:vsts-agents


1
投票

在windows容器中安装可视构建链的方法可能是使用巧克力包visualstudio2017buildtools

使用以下内容启动Dockerfile:

FROM microsoft/windowsservercore
RUN powershell.exe -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SETX PATH "%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" 
RUN choco install -y  visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --installPath C:\BuildTools" || IF "%ERRORLEVEL%"=="3010" EXIT 0      
RUN call "C:\BuildTools\VC\Auxiliary\Build\vcvars64.bat"

0
投票

在这一点上你最好的选择是使用Visual Studio Build Tools

© www.soinside.com 2019 - 2024. All rights reserved.