.net 无法在Docker容器中安装Visual Studio 2017工具
我正在尝试使用Visual Studio代码分析创建Docker映像,这是Visual Studio 2017构建工具的一部分。以下Dockerfile工作正常,工具安装在.net 无法在Docker容器中安装Visual Studio 2017工具,.net,visual-studio,docker,msbuild,.net,Visual Studio,Docker,Msbuild,我正在尝试使用Visual Studio代码分析创建Docker映像,这是Visual Studio 2017构建工具的一部分。以下Dockerfile工作正常,工具安装在C:\Program Files(x86)\Microsoft Visual Studio\2017\BuildTools\Team tools\Static Analysis tools: # escape=` FROM microsoft/dotnet-framework:4.7.1 # Restore the def
C:\Program Files(x86)\Microsoft Visual Studio\2017\BuildTools\Team tools\Static Analysis tools
:
# escape=`
FROM microsoft/dotnet-framework:4.7.1
# Restore the default Windows shell for correct batch processing below.
SHELL ["cmd", "/S", "/C"]
# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
# Install VS Build Tools
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--add Microsoft.VisualStudio.Component.Static.Analysis.Tools `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
ENTRYPOINT powershell
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
到目前为止,一切顺利。但是,我实际上需要将映像建立在microsoft/dotnet framework:4.7.2-sdk-windowsservercore-ltsc2016的基础上,因为这最终将成为TeamCity build agent映像的一部分,而这正是基于的映像。因此,我将我的行更改为:
FROM microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2016
当我建立这个,图像建立,我去没有错误。它似乎正在工作,并且需要大约相同的时间。但是,缺少目录C:\ProgramFiles(x86)\Microsoft Visual Studio\2017\BuildTools\Team Tools\
。可能是4.7.2有问题,所以我尝试了microsoft/dotnet framework:4.7.1-sdk-windowsservercore-ltsc2016
。同样的错误。我还尝试了microsoft/dotnet framework:4.7.2-sdk-windowsservercore-1803
,但也没有成功。我也尝试过使用Chocolate安装VS构建工具,但它的行为完全相同
这个microsoft/dotnet framework:4.7.1
image是VS Build Tools唯一安装的镜像,它到底有什么特别之处?我找不到它的Dockerfile,所以我无法真正说出它基于什么(他们只是说“Windows Server Core”,这没有什么帮助),或者这个映像是否安装或执行任何特殊操作
是否有人让VS Build Tools在基于microsoft/dotnet framework:4.7.1以外的任何内容的容器中工作?我找到了一个似乎可行的解决方案。在Microsoft修复导致VS Build Tools安装程序无法在某些Windows映像上运行的任何错误之前,这更像是一种解决方法 您可以创建多级生成,然后复制
团队工具
文件夹和必要的目标
文件。如果您安装了静态代码分析之外的其他东西,那么您可能还需要找到需要复制的目标文件
例如:
# escape=`
FROM microsoft/dotnet-framework:4.7.1 as vsbuild
# Restore the default Windows shell for correct batch processing below.
SHELL ["cmd", "/S", "/C"]
# Download the Build Tools bootstrapper
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
# Install Static Analysis Tools
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--add Microsoft.VisualStudio.Component.Static.Analysis.Tools `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
FROM jetbrains/teamcity-agent:2018.1.2-windowsservercore-ltsc2016
COPY --from=vsbuild ["C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Team Tools", "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Team Tools"]
COPY --from=vsbuild ["C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/Microsoft/VisualStudio/v15.0/CodeAnalysis", "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/Microsoft/VisualStudio/v15.0/CodeAnalysis"]
Visual Studio 2017 15.9版需要Windows Server 2019或Windows 10“RS5”。请参阅。,这可能适用于某些工作负载,但许多工作负载在安装根目录之外安装文件,或者进行其他计算机配置更改,如注册表更改,您无法简单地复制这些更改。这个bug在RS5发布之前就已经被识别和修复,但是考虑到我们的服务生命周期,我们没有计划修复旧版本。RS5及更新版本需要15.9(包含修复程序)。