nunix/winrust

By nunix

Updated 9 months ago

Rust and VC++ on Windows Server Core Insider and LTSC2022.

Image
Operating Systems
Developer Tools
0

41

This image has been created as a proof-of-concept for building the sudo command on Windows Server and Windows 11 in a non-intrusive way. The size is quite big due to Visual Studio C++ build environment, so once built remember to delete the image if there's no other use.

Environment

The environment used to build and test the image is as follows:

Build and Install

The directories used are an example, feel free to change them to match your own environment:

# [Optional]
mkdir $HOME\Github
cd $HOME\Github

# Clone the sudo repo
git clone https://github.com/microsoft/sudo
cd sudo

# Build and install
## Windows Server 2025
docker run --rm -v ${PWD}:C:\build -v ${HOME}:C:\hosthome nunix/winrust cargo install --path C:\build\sudo --root C:\hosthome

## Windows 11
docker run --rm -v ${PWD}:C:\build -v ${HOME}:C:\hosthome nunix/winrust:ltsc2022 cargo install --path C:\build\sudo --root C:\hosthome

Dockerfile

# escape=`

FROM mcr.microsoft.com/windows/servercore/insider:10.0.26212.5000

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

# Download the Build Tools bootstrapper.
RUN 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.
RUN start /w vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath "C:\BuildTools" `
--add Microsoft.Component.MSBuild `
--add Microsoft.VisualStudio.Component.Windows11SDK.22000 `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0 `
`
# Cleanup
&& del /q vs_buildtools.exe

# Install RUST
RUN curl -SL --output rustup-init.exe https://win.rustup.rs/x86_64
RUN start /w rustup-init.exe -y -v && echo "Error level is %ERRORLEVEL%"
RUN del rustup-init.exe

RUN setx /M PATH "C:\Users\ContainerAdministrator\.cargo\bin;%PATH%"

# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["powershell.exe"]

Docker Pull Command

docker pull nunix/winrust