Browse Source

Improve Appveyor Error handling/output

Stefan Profanter 6 years ago
parent
commit
fb61d2a5be
2 changed files with 219 additions and 197 deletions
  1. 158 147
      tools/appveyor/build.ps1
  2. 61 50
      tools/appveyor/install.ps1

+ 158 - 147
tools/appveyor/build.ps1

@@ -1,158 +1,169 @@
 $ErrorActionPreference = "Stop"
 $ErrorActionPreference = "Stop"
 
 
-cd $env:APPVEYOR_BUILD_FOLDER
+try {
+    cd $env:APPVEYOR_BUILD_FOLDER
 
 
-$vcpkg_toolchain = ""
-$vcpkg_triplet = ""
+    $vcpkg_toolchain = ""
+    $vcpkg_triplet = ""
 
 
-if ($env:CC_SHORTNAME -eq "vs2008" -or $env:CC_SHORTNAME -eq "vs2013") {
-	# on VS2008 mbedtls can not be built since it includes stdint.h which is not available there
-	$build_encryption = "OFF"
-	Write-Host -ForegroundColor Green "`n## Building without encryption on VS2008 or VS2013 #####`n"
-} else {
-	$build_encryption = "ON"
-}
+    if ($env:CC_SHORTNAME -eq "vs2008" -or $env:CC_SHORTNAME -eq "vs2013") {
+        # on VS2008 mbedtls can not be built since it includes stdint.h which is not available there
+        $build_encryption = "OFF"
+        Write-Host -ForegroundColor Green "`n## Building without encryption on VS2008 or VS2013 #####`n"
+    } else {
+        $build_encryption = "ON"
+    }
 
 
-if ($env:CC_SHORTNAME -eq "mingw") {
+    if ($env:CC_SHORTNAME -eq "mingw") {
 
 
-} else {
-    $vcpkg_toolchain = '-DCMAKE_TOOLCHAIN_FILE="C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake"'
-    $vcpkg_triplet = '-DVCPKG_TARGET_TRIPLET="x86-windows-static"'
-    # since https://github.com/Microsoft/vcpkg/commit/0334365f516c5f229ff4fcf038c7d0190979a38a#diff-464a170117fa96bf98b2f8d224bf503c
-    # vcpkg need to have  "C:\Tools\vcpkg\installed\x86-windows-static"
-    New-Item -Force -ItemType directory -Path "C:\Tools\vcpkg\installed\x86-windows-static"
-}
+    } else {
+        $vcpkg_toolchain = '-DCMAKE_TOOLCHAIN_FILE="C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake"'
+        $vcpkg_triplet = '-DVCPKG_TARGET_TRIPLET="x86-windows-static"'
+        # since https://github.com/Microsoft/vcpkg/commit/0334365f516c5f229ff4fcf038c7d0190979a38a#diff-464a170117fa96bf98b2f8d224bf503c
+        # vcpkg need to have  "C:\Tools\vcpkg\installed\x86-windows-static"
+        New-Item -Force -ItemType directory -Path "C:\Tools\vcpkg\installed\x86-windows-static"
+    }
 
 
 
 
-$make_cmd = "& $env:MAKE"
-
-# Collect files for .zip packing
-New-Item -ItemType directory -Path pack
-Copy-Item LICENSE pack
-Copy-Item AUTHORS pack
-Copy-Item README.md pack
-
-Write-Host -ForegroundColor Green "`n###################################################################"
-Write-Host -ForegroundColor Green "`n##### Building Documentation on $env:CC_NAME #####`n"
-New-Item -ItemType directory -Path build
-cd build
-& cmake -DMIKTEX_BINARY_PATH=c:\miktex\texmfs\install\miktex\bin -DCMAKE_BUILD_TYPE=Release `
-    -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DUA_BUILD_EXAMPLES:BOOL=OFF -G"$env:CC_NAME" ..
-& cmake --build . --target doc_latex
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Make doc_latex. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-& cmake --build . --target doc_pdf
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Make doc_pdf. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-cd ..
-Move-Item -Path "build\doc_latex\open62541.pdf" -Destination pack\
-Remove-Item -Path build -Recurse -Force
-
-Write-Host -ForegroundColor Green "`n###################################################################"
-Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME #####`n"
-New-Item -ItemType directory -Path "build"
-cd build
-& cmake  $vcpkg_toolchain $vcpkg_triplet -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX `
-    -DUA_ENABLE_ENCRYPTION:BOOL=$build_encryption -G"$env:CC_NAME" ..
-Invoke-Expression $make_cmd
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-cd ..
-Remove-Item -Path build -Recurse -Force
-
-Write-Host -ForegroundColor Green "`n###################################################################"
-Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with full NS0 #####`n"
-New-Item -ItemType directory -Path "build"
-cd build
-& cmake -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_FULL_NS0:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -G"$env:CC_NAME" ..
-Invoke-Expression $make_cmd
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-cd ..
-Remove-Item -Path build -Recurse -Force
-
-Write-Host -ForegroundColor Green "`n###################################################################"
-Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with amalgamation #####`n"
-New-Item -ItemType directory -Path "build"
-cd build
-& cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_AMALGAMATION:BOOL=ON `
- -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DBUILD_SHARED_LIBS:BOOL=OFF -G"$env:CC_NAME" ..
-Invoke-Expression $make_cmd
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-cd ..
-New-Item -ItemType directory -Path pack_tmp
-Move-Item -Path "build\open62541.c" -Destination pack_tmp\
-Move-Item -Path "build\open62541.h" -Destination pack_tmp\
-Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\server.exe" -Destination pack_tmp\
-Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\client.exe" -Destination pack_tmp\
-if ($env:CC_SHORTNAME -eq "mingw") {
-	Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.a" -Destination pack_tmp\
-} else {
-	Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.lib" -Destination pack_tmp\
-}
-& 7z a -tzip open62541-$env:CC_SHORTNAME-static.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER\pack_tmp\*"
-Remove-Item -Path pack_tmp -Recurse -Force
-Remove-Item -Path build -Recurse -Force
-
-Write-Host -ForegroundColor Green "`n###################################################################"
-Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with amalgamation and .dll #####`n"
-New-Item -ItemType directory -Path "build"
-cd build
-& cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_AMALGAMATION:BOOL=ON `
-    -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DBUILD_SHARED_LIBS:BOOL=ON -G"$env:CC_NAME" ..
-Invoke-Expression $make_cmd
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-cd ..
-New-Item -ItemType directory -Path pack_tmp
-Move-Item -Path "build\open62541.c" -Destination pack_tmp\
-Move-Item -Path "build\open62541.h" -Destination pack_tmp\
-Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\server.exe" -Destination pack_tmp\
-Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\client.exe" -Destination pack_tmp\
-if ($env:CC_SHORTNAME -eq "mingw") {
-	Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.dll" -Destination pack_tmp\
-	Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.dll.a" -Destination pack_tmp\
-} else {
-	Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.dll" -Destination pack_tmp\
-	Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.pdb" -Destination pack_tmp\
-}
-& 7z a -tzip open62541-$env:CC_SHORTNAME-dynamic.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER\pack_tmp\*"
-Remove-Item -Path pack_tmp -Recurse -Force
-Remove-Item -Path build -Recurse -Force
-
-# Only execute unit tests on vs2015 to save compilation time
-if ($env:CC_SHORTNAME -eq "vs2015") {
-	Write-Host -ForegroundColor Green "`n###################################################################"
-	Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with unit tests #####`n"
-	New-Item -ItemType directory -Path "build"
-	cd build
-	& cmake $vcpkg_toolchain $vcpkg_triplet -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=OFF -DUA_ENABLE_DISCOVERY=ON `
-	    -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_ENABLE_ENCRYPTION:BOOL=$build_encryption -DUA_BUILD_UNIT_TESTS=ON `
-	    -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON -DCHECK_PREFIX=c:\check -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -G"$env:CC_NAME" ..
-	Invoke-Expression $make_cmd
+    $make_cmd = "& $env:MAKE"
+
+    # Collect files for .zip packing
+    New-Item -ItemType directory -Path pack
+    Copy-Item LICENSE pack
+    Copy-Item AUTHORS pack
+    Copy-Item README.md pack
+
+    Write-Host -ForegroundColor Green "`n###################################################################"
+    Write-Host -ForegroundColor Green "`n##### Building Documentation on $env:CC_NAME #####`n"
+    New-Item -ItemType directory -Path build
+    cd build
+    & cmake -DMIKTEX_BINARY_PATH=c:\miktex\texmfs\install\miktex\bin -DCMAKE_BUILD_TYPE=Release `
+        -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DUA_BUILD_EXAMPLES:BOOL=OFF -G"$env:CC_NAME" ..
+    & cmake --build . --target doc_latex
     if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
     if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-    	Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
-    	exit $LASTEXITCODE
+        Write-Host -ForegroundColor Red "`n`n*** Make doc_latex. Exiting ... ***"
+        exit $LASTEXITCODE
     }
     }
-	& cmake --build . --target test-verbose --config debug
-	if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-		Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
-		exit $LASTEXITCODE
-	}
-}
+    & cmake --build . --target doc_pdf
+    if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+        Write-Host -ForegroundColor Red "`n`n*** Make doc_pdf. Exiting ... ***"
+        exit $LASTEXITCODE
+    }
+    cd ..
+    Move-Item -Path "build\doc_latex\open62541.pdf" -Destination pack\
+    Remove-Item -Path build -Recurse -Force
 
 
-# do not cache log
-Remove-Item -Path c:\miktex\texmfs\data\miktex\log -Recurse -Force
+    Write-Host -ForegroundColor Green "`n###################################################################"
+    Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME #####`n"
+    New-Item -ItemType directory -Path "build"
+    cd build
+    & cmake  $vcpkg_toolchain $vcpkg_triplet -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX `
+        -DUA_ENABLE_ENCRYPTION:BOOL=$build_encryption -G"$env:CC_NAME" ..
+    Invoke-Expression $make_cmd
+    if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+        Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
+        exit $LASTEXITCODE
+    }
+    cd ..
+    Remove-Item -Path build -Recurse -Force
+
+    Write-Host -ForegroundColor Green "`n###################################################################"
+    Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with full NS0 #####`n"
+    New-Item -ItemType directory -Path "build"
+    cd build
+    & cmake -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_FULL_NS0:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -G"$env:CC_NAME" ..
+    Invoke-Expression $make_cmd
+    if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+        Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
+        exit $LASTEXITCODE
+    }
+    cd ..
+    Remove-Item -Path build -Recurse -Force
+
+    Write-Host -ForegroundColor Green "`n###################################################################"
+    Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with amalgamation #####`n"
+    New-Item -ItemType directory -Path "build"
+    cd build
+    & cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_AMALGAMATION:BOOL=ON `
+     -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DBUILD_SHARED_LIBS:BOOL=OFF -G"$env:CC_NAME" ..
+    Invoke-Expression $make_cmd
+    if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+        Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
+        exit $LASTEXITCODE
+    }
+    cd ..
+    New-Item -ItemType directory -Path pack_tmp
+    Move-Item -Path "build\open62541.c" -Destination pack_tmp\
+    Move-Item -Path "build\open62541.h" -Destination pack_tmp\
+    Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\server.exe" -Destination pack_tmp\
+    Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\client.exe" -Destination pack_tmp\
+    if ($env:CC_SHORTNAME -eq "mingw") {
+        Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.a" -Destination pack_tmp\
+    } else {
+        Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.lib" -Destination pack_tmp\
+    }
+    & 7z a -tzip open62541-$env:CC_SHORTNAME-static.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER\pack_tmp\*"
+    Remove-Item -Path pack_tmp -Recurse -Force
+    Remove-Item -Path build -Recurse -Force
+
+    Write-Host -ForegroundColor Green "`n###################################################################"
+    Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with amalgamation and .dll #####`n"
+    New-Item -ItemType directory -Path "build"
+    cd build
+    & cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_AMALGAMATION:BOOL=ON `
+        -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DBUILD_SHARED_LIBS:BOOL=ON -G"$env:CC_NAME" ..
+    Invoke-Expression $make_cmd
+    if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+        Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
+        exit $LASTEXITCODE
+    }
+    cd ..
+    New-Item -ItemType directory -Path pack_tmp
+    Move-Item -Path "build\open62541.c" -Destination pack_tmp\
+    Move-Item -Path "build\open62541.h" -Destination pack_tmp\
+    Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\server.exe" -Destination pack_tmp\
+    Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\client.exe" -Destination pack_tmp\
+    if ($env:CC_SHORTNAME -eq "mingw") {
+        Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.dll" -Destination pack_tmp\
+        Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.dll.a" -Destination pack_tmp\
+    } else {
+        Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.dll" -Destination pack_tmp\
+        Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.pdb" -Destination pack_tmp\
+    }
+    & 7z a -tzip open62541-$env:CC_SHORTNAME-dynamic.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER\pack_tmp\*"
+    Remove-Item -Path pack_tmp -Recurse -Force
+    Remove-Item -Path build -Recurse -Force
+
+    # Only execute unit tests on vs2015 to save compilation time
+    if ($env:CC_SHORTNAME -eq "vs2015") {
+        Write-Host -ForegroundColor Green "`n###################################################################"
+        Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with unit tests #####`n"
+        New-Item -ItemType directory -Path "build"
+        cd build
+        & cmake $vcpkg_toolchain $vcpkg_triplet -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=OFF -DUA_ENABLE_DISCOVERY=ON `
+            -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_ENABLE_ENCRYPTION:BOOL=$build_encryption -DUA_BUILD_UNIT_TESTS=ON `
+            -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON -DCHECK_PREFIX=c:\check -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -G"$env:CC_NAME" ..
+        Invoke-Expression $make_cmd
+        if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+            Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
+            exit $LASTEXITCODE
+        }
+        & cmake --build . --target test-verbose --config debug
+        if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+            Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
+            exit $LASTEXITCODE
+        }
+    }
+
+    # do not cache log
+    Remove-Item -Path c:\miktex\texmfs\data\miktex\log -Recurse -Force
+
+} catch {
+    # Print a detailed error message
+    $FullException = ($_.Exception|format-list -force) | Out-String
+    Write-Host -ForegroundColor Red "`n------------------ Exception ------------------`n$FullException`n"
+    [Console]::Out.Flush()
+    # Wait a bit to make sure appveyor shows the error message
+    Start-Sleep 10
+    throw
+}

