diff --git a/appveyor.yml b/appveyor.yml
index 3fb469b0eb..8bd62212c4 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -7,22 +7,30 @@ cache:
environment:
ENCKEY:
secure: saYAIpqXzpq0U+JH+MNi/isRQ6Y51PZhm4BrnePDiAPptFO5htxFOLegrYqxdy67
- CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD:
+ SIGN_PASSWORD:
secure: bzYmf0ElxisSGyZnIjUOYQ==
- OPENRCT2.ORG_TOKEN:
+ OPENRCT2_ORG_TOKEN:
secure: leQX3xCQpmBLGuMqrxjFlzexDt96ypNRMM5TTRVHbGE8PwVg9crgeykLc2BIZU6HDHveJCHqh2cGMdHtHYJYcw==
+ BUILD_SERVER: AppVeyor
+ GIT_TAG: $(APPVEYOR_REPO_TAG_NAME)
+ GIT_BRANCH: $(APPVEYOR_REPO_BRANCH)
+ GIT_COMMIT_SHA1: $(APPVEYOR_REPO_COMMIT)
install:
- ps: >-
.\scripts\ps\appveyor_install.ps1
-build_script:
-- ps: >-
- .\setenv.ps1
-
- appveyor_build
+platform:
+ - Win32
+ - x64
+configuration: Release
+build:
+ project: openrct2.proj
artifacts:
-- path: .\artifacts\openrct2.zip
+- path: .\artifacts\openrct2-portable*.zip
name: OpenRCT2-portable
-- path: .\artifacts\*.exe
+- path: .\artifacts\openrct2-installer*.exe
name: OpenRCT2-installer
-- path: .\artifacts\openrct2-symbols-*.zip
+- path: .\artifacts\openrct2-symbols*.zip
name: OpenRCT2 debug symbols
+deploy_script:
+- ps: >-
+ .\scripts\ps\appveyor_deploy.ps1
diff --git a/distribution/windows/build.ps1 b/distribution/windows/build.ps1
deleted file mode 100644
index 11cecea326..0000000000
--- a/distribution/windows/build.ps1
+++ /dev/null
@@ -1,11 +0,0 @@
-param (
- [Parameter(Position = 1)]
- [string]$VersionExtra = ""
-)
-
-$path = Split-Path $Script:MyInvocation.MyCommand.Path
-Write-Host "Building Windows Installer (NSIS script)";
-Write-Host " $VersionExtra";
-makensis /DAPPV_EXTRA=$VersionExtra `
- /DVERSION_INCLUDE=$path\win32.txt `
- $path\install.nsi > $path\win32.log;
diff --git a/distribution/windows/install.nsi b/distribution/windows/install.nsi
index 3c91d2b454..d43d8bde2b 100644
--- a/distribution/windows/install.nsi
+++ b/distribution/windows/install.nsi
@@ -3,18 +3,35 @@
!define /ifndef APPV_MINOR 0
!define /ifndef APPV_MAINT 5
!define /ifndef APPV_BUILD 0
-!define /ifndef APPV_EXTRA "-beta"
-!define APPNAME "OpenRCT2" ; Define application name
-!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
-!define APPVERSIONINTERNAL "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}.${APPV_BUILD}" ; Define application version in X.X.X.X
-!include ${VERSION_INCLUDE}
+!define APPNAME "OpenRCT2"
+!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}"
+!define APPVERSIONINTERNAL "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}.${APPV_BUILD}"
!define /ifndef APPURLLINK "https://github.com/OpenRCT2/OpenRCT2"
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}"
+!if "${PLATFORM}" == "Win32"
+ !define OPENRCT2_EXE "openrct2.exe"
+ !define OPENRCT2_DLL "openrct2.dll"
+ !define APPBITS 32
+ !define APPARCH "win32"
+
+ InstallDir "$PROGRAMFILES32\OpenRCT2\"
+!else
+ !define OPENRCT2_EXE "openrct2_x64.exe"
+ !define OPENRCT2_SEGMENT_INFO "openrct2_data"
+ !define APPBITS 64
+ !define APPARCH "win64"
+
+ InstallDir "$PROGRAMFILES64\OpenRCT2\"
+!endif
+
+!define SUPPORTED_OS "Windows Vista, 7, 8.1 and 10"
+
; Define root variable relative to installer
!define PATH_ROOT "..\..\"
+!define BINARY_DIR "${PATH_ROOT}bin"
!define MUI_ICON "${PATH_ROOT}resources\logo\icon.ico"
!define MUI_UNICON "${PATH_ROOT}resources\logo\icon.ico"
@@ -27,7 +44,7 @@ SetCompressor LZMA
; Version Info
VIProductVersion "${APPVERSIONINTERNAL}"
-VIAddVersionKey "ProductName" "OpenRCT2 ${APPBITS}-bit Installer for Windows ${EXTRA_VERSION}"
+VIAddVersionKey "ProductName" "OpenRCT2 ${APPBITS}-bit Installer for ${SUPPORTED_OS}"
VIAddVersionKey "Comments" "Installs ${APPNAMEANDVERSION}"
VIAddVersionKey "CompanyName" "OpenRCT2 Developers"
VIAddVersionKey "FileDescription" "Installs ${APPNAMEANDVERSION}"
@@ -36,12 +53,12 @@ VIAddVersionKey "InternalName" "InstOpenRCT2-${APPARCH}"
VIAddVersionKey "FileVersion" "${APPVERSION}-${APPARCH}"
VIAddVersionKey "LegalCopyright" " "
; Main Install settings
-Name "${APPNAMEANDVERSION} ${APPBITS}-bit for Windows ${EXTRA_VERSION}"
+Name "${APPNAMEANDVERSION} ${APPBITS}-bit for ${SUPPORTED_OS}"
; NOTE: Keep trailing backslash!
InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Install Folder"
!ifndef OUTFILE
- !define OUTFILE "openrct2-install.exe"
+ !define OUTFILE "openrct2-install.exe"
!endif
OutFile "${OUTFILE}"
CRCCheck force
@@ -83,7 +100,7 @@ ManifestDPIAware true
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_RUN_TEXT "Run ${APPNAMEANDVERSION} now!"
-!define MUI_FINISHPAGE_RUN "$INSTDIR\openrct2.exe"
+!define MUI_FINISHPAGE_RUN "$INSTDIR\${OPENRCT2_EXE}"
!define MUI_FINISHPAGE_LINK "Visit the OpenRCT2 site for more information"
!define MUI_FINISHPAGE_LINK_LOCATION "${APPURLLINK}"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
@@ -118,8 +135,8 @@ Section "!OpenRCT2" Section1
; Copy the rest of the stuff
SetOutPath "$INSTDIR\"
- ; Copy curl ca file
- File ..\..\curl-ca-bundle.crt
+ ; Copy curl ca file
+ File ..\..\curl-ca-bundle.crt
; Copy text files
File ..\changelog.txt
@@ -139,12 +156,17 @@ Section "!OpenRCT2" Section1
Call unix2dos
; Copy executable
- File /oname=openrct2.exe ${BINARY_DIR}\openrct2.exe
- File /oname=openrct2.dll ${BINARY_DIR}\openrct2.dll
+ File /oname=${OPENRCT2_EXE} ${BINARY_DIR}\${OPENRCT2_EXE}
+!ifdef OPENRCT2_DLL
+ File /oname=${OPENRCT2_DLL} ${BINARY_DIR}\${OPENRCT2_DLL}
+!endif
+!ifdef OPENRCT2_SEGMENT_INFO
+ File /oname=${OPENRCT2_SEGMENT_INFO} ${BINARY_DIR}\${OPENRCT2_SEGMENT_INFO}
+!endif
; Create the Registry Entries
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Comments" "Visit ${APPURLLINK}"
- WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayIcon" "$INSTDIR\openrct2.exe,0"
+ WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayIcon" "$INSTDIR\${OPENRCT2_EXE},0"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayName" "OpenRCT2 ${APPVERSION}"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayVersion" "${APPVERSION}"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "HelpLink" "${APPURLLINK}"
@@ -157,9 +179,9 @@ Section "!OpenRCT2" Section1
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Version" "${APPVERSIONINTERNAL}"
!insertmacro MUI_STARTMENU_WRITE_BEGIN "OpenRCT2"
- CreateShortCut "$DESKTOP\OpenRCT2.lnk" "$INSTDIR\openrct2.exe"
+ CreateShortCut "$DESKTOP\OpenRCT2.lnk" "$INSTDIR\${OPENRCT2_EXE}"
CreateDirectory "$SMPROGRAMS\$SHORTCUTS"
- CreateShortCut "$SMPROGRAMS\$SHORTCUTS\OpenRCT2.lnk" "$INSTDIR\openrct2.exe"
+ CreateShortCut "$SMPROGRAMS\$SHORTCUTS\OpenRCT2.lnk" "$INSTDIR\${OPENRCT2_EXE}"
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Uninstall.lnk" "$INSTDIR\uninstall.exe"
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Readme.lnk" "$INSTDIR\Readme.txt"
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Changelog.lnk" "$INSTDIR\Changelog.txt"
@@ -201,23 +223,26 @@ Section "Uninstall"
Delete "$SMPROGRAMS\$SHORTCUTS\Contributors.lnk"
; Clean up OpenRCT2 dir
+ Delete "$INSTDIR\curl-ca-bundle.crt"
Delete "$INSTDIR\changelog.txt"
+ Delete "$INSTDIR\known_issues.txt"
+ Delete "$INSTDIR\licence.txt"
Delete "$INSTDIR\readme.txt"
Delete "$INSTDIR\contributors.md"
- Delete "$INSTDIR\openrct2.exe"
- Delete "$INSTDIR\openrct2.dll"
- Delete "$INSTDIR\licence.txt"
+ Delete "$INSTDIR\${OPENRCT2_EXE}"
+!ifdef OPENRCT2_DLL
+ Delete "$INSTDIR\${OPENRCT2_DLL}"
+!endif
+!ifdef OPENRCT2_SEGMENT_INFO
+ Delete "$INSTDIR\${OPENRCT2_SEGMENT_INFO}"
+!endif
Delete "$INSTDIR\INSTALL.LOG"
- Delete "$INSTDIR\crash.log"
- Delete "$INSTDIR\crash.dmp"
; Data files
- Delete "$INSTDIR\data\language\*.txt"
- Delete "$INSTDIR\data\title\*.*"
+ RMDir /r "$INSTDIR\data"
; Remove remaining directories
RMDir "$SMPROGRAMS\$SHORTCUTS"
- RMDir "$INSTDIR\data"
RMDir "$INSTDIR"
SectionEnd
@@ -285,13 +310,13 @@ FunctionEnd
;-------------------------------------------------------------------------------
; Check whether OpenRCT2 is running
Function CheckOpenRCT2Running
- IfFileExists "$INSTDIR\openrct2.exe" 0 Done
+ IfFileExists "$INSTDIR\${OPENRCT2_EXE}" 0 Done
Retry:
- FindProcDLL::FindProc "openrct2.exe"
+ FindProcDLL::FindProc "${OPENRCT2_EXE}"
Pop $R0
IntCmp $R0 1 0 Done
ClearErrors
- Delete "$INSTDIR\openrct2.exe"
+ Delete "$INSTDIR\${OPENRCT2_EXE}"
IfErrors 0 Done
ClearErrors
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "OpenRCT2 is running. Please close it and retry." IDRETRY Retry
@@ -363,88 +388,88 @@ FunctionEnd
; $var=1 Version1 is newer
; $var=2 Version2 is newer
Function VersionCompare
- !define VersionCompare `!insertmacro VersionCompareCall`
+ !define VersionCompare `!insertmacro VersionCompareCall`
- !macro VersionCompareCall _VER1 _VER2 _RESULT
- Push `${_VER1}`
- Push `${_VER2}`
- Call VersionCompare
- Pop ${_RESULT}
- !macroend
+ !macro VersionCompareCall _VER1 _VER2 _RESULT
+ Push `${_VER1}`
+ Push `${_VER2}`
+ Call VersionCompare
+ Pop ${_RESULT}
+ !macroend
- Exch $1
- Exch
- Exch $0
- Exch
- Push $2
- Push $3
- Push $4
- Push $5
- Push $6
- Push $7
+ Exch $1
+ Exch
+ Exch $0
+ Exch
+ Push $2
+ Push $3
+ Push $4
+ Push $5
+ Push $6
+ Push $7
- begin:
- StrCpy $2 -1
- IntOp $2 $2 + 1
- StrCpy $3 $0 1 $2
- StrCmp $3 '' +2
- StrCmp $3 '.' 0 -3
- StrCpy $4 $0 $2
- IntOp $2 $2 + 1
- StrCpy $0 $0 '' $2
+ begin:
+ StrCpy $2 -1
+ IntOp $2 $2 + 1
+ StrCpy $3 $0 1 $2
+ StrCmp $3 '' +2
+ StrCmp $3 '.' 0 -3
+ StrCpy $4 $0 $2
+ IntOp $2 $2 + 1
+ StrCpy $0 $0 '' $2
- StrCpy $2 -1
- IntOp $2 $2 + 1
- StrCpy $3 $1 1 $2
- StrCmp $3 '' +2
- StrCmp $3 '.' 0 -3
- StrCpy $5 $1 $2
- IntOp $2 $2 + 1
- StrCpy $1 $1 '' $2
+ StrCpy $2 -1
+ IntOp $2 $2 + 1
+ StrCpy $3 $1 1 $2
+ StrCmp $3 '' +2
+ StrCmp $3 '.' 0 -3
+ StrCpy $5 $1 $2
+ IntOp $2 $2 + 1
+ StrCpy $1 $1 '' $2
- StrCmp $4$5 '' equal
+ StrCmp $4$5 '' equal
- StrCpy $6 -1
- IntOp $6 $6 + 1
- StrCpy $3 $4 1 $6
- StrCmp $3 '0' -2
- StrCmp $3 '' 0 +2
- StrCpy $4 0
+ StrCpy $6 -1
+ IntOp $6 $6 + 1
+ StrCpy $3 $4 1 $6
+ StrCmp $3 '0' -2
+ StrCmp $3 '' 0 +2
+ StrCpy $4 0
- StrCpy $7 -1
- IntOp $7 $7 + 1
- StrCpy $3 $5 1 $7
- StrCmp $3 '0' -2
- StrCmp $3 '' 0 +2
- StrCpy $5 0
+ StrCpy $7 -1
+ IntOp $7 $7 + 1
+ StrCpy $3 $5 1 $7
+ StrCmp $3 '0' -2
+ StrCmp $3 '' 0 +2
+ StrCpy $5 0
- StrCmp $4 0 0 +2
- StrCmp $5 0 begin newer2
- StrCmp $5 0 newer1
- IntCmp $6 $7 0 newer1 newer2
+ StrCmp $4 0 0 +2
+ StrCmp $5 0 begin newer2
+ StrCmp $5 0 newer1
+ IntCmp $6 $7 0 newer1 newer2
- StrCpy $4 '1$4'
- StrCpy $5 '1$5'
- IntCmp $4 $5 begin newer2 newer1
+ StrCpy $4 '1$4'
+ StrCpy $5 '1$5'
+ IntCmp $4 $5 begin newer2 newer1
- equal:
- StrCpy $0 0
- goto end
- newer1:
- StrCpy $0 1
- goto end
- newer2:
- StrCpy $0 2
+ equal:
+ StrCpy $0 0
+ goto end
+ newer1:
+ StrCpy $0 1
+ goto end
+ newer2:
+ StrCpy $0 2
- end:
- Pop $7
- Pop $6
- Pop $5
- Pop $4
- Pop $3
- Pop $2
- Pop $1
- Exch $0
+ end:
+ Pop $7
+ Pop $6
+ Pop $5
+ Pop $4
+ Pop $3
+ Pop $2
+ Pop $1
+ Exch $0
FunctionEnd
diff --git a/distribution/windows/win32.txt b/distribution/windows/win32.txt
deleted file mode 100644
index a33ea783b6..0000000000
--- a/distribution/windows/win32.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!define APPBITS 32 ; Define number of bits for the architecture
-!define EXTRA_VERSION "Vista, 7, 8.1 and 10"
-!define APPARCH "win32" ; Define the application architecture
-!define BINARY_DIR "${PATH_ROOT}bin"
-InstallDir "$PROGRAMFILES32\OpenRCT2\"
diff --git a/openrct2.proj b/openrct2.proj
new file mode 100644
index 0000000000..edc667dc4b
--- /dev/null
+++ b/openrct2.proj
@@ -0,0 +1,279 @@
+
+
+
+
+
+
+
+
+
+
+
+ 0.0.5
+ 9
+
+ $(COMPUTERNAME)
+ $(GIT_COMMIT_SHA1.Substring(0, 7))
+
+
+ OPENRCT2_BUILD_SERVER="$(BUILD_SERVER)";$(OPENRCT2_DEFINES)
+ OPENRCT2_BRANCH="$(GIT_BRANCH)";$(OPENRCT2_DEFINES)
+ OPENRCT2_COMMIT_SHA1="$(GIT_COMMIT_SHA1)";$(OPENRCT2_DEFINES)
+ OPENRCT2_COMMIT_SHA1_SHORT="$(GIT_COMMIT_SHA1_SHORT)";$(OPENRCT2_DEFINES)
+
+ $(MsBuildThisFileDirectory)
+ $(RootDir)distribution\
+ $(RootDir)artifacts\
+
+ $(DistDir)windows\install.nsi
+
+ $(TargetDir)openrct2.dll
+ $(TargetDir)openrct2.exe
+ $(TargetPath)
+ $(TargetDir)openrct2_data
+ $(TargetDir)data\g2.dat
+
+ $(DistDir)windows\code-sign-key-openrct2.org.pfx
+ http://timestamp.comodoca.com/authenticode
+
+ -$(Configuration)-$(Platform)
+ $(PublishPostfix)-$(GIT_COMMIT_SHA1_SHORT)
+ $(PublishPostfix.ToLower())
+ $(ArtifactsDir)openrct2-portable$(PublishPostfix).zip
+ $(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip
+ $(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip
+ $(ArtifactsDir)openrct2-installer$(PublishPostfix).exe
+
+ OpenRCT2-$(Version)$(VersionExtension)-windows
+
+
+
+
+ https://github.com/OpenRCT2/Dependencies/releases/download/v$(TargetLibsVersion)/openrct2-libs-vs2015.zip
+ $(RootDir)lib\
+ $(LibsPath)libversion
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(UploadFilename).zip
+ 1
+ 6
+
+
+ $(UploadFilename).exe
+ 2
+ 7
+
+
+ $(UploadFilename)-symbols.zip
+ 5
+ 10
+
+
+
+
+
+
+
+ 0
+ $([System.IO.File]::ReadAllText($(LibsVersionPath)).Trim())
+ true
+
+
+
+
+
+
+
+
+
+ $(LibsPath)openrct2-libs-vs2015.zip
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(GIT_COMMIT_SHA1_SHORT)
+ $(BuildString) ($(GIT_BRANCH))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_7z Output="$(PublishZip)" Inputs="@(PublishItems)" />
+
+
+
+
+
+
+ <_7z Output="$(PublishSymbolsZip)" Inputs="@(SymbolItems)" />
+
+
+
+
+
+ -$(GIT_BRANCH)-$(GIT_COMMIT_SHA1_SHORT)
+ $(GIT_TAG)
+ -$(GIT_TAG)
+ $([System.IO.Path]::GetFilename($(PublishInstallerExe)))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ https://openrct2.org/altapi/?command=push-build
+ %(UploadArtifacts.Filename)%(UploadArtifacts.Extension)
+
+
+
+
+
+
+
+
+
diff --git a/openrct2.targets b/openrct2.targets
new file mode 100644
index 0000000000..cb86b35663
--- /dev/null
+++ b/openrct2.targets
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/openrct2.vcxproj b/openrct2.vcxproj
index aa570a658c..bf2b6d596d 100644
--- a/openrct2.vcxproj
+++ b/openrct2.vcxproj
@@ -1,9 +1,5 @@
-
-
-
-
-
+
Debug
diff --git a/readme.md b/readme.md
index 6e8448e504..1bbc034c75 100644
--- a/readme.md
+++ b/readme.md
@@ -53,7 +53,8 @@ OpenRCT2 requires original files of RollerCoaster Tycoon 2 to play. It can be bo
### Windows:
- Vista / 7 / 8 / 10
- Visual Studio 2015 Update 2 (Enterprise / Professional / [Community (Free)](https://www.visualstudio.com/products/visual-studio-community-vs))
-- [Powershell 4.0](http://social.technet.microsoft.com/wiki/contents/articles/21016.how-to-install-windows-powershell-4-0.aspx).
+- [7-Zip](http://www.7-zip.org/) (for deployment only)
+- [NSIS](http://nsis.sourceforge.net/) (for deployment only)
### Mac:
- [Homebrew](http://brew.sh)
@@ -71,13 +72,18 @@ All libs listed here (bar cmake) required in 32 bit variants.
## 3.2 Compiling and running
### Windows:
1. Check out the repository. This can be done using [GitHub Desktop](https://desktop.github.com) or [other tools](https://help.github.com/articles/which-remote-url-should-i-use).
-2. Open a new Developer Command Prompt for VS2015, run PowerShell and then navigate to the repository.
-3. Run the ```setenv.ps1``` script in the repository to set up your PowerShell environment for OpenRCT2 development. This will warn you of any missing applications required to build OpenRCT2.
-4. Run ```install``` to download the required dependencies to build OpenRCT2.
-5. Run ```build all``` to build all the required components for OpenRCT2.
-6. Run ```run``` to run OpenRCT2.
+2. Open a new Developer Command Prompt for VS2015, then navigate to the repository (e.g. `cd C:\GitHub\OpenRCT2`).
+3. Run `msbuild openrct2.proj /t:build`.
-These PowerShell scripts are stored in ```.\scripts\ps``` and have parameters. Once you have used the build script once, further development can be done within Visual Studio by opening ```openrct2.sln```. The build scripts have several commands allowing you to rebuild certain components such ```g2.dat``` or language files.
+Once you have ran msbuild once, further development can be done within Visual Studio by opening `openrct2.sln`.
+
+Other examples:
+```
+msbuild openrct2.proj /t:clean
+msbuild openrct2.proj /t:rebuild /p:configuration=release /p:platform=x64
+msbuild openrct2.proj /t:g2
+msbuild openrct2.proj /t:PublishPortable
+```
### Mac:
We support native builds for macOS (limited to i386 only for now).
diff --git a/scripts/ps/appveyor_build.ps1 b/scripts/ps/appveyor_build.ps1
deleted file mode 100644
index 6d87e22bb8..0000000000
--- a/scripts/ps/appveyor_build.ps1
+++ /dev/null
@@ -1,161 +0,0 @@
-#########################################################
-# Script to build OpenRCT2 on AppVeyor
-#########################################################
-
-function Push-Build($file, $name, $version, $flavourId)
-{
- curl.exe -s -o - `
- --form "key=${env:OPENRCT2.ORG_TOKEN}" `
- --form "fileName=$name" `
- --form "version=$version" `
- --form "gitHash=${env:APPVEYOR_REPO_COMMIT}" `
- --form "gitBranch=${env:APPVEYOR_REPO_BRANCH}" `
- --form "flavourId=$flavourId" `
- --form "file=@$file" `
- "https://openrct2.org/altapi/?command=push-build"
-}
-
-$server = "AppVeyor"
-
-# Provide a short commit SHA1 too
-${env:APPVEYOR_REPO_COMMIT_SHORT} = (${env:APPVEYOR_REPO_COMMIT}).Substring(0, 7)
-
-# Current version
-$version = "0.0.5.0"
-
-# Tagged builds will hide branch and commit SHA1
-$tag = $null
-if (${env:APPVEYOR_REPO_TAG} -ne $null)
-{
- $tag = ${env:APPVEYOR_REPO_TAG_NAME}
-}
-
-# Enable code signing if password environment variable is set
-$codeSign = $false
-if (${env:CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD} -ne $null)
-{
- $codeSign = $true
-}
-
-# Enable pushing builds to OpenRCT2.org if token environment variable is set
-$pushBuilds = $false
-$installer = $false
-$symbols = $true
-if (${env:OPENRCT2.ORG_TOKEN} -ne $null)
-{
- $installer = $true
-
- if ($tag -ne $null -or $env:APPVEYOR_REPO_BRANCH -match "^develop$|^push/")
- {
- $pushBuilds = $true
- }
-}
-
-# Write out summary of the build
-Write-Host "AppVeyor CI Build" -ForegroundColor Green
-if ($tag -ne $null)
-{
- Write-Host " $version ($tag)" -ForegroundColor Green
-}
-else
-{
- Write-Host " $version-$env:APPVEYOR_REPO_BRANCH-$env:APPVEYOR_REPO_COMMIT_SHORT" -ForegroundColor Green
-}
-Write-Host " Signed: $codeSign" -ForegroundColor Green
-Write-Host " Push : $pushBuilds" -ForegroundColor Green
-
-# Install dependencies
-install -Quiet
-
-# Build OpenRCT2
-publish build `
- -Server $server `
- -GitTag $tag `
- -GitBranch $env:APPVEYOR_REPO_BRANCH `
- -GitSha1 $env:APPVEYOR_REPO_COMMIT `
- -GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
- -CodeSign $codeSign
-
-if ($LASTEXITCODE -ne 0)
-{
- exit 1
-}
-
-# Create a Portable ZIP
-publish package `
- -Server $server `
- -GitTag $tag `
- -GitBranch $env:APPVEYOR_REPO_BRANCH `
- -GitSha1 $env:APPVEYOR_REPO_COMMIT `
- -GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
- -CodeSign $codeSign
-
-# Create an Installer
-if ($installer)
-{
- publish package `
- -Installer `
- -Server $server `
- -GitTag $tag `
- -GitBranch $env:APPVEYOR_REPO_BRANCH `
- -GitSha1 $env:APPVEYOR_REPO_COMMIT `
- -GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
- -CodeSign $codeSign
-}
-
-if ($symbols)
-{
- publish package `
- -Symbols `
- -Server $server `
- -GitTag $tag `
- -GitBranch $env:APPVEYOR_REPO_BRANCH `
- -GitSha1 $env:APPVEYOR_REPO_COMMIT `
- -GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
- -CodeSign $codeSign
-}
-
-if ($pushBuilds)
-{
- $versionExtension = ""
- if ($tag -ne $null)
- {
- # Hide tag if it is a version
- if ($GitTag -notmatch "^v[0-9]")
- {
- $versionExtension = "-$tag"
- }
- }
- else
- {
- $versionExtension = "-${env:APPVEYOR_REPO_BRANCH}-${env:APPVEYOR_REPO_COMMIT_SHORT}"
- }
- $pushFileName = "OpenRCT2-${version}${versionExtension}-windows"
-
- # Push portable zip
- Write-Host "Sending portable zip to OpenRCT2.org" -ForegroundColor Cyan
- Push-Build -file ".\artifacts\openrct2.zip" `
- -name "$pushFileName.zip" `
- -version $version `
- -flavourId 1
-
- # Push installer
- if ($installer)
- {
- Write-Host "Sending installer to OpenRCT2.org" -ForegroundColor Cyan
- Push-Build -file ".\artifacts\openrct2-install.exe" `
- -name "$pushFileName.exe" `
- -version $version `
- -flavourId 2
- }
-
- # Push symbols
- if ($symbols)
- {
- Write-Host "Sending symbols to OpenRCT2.org" -ForegroundColor Cyan
- Push-Build -file ".\artifacts\openrct2-symbols-${env:APPVEYOR_REPO_COMMIT_SHORT}.zip" `
- -name "$pushFileName-symbols.zip" `
- -version $version `
- -flavourId 5
- }
-}
diff --git a/scripts/ps/appveyor_deploy.ps1 b/scripts/ps/appveyor_deploy.ps1
new file mode 100644
index 0000000000..bf63ce8592
--- /dev/null
+++ b/scripts/ps/appveyor_deploy.ps1
@@ -0,0 +1,21 @@
+###########################################
+# Script to deploy OpenRCT2 from AppVeyor #
+###########################################
+
+# Check if OpenRCT2.org API security token is available
+if (${env:OPENRCT2_ORG_TOKEN})
+{
+ # Only upload tagged builds, develop branch or push/ branches
+ if (${env:APPVEYOR_REPO_TAG} -eq "true" -or ${env:APPVEYOR_REPO_BRANCH} -match "^develop$|^push/")
+ {
+ msbuild openrct2.proj /t:UploadArtifacts /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
+ }
+ else
+ {
+ Write-Host "No deployment: Non-tagged or push branch." -ForegroundColor Yellow
+ }
+}
+else
+{
+ Write-Host "No deployment: %OPENRCT2_ORG_TOKEN% not available." -ForegroundColor Yellow
+}
diff --git a/scripts/ps/appveyor_install.ps1 b/scripts/ps/appveyor_install.ps1
index 92a1dcd9ef..762318c20e 100644
--- a/scripts/ps/appveyor_install.ps1
+++ b/scripts/ps/appveyor_install.ps1
@@ -23,7 +23,8 @@ if ($env:ENCKEY)
Check-ExitCode
}
-if (${env:OPENRCT2.ORG_TOKEN})
+# Check if OpenRCT2.org API security token is available
+if (${env:OPENRCT2_ORG_TOKEN})
{
if (-not (Test-Path "C:\ProgramData\chocolatey\lib\nsis.portable"))
{
@@ -43,3 +44,8 @@ if (${env:OPENRCT2.ORG_TOKEN})
cp FindProcDLL.dll "C:\ProgramData\chocolatey\lib\nsis.portable\tools\nsis-3.0b1\Plugins\x86-ansi"
}
}
+else
+{
+ # Don't build the NSIS installer for non-uploaded builds
+ ${env:NO_NSIS} = "true"
+}
diff --git a/scripts/ps/build.ps1 b/scripts/ps/build.ps1
deleted file mode 100644
index 3a908184e2..0000000000
--- a/scripts/ps/build.ps1
+++ /dev/null
@@ -1,90 +0,0 @@
-#########################################################
-# Script to build different parts of OpenRCT2
-#########################################################
-[CmdletBinding()]
-param (
- [Parameter(Mandatory = $false, Position = 1)]
- [string]$Task = "openrct2",
-
- [Parameter(Mandatory = $false)]
- [string]$Configuration = "Release",
-
- [Parameter(Mandatory = $false)]
- [switch]$Rebuild = $false,
-
- [Parameter(Mandatory = $false)]
- [switch]$Breakpad = $false
-)
-
-# Setup
-$ErrorActionPreference = "Stop"
-$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
-Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
-
-# Get paths
-$rootPath = Get-RootPath
-$binPath = Join-Path $rootPath "bin"
-$openrct2Path = Join-Path $binPath "openrct2.exe"
-
-function Build-Data()
-{
- $dataPath = "$rootPath\data"
- $binDataPath = "$binPath\data"
-
- # Create data directory in bin
- Write-Host "Create data directory..." -ForegroundColor Cyan
- New-Item -Force -ItemType Directory $binDataPath > $null
-
- # Create symlinks
- Symlink-or-Copy "$binDataPath\language" "$dataPath\language" > $null
- Symlink-or-Copy "$binDataPath\shaders" "$dataPath\shaders" > $null
- Symlink-or-Copy "$binDataPath\title" "$dataPath\title" > $null
-
- return 0
-}
-
-function Build-OpenRCT2()
-{
- Write-Host "Building OpenRCT2 ($Configuration)..." -ForegroundColor Cyan
-
- $target = ""
- if ($Rebuild)
- {
- $target = "/t:rebuild"
- }
- msbuild $rootPath\openrct2.sln /p:Breakpad=$Breakpad /p:Configuration=$Configuration /p:Platform=Win32 $target /v:minimal | Write-Host
- return $LASTEXITCODE
-}
-
-function Build-G2()
-{
- # Check if OpenRCT2 binary exists
- if (-not (Test-Path $openrct2Path))
- {
- Write-Host "You must build OpenRCT2 first before g2.dat can be built." -ForegroundColor Red
- return 1
- }
-
- Write-Host "Building g2.dat..." -ForegroundColor Cyan
- & $openrct2Path sprite build "$binPath\data\g2.dat" "$rootPath\resources\g2"
- return $LASTEXITCODE
-}
-
-function Build-All()
-{
- if (($result = (Build-Data )) -ne 0) { return $result }
- if (($result = (Build-OpenRCT2)) -ne 0) { return $result }
- if (($result = (Build-G2 )) -ne 0) { return $result }
-}
-
-# Script entry point
-switch ($Task)
-{
- "data" { $result = Build-Data }
- "openrct2" { $result = Build-OpenRCT2 }
- "g2" { $result = Build-G2 }
- "all" { $result = Build-All }
- default { Write-Host "Unknown build task." -ForegroundColor Red
- $result = 1 }
-}
-exit $result
diff --git a/scripts/ps/common.psm1 b/scripts/ps/common.psm1
deleted file mode 100644
index 17868366cf..0000000000
--- a/scripts/ps/common.psm1
+++ /dev/null
@@ -1,83 +0,0 @@
-#########################################################
-# Common functions for OpenRCT2 PowerShell scripts
-#########################################################
-$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
-
-function AppExists($app)
-{
- $result = (Get-Command $app -CommandType Application -ErrorAction SilentlyContinue)
- return ($result -ne $null -and $result.Count -gt 0)
-}
-
-function AddPath($path)
-{
- $env:path = "$path;$env:path"
-}
-
-function Get-RootPath()
-{
- return Split-Path (Split-Path $scriptsPath)
-}
-
-function Prompt-User($message)
-{
- $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Yes"
- $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "No"
- $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
- $choice = $host.UI.PromptForChoice("", $message, $options, 1)
- return ($choice -eq 0)
-}
-
-function Resolve-PathFromBase($path)
-{
- $rootPath = Get-RootPath
- if ($path.StartsWith($rootPath)) {
- $path = $path.Remove(0, $rootPath.Length + 1)
- }
- return $path
-}
-
-function Symlink-or-Copy($path, $target)
-{
- $pathDirectory = Split-Path $path
- $pathName = Split-Path $path -Leaf
-
- $friendlyPath = Resolve-PathFromBase $path
- $friendlyTarget = Resolve-PathFromBase $target
-
- # If the path is not a symlink, copy files instead
- $mustCopy = $false
- if (Test-Path $path)
- {
- if (-not ((Get-Item $path).Attributes -band [IO.FileAttributes]::ReparsePoint))
- {
- $mustCopy = $true
- }
- }
-
- $symlinkSuccessful = $false
- if (-not $mustCopy)
- {
- try
- {
- Write-Host "Symlink $friendlyPath to $friendlyTarget..." -ForegroundColor Cyan
- New-Item -Force -ItemType SymbolicLink -Path $pathDirectory -Name $pathName -Target $target -ErrorAction Stop
- $symlinkSuccessful = $true
- }
- catch [System.Management.Automation.ParameterBindingException]
- {
- Write-Host " Your powershell can not create symlinks, try updating it" -ForegroundColor Red
- }
- catch [System.UnauthorizedAccessException]
- {
- Write-Host " You need to run powershell in administration mode to create symlinks" -ForegroundColor Red
- }
- }
-
- if (-not $symlinkSuccessful)
- {
- Write-Host "Copying $friendlyTarget to $friendlyPath..." -ForegroundColor Cyan
- New-Item -Force -Type Directory $path > $null
- Copy-Item -Force -Recurse "$target\*" $path
- }
-}
diff --git a/scripts/ps/install.ps1 b/scripts/ps/install.ps1
deleted file mode 100644
index 9d5fc99185..0000000000
--- a/scripts/ps/install.ps1
+++ /dev/null
@@ -1,63 +0,0 @@
-#########################################################
-# Script to install the latest dependencies for OpenRCT2
-#########################################################
-param (
- [switch]$Force,
- [switch]$Quiet
-)
-Write-Host "Installing OpenRCT2 development environment for Windows" -ForegroundColor Cyan
-
-# Setup
-$ErrorActionPreference = "Stop"
-$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
-Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
-
-# Constants
-$libsVersion = 9
-$libsUrl = "https://github.com/OpenRCT2/Dependencies/releases/download/v$libsVersion/openrct2-libs-vs2015.zip"
-
-# Get paths
-$rootPath = Get-RootPath
-$libsPath = Join-Path $rootPath "lib"
-$zipPath = Join-Path $libsPath "openrct2-libs-vs2015.zip"
-$libsVersionPath = Join-Path $libsPath "libversion"
-
-# Check if we need to update the dependencies
-$currentLibsVersion = 0
-$updateLibs = $true
-if (Test-Path $libsVersionPath)
-{
- $currentLibsVersion = [IO.File]::ReadAllText($libsVersionPath)
-}
-if ($currentLibsVersion -ge $libsVersion)
-{
- $updateLibs = $false
-}
-
-# Check if user needs to download dependencies
-$libsPathExists = Test-Path $libsPath
-if ($libsPathExists -and -not $updateLibs -and -not $Force)
-{
- if (-not $Quiet -and (Prompt-User "Dependencies already exists, reinstall?"))
- {
- $updateLibs = $true
- }
-}
-else
-{
- $updateLibs = $true
-}
-
-# Download latest version of the dependencies
-if ($updateLibs) {
- Write-Host "Updating dependencies..." -ForegroundColor Cyan
-
- Remove-Item -Force -Recurse $libsPath -ErrorAction SilentlyContinue
- New-Item -Force -ItemType Directory $libsPath > $null
-
- Invoke-WebRequest $libsUrl -OutFile $zipPath
- [System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null
- [System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $libsPath)
- Remove-Item $zipPath -Force -ErrorAction SilentlyContinue
- $libsVersion | Set-Content $libsVersionPath
-}
diff --git a/scripts/ps/publish.ps1 b/scripts/ps/publish.ps1
deleted file mode 100644
index 85cd9f5442..0000000000
--- a/scripts/ps/publish.ps1
+++ /dev/null
@@ -1,326 +0,0 @@
-#########################################################
-# Script to build and package OpenRCT2
-# - Sets the source code preprocessor defines
-# - Builds a clean release of OpenRCT2
-# - Creates a ZIP for distribution
-#########################################################
-param (
- [Parameter(Position = 1)]
- [string]$Task = "all",
-
- [string]$Server = "",
- [string]$GitTag = "",
- [string]$GitBranch = "",
- [string]$GitSha1 = "",
- [string]$GitSha1Short = "",
- [bool] $CodeSign = $false,
- [switch]$Installer = $false,
- [switch]$Symbols = $false
-)
-
-if (-not $GitTag)
-{
- if (-not $GitBranch)
- {
- $GitBranch = (git rev-parse --abbrev-ref HEAD)
- }
- if (-not $GitCommitSha1)
- {
- $GitCommitSha1 = (git rev-parse HEAD)
- }
- if (-not $GitCommitSha1Short)
- {
- $GitCommitSha1Short = (git rev-parse --short HEAD)
- }
-}
-
-# Setup
-$ErrorActionPreference = "Stop"
-$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
-Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
-
-# Get paths
-$rootPath = Get-RootPath
-
-# Set build attributes
-function Do-PrepareSource()
-{
- Write-Host "Setting build #defines..." -ForegroundColor Cyan
- $defines = @{ }
- $defines["OPENRCT2_BUILD_SERVER"] = $Server;
- if ($GitTag -ne "")
- {
- # Hide tag if it is a version
- if ($GitTag -match "^v[0-9]")
- {
- $defines["OPENRCT2_BRANCH"] = "";
- }
- else
- {
- $defines["OPENRCT2_BRANCH"] = $GitTag;
- }
- }
- else
- {
- $defines["OPENRCT2_BRANCH"] = $GitBranch;
- $defines["OPENRCT2_COMMIT_SHA1"] = $GitCommitSha1;
- $defines["OPENRCT2_COMMIT_SHA1_SHORT"] = $GitCommitSha1Short;
- }
-
- $defineString = ""
- foreach ($key in $defines.Keys) {
- $value = $defines[$key]
- if ($value -is [System.String]) {
- $value = $value.Replace('"', '\"')
- }
- $defineString += "$key=""$value"";";
- }
-
- # Set the environment variable which the msbuild project will use
- $env:OPENRCT2_DEFINES = $defineString;
-
- return 0
-}
-
-# Building OpenRCT2
-function Do-Build()
-{
- Write-Host "Building OpenRCT2..." -ForegroundColor Cyan
- & "$scriptsPath\build.ps1" all -Rebuild -Breakpad
- if ($LASTEXITCODE -ne 0)
- {
- Write-Host "Failed to build OpenRCT2" -ForegroundColor Red
- return 1
- }
-
- if ($CodeSign)
- {
- $releaseDir = "$rootPath\bin"
- $exePath = "$releaseDir\openrct2.exe"
- $dllPath = "$releaseDir\openrct2.dll"
-
- if (-not (Sign-Binary($exePath))) { return 1 }
- if (-not (Sign-Binary($dllPath))) { return 1 }
- }
-
- return 0
-}
-
-# Symbols
-function Do-Symbols()
-{
- Write-Host "Publishing OpenRCT2 debug symbols as zip..." -ForegroundColor Cyan
- $artifactsDir = "$rootPath\artifacts"
- $releaseDir = "$rootPath\bin"
- $outZip = "$rootPath\artifacts\openrct2-symbols-$GitSha1Short.zip"
-
- Copy-Item -Force "$releaseDir\openrct2.pdb" $artifactsDir -ErrorAction Stop
- Copy-Item -Force "$releaseDir\openrct2.dll" $artifactsDir -ErrorAction Stop
-
- # Create archive using 7z (renowned for speed and compression)
- $7zcmd = "7za"
- if (-not (AppExists($7zcmd)))
- {
- # AppVeyor in particular uses '7z' instead
- $7zcmd = "7z"
- if (-not (AppExists($7zcmd)))
- {
- Write-Host "Publish script requires 7z to be in PATH" -ForegroundColor Red
- return 1
- }
- }
- & $7zcmd a -tzip -mx9 -mtc=off $outZip "$artifactsDir\openrct2.pdb" "$artifactsDir\openrct2.dll" > $null
- if ($LASTEXITCODE -ne 0)
- {
- Write-Host "Failed to create zip." -ForegroundColor Red
- return 1
- }
- Remove-Item -Force -Recurse "$artifactsDir\openrct2.pdb" -ErrorAction SilentlyContinue
- return 0
-}
-
-# Package
-function Do-Package()
-{
- Write-Host "Publishing OpenRCT2 as zip..." -ForegroundColor Cyan
- $releaseDir = "$rootPath\bin"
- $distDir = "$rootPath\distribution"
- $tempDir = "$rootPath\artifacts\temp"
- $outZip = "$rootPath\artifacts\openrct2.zip"
-
- # Create new temp directory
- Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
- New-Item -Force -ItemType Directory $tempDir > $null
-
- # Copy files to be archived
- Copy-Item -Force -Recurse "$releaseDir\data" $tempDir -ErrorAction Stop
- Copy-Item -Force "$releaseDir\openrct2.exe" $tempDir -ErrorAction Stop
- Copy-Item -Force "$releaseDir\openrct2.dll" $tempDir -ErrorAction Stop
- Copy-Item -Force "$releaseDir\curl-ca-bundle.crt" $tempDir -ErrorAction Stop
- Copy-Item -Force "$distDir\changelog.txt" $tempDir -ErrorAction Stop
- Copy-Item -Force "$distDir\known_issues.txt" $tempDir -ErrorAction Stop
- Copy-Item -Force "$distDir\readme.txt" $tempDir -ErrorAction Stop
- Copy-Item -Force "$rootPath\contributors.md" $tempDir -ErrorAction Stop
- Copy-Item -Force "$rootPath\licence.txt" $tempDir -ErrorAction Stop
-
- # Create archive using 7z (renowned for speed and compression)
- $7zcmd = "7za"
- if (-not (AppExists($7zcmd)))
- {
- # AppVeyor in particular uses '7z' instead
- $7zcmd = "7z"
- if (-not (AppExists($7zcmd)))
- {
- Write-Host "Publish script requires 7z to be in PATH" -ForegroundColor Red
- return 1
- }
- }
- & $7zcmd a -tzip -mx9 -mtc=off $outZip "$tempDir\*" > $null
- if ($LASTEXITCODE -ne 0)
- {
- Write-Host "Failed to create zip." -ForegroundColor Red
- return 1
- }
-
- # Remove temp directory
- Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
- return 0
-}
-
-# Installer
-function Do-Installer()
-{
- Write-Host "Publishing OpenRCT2 as installer..." -ForegroundColor Cyan
- $artifactsDir = "$rootPath\artifacts"
- $installerDir = "$rootPath\distribution\windows"
-
- # Create artifacts directory
- New-Item -Force -ItemType Directory $artifactsDir > $null
-
- # Resolve version extension
- $VersionExtra = ""
- if ($GitTag -ne "")
- {
- # Hide tag if it is a version
- if ($GitTag -notmatch "^v[0-9]")
- {
- $VersionExtra = "-$GitTag";
- }
- }
- else
- {
- $VersionExtra = "-$GitBranch-$GitCommitSha1Short"
- }
-
- # Create installer
- & "$installerDir\build.ps1" -VersionExtra $VersionExtra
- if ($LASTEXITCODE -ne 0)
- {
- Write-Host "Failed to create installer." -ForegroundColor Red
- if (Test-Path -PathType Leaf "$installerDir\win32.log")
- {
- Get-Content "$installerDir\win32.log" | Write-Host
- }
- return 1
- }
-
- $binaries = (Get-ChildItem "$installerDir\*.exe" | Sort-Object -Property LastWriteTime -Descending)
- if ($binaries -eq 0)
- {
- Write-Host "Unable to find created installer." -ForegroundColor Red
- return 1
- }
-
- $installerPath = $binaries[0].FullName
-
- if ($CodeSign)
- {
- if (-not (Sign-Binary($installerPath))) { return 1 }
- }
-
- Move-Item -Force $installerPath "$artifactsDir\openrct2-install.exe"
- return 0
-}
-
-function Do-Task-Build()
-{
- if (($result = (Do-PrepareSource)) -ne 0) { return $result }
- if (($result = (Do-Build )) -ne 0) { return $result }
- return 0
-}
-
-function Do-Task-Package()
-{
- if ($Installer)
- {
- if (($result = (Do-Installer)) -ne 0) { return $result }
- }
- elseif ($Symbols)
- {
- if (($result = (Do-Symbols)) -ne 0) { return $result }
- }
- else
- {
- if (($result = (Do-Package)) -ne 0) { return $result }
- }
- return 0
-}
-
-function Do-Task-All()
-{
- if (($result = (Do-Task-Build )) -ne 0) { return $result }
- if (($result = (Do-Task-Package)) -ne 0) { return $result }
- return 0
-}
-
-function Sign-Binary($binaryPath)
-{
- $pfxPath = "$rootPath\distribution\windows\code-sign-key-openrct2.org.pfx"
- $pfxPassword = ${env:CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD}
- $timestampUrl = "http://timestamp.comodoca.com/authenticode"
-
- if (-not (Test-Path -PathType Leaf $pfxPath))
- {
- Write-Host "Unable to sign, code signature key was not found." -ForegroundColor Red
- return 1
- }
-
- if ($pfxPassword -eq $null)
- {
- Write-Host "Unable to sign, %CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD% was not set." -ForegroundColor Red
- return 1
- }
-
- # Resolve signtool path
- $signtoolcmd = "signtool"
- if (-not (AppExists($signtoolcmd)))
- {
- $signtoolcmd = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\SignTool.exe"
- if (-not (AppExists($signtoolcmd)))
- {
- Write-Host "Publish script requires signtool to be in PATH" -ForegroundColor Red
- return 1
- }
- }
-
- # Sign the binary
- & $signtoolcmd sign /f $pfxPath /p $pfxPassword /t $timestampUrl $binaryPath
- if ($LASTEXITCODE -ne 0)
- {
- Write-Host "Failed to sign binary." -ForegroundColor Red
- return 1
- }
-
- return 0
-}
-
-# Script entry point
-switch ($Task)
-{
- "build" { $result = Do-Task-Build }
- "package" { $result = Do-Task-Package }
- "all" { $result = Do-Task-All }
- default { Write-Host "Unknown publish task." -ForegroundColor Red
- $result = 1 }
-}
-exit $result