具有托管 DevOps 代理的"VSTEST"和"VISUALSTUDIO"功能的服务器核心 Docker 映像



我正试图将我们的自托管DevOps代理主机从独立的VM转移到docker容器,但在满足我们的一些管道的要求方面遇到了一些问题。

具体来说,vstestvisualstudio似乎是最麻烦的,因为我认为我应该使用服务器核心映像作为基础。

我希望通过遵循MS关于在容器中安装构建工具的指南来满足这些要求,但遗憾的是,管道仍然无法工作。

这是我当前的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 Studio2022BuildTools" `
--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取自本MS文档。

我是否绝对需要安装完整的Visual Studio套件才能满足vstestvisualstudio管道要求?如果没有,我需要什么样的包裹?如果是,是否可以将整个VS套件安装在docker容器中?

我最终使用了mcr.microsoft.com/dotnet/framework/sdk:4.8.1映像作为代理的基础。它包含vstest工具(但是需要使用ENV手动指定路径(。这满足了vstest的需求,我想我会推动取消visualstudio的需求,因为在我们的情况下可能不需要它,而且我们的管道管理员只是错误地添加了它。

最新更新