Skip to content

Instantly share code, notes, and snippets.

@cfriedt
Last active May 30, 2020 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfriedt/e90632b0732998c166e215a3e3d0b3d3 to your computer and use it in GitHub Desktop.
Save cfriedt/e90632b0732998c166e215a3e3d0b3d3 to your computer and use it in GitHub Desktop.
What Would Travis Do (On Windows)

What Would Travis Do (on Windows)

A Travis-CI Compatible Environment for Windows on Google Cloud

This gist should help users set a Google Cloud Virtual Machine (VM) environment similar environment to that provided by the Travis CI for Windows.

Initially, the regular traditional Windows Command Prompt is used for executing commands, and then git-bash is used for subsequent commands, much like the Travis environment.

Create a new VM Instance

First, we have to set up a virtual machine (VM) from the Google Cloud Console.

  1. Navigate to the Menu (☰), Compute Engine, and VM Instances
  2. Hit Create Instance
  3. Under Boot disk, select Change, then Operating System: Windows Server, and Version: Windows Server version 1809 Datacenter Core for Containers, and hit Select
  4. Press Create
  5. When the VM is ready, click on the instance name "e.g. instance-1", and then Set Windows Password.
  6. Change the username to 'travis', and press Set.
  7. Copy the password, and choose Close
  8. Hit the RDP button (requires Chrome RDP for Google Cloud Platform)
  9. Enter username: travis, paste the password into the password field, and log in to Windows.

Install the Chocolatey Package Manager

Install Chocolatey as described here.

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Install Chocolatey Packages

Note: This part could take an extraordinarily long amount of time.

Here, we create a simple batch script that installs Chocolatey packages in a separate file.

First, create the script using notepad set-up-travis.bat and copy the following into it.

for /F "tokens=*" %%A in (chocopkgs.txt) do choco install -y %%A

Next, run notepad chocopkgs.txt and copy the following into it. These packages were originally listed here.

7zip.install
chocolatey
chocolatey-core.extension
chocolatey-dotnetfx.extension
chocolatey-fastanswers.extension
chocolatey-visualstudio.extension
chocolatey-windowsupdate.extension
cmake.install
curl
DotNet4.5.2
DotNet4.6
DotNet4.6-TargetPack
DotNet4.6.1
dotnetfx
git.install
hashdeep
jq
KB2919355
KB2919442
KB2999226
KB3033929
KB3035131
llvm
microsoft-build-tools
mingw
netfx-4.5.1-devpack
netfx-4.5.2-devpack
netfx-4.6.1-devpack
rsync
ruby
vcredist140
vcredist2017
visualstudio-installer
visualstudio2017-workload-netcorebuildtools
visualstudio2017-workload-vctools
visualstudio2017-workload-webbuildtools
visualstudio2017buildtools
Wget
windows-sdk-10.1
winscp
winscp.install

We omit wsl for brevity.

Enter the BASH Environment

Run the following (with quotes included) to start bash.

"C:\Program Files\Git\bin\bash"

Then export your PATH to match the travis environment.

export PATH="/bin:/usr/bin:/c/tools/ruby27/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/Google/Compute Engine/sysprep:/c/Program Files/Docker:/c/ProgramData/chocolatey/bin:/c/Program Files/CMake/bin:/c/Program Files/Git/cmd:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/tools/BCURRAN3:/c/Users/travis/AppData/Local/Microsoft/WindowsApps:/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin"

Optional

It's also suggested to update the PATH in order to support building with cmake and msbuild.exe.

export PATH="${PATH}:/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin"

Conclusion

At this point (aside from python2.7 and wsl), the environment should approximately match what Travis offers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment