【问题标题】:Server Core Docker image with "VSTEST" and "VISUALSTUDIO" capabilities for a hosted DevOps Agent用于托管 DevOps 代理的具有 \"VSTEST\" 和 \"VISUALSTUDIO\" 功能的服务器核心 Docker 映像
【发布时间】:2022-11-10 23:25:47
【问题描述】:

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

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

我希望通过关注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 套件才能满足 vstestvisualstudio 管道要求?如果没有,我需要什么样的包裹?如果是,是否可以将整个 VS 套件安装在 docker 容器中?

【问题讨论】:

  • 考虑重构您的管道以不使用需要这些功能的内置任务,而是运行等效的 CLI 命令。
  • @DanielMann 不幸的是,在不同的项目中有很多来自不同人的管道,所以这不是一个真正的选择。 :(

标签: docker visual-studio azure-devops-self-hosted-agent build-agent


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2015-10-28
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多