Skip to content

Commit

Permalink
4
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitjano committed Apr 27, 2024
1 parent 76ae114 commit 0a9ebec
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2022
# escape=`

# Reset the shell.
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Use the latest Windows Server Core 2022 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022

# Download and install Build Tools for Visual Studio 2022 for native desktop
RUN wget https://aka.ms/vs/17/release/vs_buildtools.exe -OutFile "$Env:TEMP\vs_buildtools.exe"; \
wget https://aka.ms/vs/17/release/VisualStudio.chman -OutFile "$Env:TEMP\VisualStudio.chman"; \
Start-Process -FilePath $env:TEMP\vs_buildtools.exe -ArgumentList \
"--quiet", \
"--norestart", \
"--nocache", \
# "--installPath", \
# "c:\ProgramFiles (x86)\Microsoft Visual Studio\2022\BuildTools", \
"--wait", \
"--channelUri", \
"$Env:TEMP\VisualStudio.chman", \
"--installChannelUri", \
"$Env:TEMP\VisualStudio.chman", \
"--add", \
"Microsoft.VisualStudio.Workload.VCTools", \
"Microsoft.Net.Component.4.8.SDK", \
"Microsoft.VisualStudio.Component.VC.ATLMFC", \
"--includeRecommended" \
-Wait -PassThru; \
del $Env:TEMP\vs_buildtools.exe;
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

# install git and cmake from choco
RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y --no-progress; \
choco install git -y --no-progress
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 `
--installPath "%ProgramFiles%\Microsoft Visual Studio\2022\BuildTools" `
--add Microsoft.VisualStudio.Workload.VCTools `
--includeRecommended `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
`
# Cleanup
&& del /q vs_buildtools.exe

RUN git clone https://github.com/microsoft/vcpkg.git c:\vcpkg; \
c:\vcpkg\bootstrap-vcpkg.bat -disableMetrics
RUN `
curl -SL --output git.zip https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-64-bit.zip `
&& mkdir "%ProgramFiles%\Git" `
&& powershell -command "Expand-Archive -Path C:\git.zip -DestinationPath '%ProgramFiles%\git'" `
&& powershell -command "(Get-Content 'C:/Program Files/Git/etc/gitconfig') -replace 'path = C:/Program Files/Git/etc/gitconfig', '' | Set-Content 'C:/Program Files/Git/etc/gitconfig'" `
&& del /q git.zip `
&& SETX /M PATH "%ProgramFiles%\Git\cmd;%ProgramFiles%\Git\mingw64\bin;%ProgramFiles%\Git\usr\bin;%PATH%

RUN c:\vcpkg\vcpkg install eigen3 --clean-after-build
RUN `
git clone https://github.com/microsoft/vcpkg.git C:\vcpkg `
&& cd vcpkg `
&& bootstrap-vcpkg.bat `
&& SETX /M PATH "C:\vcpkg;%PATH%" `
&& vcpkg install zlib:x64-windows --clean-after-build `
&& vcpkg remove zlib:x64-windows

ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
# 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\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

0 comments on commit 0a9ebec

Please sign in to comment.