【发布时间】:2022-11-10 23:25:47
【问题描述】:
我正在尝试将我们的自托管 DevOps 代理主机从独立的虚拟机转移到 docker 容器,但我遇到了一些问题,以满足我们的一些管道的要求。
具体来说,vstest 和visualstudio 似乎是最麻烦的,因为我认为我应该使用服务器核心映像作为基础。
我希望通过关注this MS guide on installing build tools in a container 可以满足这些要求,但是唉,管道仍然无法正常工作。
这是我目前的DockerFile:
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022
RUN powershell add-windowsfeature web-asp-net45
RUN powershell "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"
RUN choco install dotnet4.7 -y
RUN choco install dotnet-sdk -y
RUN `
# Download the Build Tools bootstrapper.
curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe `
`
# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache --includeRecommended `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
--add Microsoft.VisualStudio.Workload.AzureBuildTools `
--add Microsoft.VisualStudio.Workload.DataBuildTools `
--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools `
--add Microsoft.VisualStudio.Workload.MSBuildTools `
--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) `
`
# Cleanup
&& del /q vs_buildtools.exe
RUN choco install nodejs -y
RUN choco install azure-cli -y
RUN choco install openjdk -y
WORKDIR /azp
COPY start.ps1 .
CMD powershell .\start.ps1
start.ps1 取自 this MS document。
我是否绝对需要安装完整的 Visual Studio 套件才能满足 vstest 和 visualstudio 管道要求?如果没有,我需要什么样的包裹?如果是,是否可以将整个 VS 套件安装在 docker 容器中?
【问题讨论】:
-
考虑重构您的管道以不使用需要这些功能的内置任务,而是运行等效的 CLI 命令。
-
@DanielMann 不幸的是,在不同的项目中有很多来自不同人的管道,所以这不是一个真正的选择。 :(
标签: docker visual-studio azure-devops-self-hosted-agent build-agent