+ 61 - 50
tools/appveyor/install.ps1

@@ -1,52 +1,63 @@
 $ErrorActionPreference = "Stop"
 $ErrorActionPreference = "Stop"
 
 
-& git submodule --quiet update --init --recursive
-
-Write-Host -ForegroundColor Green "`n### Installing CMake and python ###`n"
-& cinst --no-progress cmake python2
-& C:\Python27\python.exe -m pip install --upgrade pip
-& C:\Python27\Scripts\pip.exe install six
-
-Write-Host -ForegroundColor Green "`n### Installing sphinx ###`n"
-& C:\Python27\Scripts\pip.exe install --user sphinx sphinx_rtd_theme
-
-Write-Host -ForegroundColor Green "`n### Installing Miktex ###`n"
-if (-not (Test-Path "c:\miktex\texmfs\install\miktex\bin\pdflatex.exe")) {
-	& appveyor DownloadFile https://ftp.uni-erlangen.de/mirrors/CTAN/systems/win32/miktex/setup/windows-x86/miktex-portable.exe
-	& 7z x miktex-portable.exe -oc:\miktex -bso0 -bsp0
-
-	# Remove some big files to reduce size to be cached
-	Remove-Item -Path c:\miktex\texmfs\install\doc -Recurse
-	Remove-Item -Path c:\miktex\texmfs\install\miktex\bin\biber.exe
-	Remove-Item -Path c:\miktex\texmfs\install\miktex\bin\a5toa4.exe
-}
-
-Write-Host -ForegroundColor Green "`n### Installing graphviz ###`n"
-& cinst --no-progress graphviz
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Installing graphviz failed. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-
-Write-Host -ForegroundColor Green "`n### Installing mbedtls ###`n"
-
-if ($env:CC_SHORTNAME -eq "mingw") {
-	& C:\msys64\usr\bin\pacman --noconfirm -S mingw-w64-x86_64-mbedtls
-} elseif ($env:CC_SHORTNAME -eq "vs2015") {
-	# we need the static version, since open62541 is built with /MT
-	# vcpkg currently only supports VS2015 and newer builds
-	& vcpkg install mbedtls:x86-windows-static
-}
-if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
-	Write-Host -ForegroundColor Red "`n`n*** Installing mbedtls failed. Exiting ... ***"
-	exit $LASTEXITCODE
-}
-
-if ($env:CC_SHORTNAME -eq "vs2015") {
-	Write-Host -ForegroundColor Green "`n### Installing libcheck ###`n"
-	& appveyor DownloadFile https://github.com/Pro/check/releases/download/0.12.0_win/check.zip
-	& 7z x check.zip -oc:\ -bso0 -bsp0
-
-	Write-Host -ForegroundColor Green "`n### Installing DrMemory ###`n"
-	& cinst --no-progress drmemory.portable
-}
+try {
+    & git submodule --quiet update --init --recursive
+
+    Write-Host -ForegroundColor Green "`n### Installing CMake and python ###`n"
+    & cinst --no-progress cmake python2
+    & C:\Python27\python.exe -m pip install --upgrade pip
+    & C:\Python27\Scripts\pip.exe install six
+
+    Write-Host -ForegroundColor Green "`n### Installing sphinx ###`n"
+    & C:\Python27\Scripts\pip.exe install --user sphinx sphinx_rtd_theme
+
+    Write-Host -ForegroundColor Green "`n### Installing Miktex ###`n"
+    if (-not (Test-Path "c:\miktex\texmfs\install\miktex\bin\pdflatex.exe")) {
+        & appveyor DownloadFile https://ftp.uni-erlangen.de/mirrors/CTAN/systems/win32/miktex/setup/windows-x86/miktex-portable.exe
+        & 7z x miktex-portable.exe -oc:\miktex -bso0 -bsp0
+
+        # Remove some big files to reduce size to be cached
+        Remove-Item -Path c:\miktex\texmfs\install\doc -Recurse
+        Remove-Item -Path c:\miktex\texmfs\install\miktex\bin\biber.exe
+        Remove-Item -Path c:\miktex\texmfs\install\miktex\bin\a5toa4.exe
+    }
+
+    Write-Host -ForegroundColor Green "`n### Installing graphviz ###`n"
+    & cinst --no-progress graphviz
+    if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+        Write-Host -ForegroundColor Red "`n`n*** Installing graphviz failed. Exiting ... ***"
+        exit $LASTEXITCODE
+    }
+
+    Write-Host -ForegroundColor Green "`n### Installing mbedtls ###`n"
+
+    if ($env:CC_SHORTNAME -eq "mingw") {
+        & C:\msys64\usr\bin\pacman --noconfirm -S mingw-w64-x86_64-mbedtls
+    } elseif ($env:CC_SHORTNAME -eq "vs2015") {
+        # we need the static version, since open62541 is built with /MT
+        # vcpkg currently only supports VS2015 and newer builds
+        & vcpkg install mbedtls:x86-windows-static
+    }
+    if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
+        Write-Host -ForegroundColor Red "`n`n*** Installing mbedtls failed. Exiting ... ***"
+        exit $LASTEXITCODE
+    }
+
+    if ($env:CC_SHORTNAME -eq "vs2015") {
+        Write-Host -ForegroundColor Green "`n### Installing libcheck ###`n"
+        & appveyor DownloadFile https://github.com/Pro/check/releases/download/0.12.0_win/check.zip
+        & 7z x check.zip -oc:\ -bso0 -bsp0
+
+        Write-Host -ForegroundColor Green "`n### Installing DrMemory ###`n"
+        & cinst --no-progress drmemory.portable
+    }
+
+} catch {
+    # Print a detailed error message
+    $FullException = ($_.Exception|format-list -force) | Out-String
+    Write-Host -ForegroundColor Red "`n------------------ Exception ------------------`n$FullException`n"
+    [Console]::Out.Flush()
+    # Wait a bit to make sure appveyor shows the error message
+    Start-Sleep 10
+    throw
+}