diff --git a/appveyor.yml b/appveyor.yml index 0e340f37db0df5d538ae8efc8e5979ddc09f3b89..560434abd09db7d17d347fc069435dacb2e143d2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -48,11 +48,13 @@ build_script: - ".\\ci\\appveyor\\tests.cmd" - echo %errorlevel% + - powershell .\\ci\\appveyor\\download_vcredist.ps1 -target %cd%\\ci\\appveyor + # Windows Installer - - if [%APPVEYOR_REPO_TAG_NAME%] neq [] choco install -y InnoSetup - - if [%APPVEYOR_REPO_TAG_NAME%] neq [] set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH% - - if [%APPVEYOR_REPO_TAG_NAME%] neq [] iscc %cd%\ci\appveyor\sakia.iss /DROOT_PATH=%cd% - - if [%APPVEYOR_REPO_TAG_NAME%] neq [] move %cd%\sakia.exe %cd%\sakia-%APPVEYOR_REPO_TAG_NAME%-win%PYTHON_ARCH%.exe + - choco install -y InnoSetup + - set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH% + - iscc %cd%\ci\appveyor\sakia.iss /DROOT_PATH=%cd% + - move %cd%\sakia.exe %cd%\sakia-%APPVEYOR_REPO_TAG_NAME%-win%PYTHON_ARCH%.exe artifacts: - path: dist diff --git a/ci/appveyor/download_vcredist.ps1 b/ci/appveyor/download_vcredist.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..3400604ed82dc1e7d95d4ca47c418996671e9189 --- /dev/null +++ b/ci/appveyor/download_vcredist.ps1 @@ -0,0 +1,6 @@ +Param([String]$target) + +Write-Host "Downloading vcredist to $target" +(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/A/4/D/A4D9F1D3-6449-49EB-9A6E-902F61D8D14B/vcredist_x86.exe', "$target\vcredist_x86.exe") +(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/A/4/D/A4D9F1D3-6449-49EB-9A6E-902F61D8D14B/vcredist_x64.exe', "$target\vcredist_x64.exe") + diff --git a/ci/appveyor/sakia.iss b/ci/appveyor/sakia.iss index 3b22f038db2cd96d627ad92d237cec1bd6ddfbbe..465ebc6f70e33889291d1359e8bef4f10ed195f4 100644 --- a/ci/appveyor/sakia.iss +++ b/ci/appveyor/sakia.iss @@ -47,6 +47,8 @@ Source: "{#MyAppSrc}\sakia.ico"; DestDir: "{app}\"; Flags: ignoreversion recurse Source: "{#MyAppSrc}\sakia.png"; DestDir: "{app}\"; Flags: ignoreversion recursesubdirs Source: "{#MyAppSrc}\LICENSE"; DestDir: "{app}\"; Flags: ignoreversion recursesubdirs Source: "{#MyAppSrc}\ci\appveyor\after_install.cmd"; DestDir: "{app}\"; Flags: ignoreversion +Source: "{#MyAppSrc}\ci\appveyor\vcredist_x86.exe"; DestDir: "{tmp}\"; Flags: ignoreversion deleteafterinstall +Source: "{#MyAppSrc}\ci\appveyor\vcredist_x64.exe"; DestDir: "{tmp}\"; Flags: ignoreversion deleteafterinstall [Icons] Name: "{group}\{#MyAppName}"; IconFilename: "{app}\sakia.ico"; Filename: "{app}\{#MyAppExeName}" @@ -54,9 +56,49 @@ Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" Name: "{commondesktop}\{#MyAppName}"; IconFilename: "{app}\sakia.ico"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] +#define VCmsg "Installing Microsoft Visual C++ Redistributable...." + +[Run] +Filename: "{tmp}\vcredist_x86.exe"; StatusMsg: "{#VCmsg}"; Check: not IsWin64 and not VCinstalled +Filename: "{tmp}\vcredist_x64.exe"; StatusMsg: "{#VCmsg}"; Check: IsWin64 and not VCinstalled Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent Filename: "{app}\after_install.cmd"; Description: "Delete ALL existing data"; Flags: postinstall nowait skipifsilent unchecked +[Code] +function VCinstalled: Boolean; + // By Michael Weiner <mailto:spam@cogit.net> + // Function for Inno Setup Compiler + // 13 November 2015 + // Returns True if Microsoft Visual C++ Redistributable is installed, otherwise False. + // The programmer may set the year of redistributable to find; see below. + var + names: TArrayOfString; + i: Integer; + dName, key, year: String; + begin + // Year of redistributable to find; leave null to find installation for any year. + year := ''; + Result := False; + key := 'Software\Microsoft\Windows\CurrentVersion\Uninstall'; + // Get an array of all of the uninstall subkey names. + if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, key, names) then + // Uninstall subkey names were found. + begin + i := 0 + while ((i < GetArrayLength(names)) and (Result = False)) do + // The loop will end as soon as one instance of a Visual C++ redistributable is found. + begin + // For each uninstall subkey, look for a DisplayName value. + // If not found, then the subkey name will be used instead. + if not RegQueryStringValue(HKEY_LOCAL_MACHINE, key + '\' + names[i], 'DisplayName', dName) then + dName := names[i]; + // See if the value contains both of the strings below. + Result := (Pos(Trim('Visual C++ ' + year),dName) * Pos('Redistributable',dName) <> 0) + i := i + 1; + end; + end; + end; + [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications.