working dockerfile:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
ARG AUSER
ARG APASS
SHELL ["powershell", "-Command"]
WORKDIR /scripts
COPY install_build_tools/* ./
# Extract JDK 11 if needed, but looks like already extracted by script
# Install JAVA JDK 8, 17 and 21
RUN powershell -ExecutionPolicy Bypass -File install_jdk_11.ps1 $AUSER $env:AUSER $APASS $env:APASS
RUN powershell -NoProfile -ExecutionPolicy Bypass -Command ".\install_jdk_8.ps1 $env:AUSER $env:APASS; Expand-Archive -LiteralPath 'C:\Program Files\Java\openlogic-openjdk-8u292-b10-windows-x64.zip' -DestinationPath 'C:\Program Files\Java\jdk-8'"
RUN powershell -NoProfile -ExecutionPolicy Bypass -Command ".\install_jdk_17.ps1 $env:AUSER $env:APASS; Expand-Archive -LiteralPath 'C:\Program Files\Java\OpenJDK17U-jdk_x64_windows_hotspot_17.0.2_8.zip' -DestinationPath 'C:\Program Files\Java\jdk-17'"
RUN powershell -NoProfile -ExecutionPolicy Bypass -Command ".\install_jdk_21.ps1 $env:AUSER $env:APASS; Expand-Archive -LiteralPath 'C:\Program Files\Java\openjdk-21.0.2_windows-x64_bin.zip' -DestinationPath 'C:\Program Files\Java\jdk-21'"
# Install Maven
RUN powershell -ExecutionPolicy Bypass -File install_maven.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install Gradle
RUN powershell -ExecutionPolicy Bypass -File install_gradle.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install Nuget
RUN powershell -ExecutionPolicy Bypass -File install_nuget.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install TOSCA
RUN powershell -ExecutionPolicy Bypass -File install_tosca.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install Liquibase
RUN powershell -ExecutionPolicy Bypass -File install_liquibase.ps1 -AUSER $env:AUSER -APASS $env:APASS
# Install PowerBuilder
RUN powershell -ExecutionPolicy Bypass -File install_power_builder.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install Azure CLI
RUN powershell -ExecutionPolicy Bypass -File install_azure_cli.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install PowerShell Version 7
RUN powershell -ExecutionPolicy Bypass -File install_powershell_7.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install Azure PowerShell
RUN powershell -ExecutionPolicy Bypass -File install_azure_powershell.ps1 $AUSER $env:AUSER $APASS $env:APASS
RUN powershell -Command Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile "chrome_installer.exe"; `cmd.exe /c start /wait chrome_installer.exe /silent /install; `Remove-Item -Force "chrome_installer.exe"
RUN curl.exe --version
# Set up build tools config files
COPY ./build_tools_config_files/maven/settings.xml C:/Users/ContainerAdministrator/.m2/
COPY ./build_tools_config_files/gradle/gradle.properties C:/Users/ContainerAdministrator/.gradle/
COPY ./build_tools_config_files/nuget/NuGet.Config C:/Users/ContainerAdministrator/AppData/Roaming/NuGet/
COPY ./build_tools_config_files/npm/.npmrc C:/Users/ContainerAdministrator/
# Copy install script to collect logs when an install error occurs
COPY install.cmd ./
# Download collect.exe in case of an install failure
ADD https://aka.ms/vscollect.exe ./collect.exe
COPY install_vs_2022.ps1 ./
# Install Visual Studio Build Tools
RUN powershell -ExecutionPolicy Bypass -File install_vs_2022.ps1 $AUSER $env:AUSER $APASS $env:APASS
# Install Python
RUN powershell -ExecutionPolicy Bypass -File install_python.ps1 $AUSER $env:AUSER $APASS $env:APASS
WORKDIR /azp
COPY ./start.ps1 ./
CMD ./start.ps1
Please see above dockerfile, it is building the image fine, but when i add below highlighted step which nuget env path , I am seeing follwoing error:
error:
---> 5d5658cb8cea
Step 14/35 : ENV PATH="C:\\Nuget;%PATH%"
---> Running in 27c13acd3480
---> Removed intermediate container 27c13acd3480
---> 82a8f8f404c8
Step 15/35 : RUN powershell -Command "Get-ChildItem -Path C:\scripts"
---> Running in c510c90308af
container c510c90308afbca8be42f5501e1044300909dd1f4223f9a2c80ca86149fa4648 encountered an error during hcs::System::CreateProcess: powershell -Command powershell -Command "Get-ChildItem -Path C:\scripts": failure in a Windows system call: The system cannot find the file specified. (0x2)
##[debug]$LASTEXITCODE: 1
##[debug]Exit code: 1
##[debug]Leaving Invoke-VstsTool.
why it is happening after adding that env path command, please suggest fix
FYI:
Steps Taken but no luck
- Verified that all necessary files and folders exist in the build context on the Azure DevOps agent.
- Reviewed and tested different Dockerfile
COPY
commands, using both relative and absolute Windows paths. - Added diagnostic Dockerfile steps to check for the existence and contents of the target directory inside the container image.
- Rebuilt the Docker image using the
--no-cache
option to rule out caching issues. - Checked for environmental issues by comparing results on the CI/CD agent and a local build (if possible).
- Investigated known Docker and Windows container issues related to file copying.