Search code examples
windowstravis-ci

How to simulate a Travis CI windows build locally?


I am trying to troubleshoot a Travis windows build locally, because it's just not efficient to always wait to the CI to try a new approach.

There are windows 10 trial VMs available, but how can I reconstruct the Travis build environment?

Basically it seems a standard windows server on travis with lots of packages installed via Choloatey https://docs.travis-ci.com/user/reference/windows/#support

But isn't there a script which installs all this or does that have to be done manually?


Solution

    • Open a Administrative cmd powershell

    • Follow https://docs.chocolatey.org/en-us/choco/setup

    • call

      choco install -y 7zip.install --version 19.0
      choco install -y chocolatey --version 0.10.15
      choco install -y chocolatey-core.extension --version 1.3.5.1       
      choco install -y chocolatey-dotnetfx.extension --version 1.0.1 
      choco install -y chocolatey-fastanswers.extension --version 0.0.2 
      choco install -y chocolatey-visualstudio.extension --version 1.8.1 
      choco install -y chocolatey-windowsupdate.extension --version 1.0.4 
      choco install -y cmake.install --version 3.16.2 
      choco install -y curl --version 7.68.0 
      choco install -y DotNet4.5.2 --version 4.5.2.20140902 
      choco install -y DotNet4.6 --version 4.6.00081.20150925 
      choco install -y DotNet4.6-TargetPack --version 4.6.00081.20150925 
      choco install -y DotNet4.6.1 --version 4.6.01055.20170308 
      choco install -y dotnetfx --version 4.8.0.20190930 
      choco install -y git.install --version 2.25.0
      choco install -y hashdeep --version 4.4 
      choco install -y jq --version 1.6
      choco install -y KB2919355 --version 1.0.20160915
      choco install -y KB2919442 --version 1.0.20160915 
      choco install -y KB2999226 --version 1.0.20181019 
      choco install -y KB3033929 --version 1.0.5 
      choco install -y KB3035131 --version 1.0.3 
      choco install -y llvm --version 9.0.0  
      choco install -y microsoft-build-tools --version 15.0.26320.2 
      choco install -y mingw --version 8.1.0 
      choco install -y netfx-4.5.1-devpack --version 4.5.50932 
      choco install -y netfx-4.5.2-devpack --version 4.5.5165101.20180721 
      choco install -y netfx-4.6.1-devpack --version 4.6.01055.00 
      choco install -y rsync --version 5.5.0.20190204 
      choco install -y ruby --version 2.7.0.1 
      choco install -y vcredist140 --version 14.24.28127.4 
      choco install -y vcredist2017 --version 14.16.27033
      choco install -y visualstudio-installer --version 2.0.1 
      choco install -y visualstudio2017-workload-netcorebuildtools --version 1.1.2
      choco install -y visualstudio2017-workload-vctools --version 1.3.2
      choco install -y visualstudio2017-workload-webbuildtools --version 1.3.2
      choco install -y visualstudio2017buildtools --version 15.9.18.0
      choco install -y Wget --version 1.20.3.20190531
      choco install -y windows-sdk-10.1 --version 10.1.18362.1 
      choco install -y winscp --version 5.15.9  
      choco install -y winscp.install --version 5.15.9 
      choco install -y wsl --version 1.0.1
      
    • Right click on any folder, execute git bash, clone your projects, and execute the build steps

    Env variables

    Instead of "env:" in your travis script, execute export VARIABLE=value

    Run git bash as admin

    For travis scripts that install global sofware, you might want to run git bash as admin.

    • Open start menu
    • Search for git bash
    • Right click -> run as administrator

    Example run

    powershell -Command Set-MpPreference -DisableArchiveScanning \$true
    powershell -Command Set-MpPreference -DisableRealtimeMonitoring \$true
    powershell -Command Set-MpPreference -DisableBehaviorMonitoring \$true
    
    
    git clone  https://github.com/example/repo.git example/repo