skip to Main Content

Facing issue while installing windows server 2022 and visual studio 2022 in container

I am using the below Dokerfile

# escape=`

# Use the latest Windows Server Core 2019 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

RUN `
    # Download the Build Tools bootstrapper.
    curl -SL --output vs_enterprise.exe https://aka.ms/vs/17/release/vs_enterprise.exe `
    `
    # Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
    && (start /w vs_enterprise.exe --quiet --wait --norestart --nocache `
        --installPath "%ProgramFiles(x86)%Microsoft Visual Studio2022Enterprise" `
        --add Microsoft.VisualStudio.Workload.AzureBuildTools `
        --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_enterprise.exe

# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

After installation, I am getting the below error when I am trying to test webtest

MSTest: The term 'MSTest' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ MSTest
+ ~~~~~~
   + CategoryInfo          : ObjectNotFound: (MSTest:String) [], >CommandNotFoundException
   + FullyQualifiedErrorId : CommandNotFoundException

2

Answers


  1. Microsoft currently has an issue with the Visual Studio installer backend. You are probably affected by that. See here

    Summary: VS Setup is currently down

    Login or Signup to reply.
  2. Try running it like this:

    FROM mcr.microsoft.com/windows/servercore:ltsc2019
    
    # Restore the default Windows shell for correct batch processing.
    SHELL ["cmd", "/S", "/C"]
    
    RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe 
        && (start /w vs_buildtools.exe --quiet --wait --norestart --nocache 
            --installPath "%ProgramFiles(x86)%Microsoft Visual Studio2022BuildTools" 
            --add Microsoft.VisualStudio.Workload.AzureBuildTools 
            --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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search