Home > OS >  Server Core Docker image with "VSTEST" and "VISUALSTUDIO" capabilities for a hos
Server Core Docker image with "VSTEST" and "VISUALSTUDIO" capabilities for a hos

Time:10-27

I'm trying to move our self-hosted DevOps agent hosts from being stand-alone VMs to being docker containers, and I'm having some issues satisfying the requirements some of our pipelines have.

Specifically, vstest and visualstudio seem to be most troublesome, since I reckon I should be using a Server Core image as the base.

I was hoping these requirements would be satisfied by following this MS guide on installing build tools in a container, but alas pipelines will still not work.

Here's my current 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

The start.ps1 is taken from this MS document.

Do I absolutely need to install the full Visual Studio suite to be able to satisfy the vstest and visualstudio pipeline requirements? If not, what kind of package do I need? If yes, is it even possible to install the whole VS suite inside a docker container?

CodePudding user response:

I've ended up using the mcr.microsoft.com/dotnet/framework/sdk:4.8.1 image as the base for the agent. It contains the vstest tool (however the path needs to be manually specified using ENV). This satisfies the vstest demand and I think I'll push to have the visualstudio demand dropped, as it's likely NOT needed in our cases and our pipeline admins have simply been adding it in error.

  • Related