Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
generate setup.exe on build and sign it
Browse files Browse the repository at this point in the history
introduces a build-time dependency on inno setup 5 from http://www.jrsoftware.org/ . setup.exe generation can be disabled in the post-build action if needed.
  • Loading branch information
dabear committed Jul 30, 2016
1 parent 9fdc2b5 commit bd33c64
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 10 deletions.
26 changes: 22 additions & 4 deletions FloatingGlucose/FloatingGlucose.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,33 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>cd $(TargetDir)
echo Deleting files in build directory
del /F /Q *.zip
del /F /Q Setup*.exe
set "projectname=$(ProjectName)"
set "buildconfigname=$(ConfigurationName)"
set "signtool="C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" sign /fd sha256 /tr http://time.certum.pl/ /sha1 0B360481F3F59C7F398FB0417AA4B341EB018906 "
set "innosetupiscc="%25programfiles(x86)%25/Inno Setup 5/ISCC.exe" /Qp"
set PWS=powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile

REM install(import) pfx to windows certificate store, then select it based on its sha1 #hash and sign the application
REM the visual studio code signing doesn't seem to handle the pfx file I have correctly, so I rather invoke signing manually here with signtool (part of visual studio):
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" sign /fd sha256 /tr http://time.certum.pl/ /sha1 0B360481F3F59C7F398FB0417AA4B341EB018906 $(TargetPath)
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" sign /fd sha256 /tr http://time.certum.pl/ /sha1 0B360481F3F59C7F398FB0417AA4B341EB018906 $(TargetDir)\Newtonsoft.Json.dll
set PWS=powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile
%25PWS%25 -Command ". ..\..\buildscripts\create-zip-file.ps1; writeReleaseZipFile;"</PostBuildEvent>

echo Signing application executables
%25signtool%25 $(TargetPath)
%25signtool%25 $(TargetDir)\*.dll

REM Creates version numbered zip file

echo Creating version.txt file and zipping release
%25PWS%25 -Command ". ..\..\buildscripts\create-zip-file.ps1; writeVersionFile; createReleaseZipFile; "
set /p BUILDVER=&lt;version.txt
REM creates setupRelease.exe|setupDebug.exe installer

echo Creating Signed installer file

cd $(ProjectDir)\installer
%25innosetupiscc%25 /DReleaseType=$(ConfigurationName) /DMyAppVersion=%25BUILDVER%25 /O$(TargetDir) floatingglucose.iss</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>
Expand Down
27 changes: 21 additions & 6 deletions FloatingGlucose/buildscripts/create-zip-file.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
function out-zip($zipfilename, $files) {
#Load some assemblys. (No line break!)
[System.Reflection.Assembly]::Load("WindowsBase,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35") | Out-Null

#Create a zip file named "MyZipFile.zip". (No line break!)
$ZipPackage=[System.IO.Packaging.ZipPackage]::Open("$zipfilename",
Expand All @@ -30,10 +30,7 @@ function out-zip($zipfilename, $files) {
$ZipPackage.Close()
}

function getGitReleaseZipFileName() {
$projectname = $env:projectname
$buildconfigname = ($env:buildconfigname).toLower()
#$projectname = "FloatingGlucose"
function getGitTagOrReleaseName() {
$log = (git log --pretty=oneline --decorate | select -first 1)
#$log = (git log --pretty=oneline --decorate | select -Index 3)
$commit_id = "commit-" + ($log.Split(" ") | select -first 1).substring(0,8)
Expand All @@ -56,11 +53,29 @@ function getGitReleaseZipFileName() {
$version = $commit_id

}
return $version
}



function getGitReleaseZipFileName() {
#$projectname = "FloatingGlucose"
$projectname = $env:projectname
$buildconfigname = ($env:buildconfigname).toLower()
$version = getGitTagOrReleaseName
return "$projectname-$version-$buildconfigname.zip"

}

function writeReleaseZipFile(){
function writeVersionFile(){
$buildver = getGitTagOrReleaseName
#echo $buildver > version.txt #|out-file "version.txt" -Encoding "ascii"
#writealltext must be used to avoid newline
[System.IO.File]::WriteAllText("version.txt", $buildver)
echo "wrote $buildver to version.txt"
}

function createReleaseZipFile(){

$zipfilename = getGitReleaseZipFileName
$dir = pwd
Expand Down
1 change: 1 addition & 0 deletions FloatingGlucose/installer/Output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
62 changes: 62 additions & 0 deletions FloatingGlucose/installer/floatingglucose.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "FloatingGlucose"

#define MyAppPublisher "code.bjorninge.no"
#define MyAppURL "http://code.bjorninge.no"
#define MyAppExeName "FloatingGlucose.exe"
#define SourceDir ".."
;should be set via iscc
;cd installer
;"%programfiles(x86)%/Inno Setup 5/ISCC.exe" floatingglucose.iss
;#define MyAppVersion "0.9.9test"
;#define ReleaseType "Release"

;setting up signing:
; in inno setup, go to tools->configure sign tools
; add a new tool, call it "signtool" with the following value
; "C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe\" sign /fd sha256 /tr http://time.certum.pl/ /sha1 0B360481F3F59C7F398FB0417AA4B341EB018906 $f
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
SignTool=signtool /d $qFloatingGlucoseInstaller$q $f
AppId={{B271DEE6-C788-4604-B392-8B8DD16C97A8}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename="Setup{#ReleaseType}-{#MyAppVersion}"
Compression=lzma
SolidCompression=yes
SetupIconFile="{#SourceDir}\noun_335372_cc.ico"

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "..\bin\{#ReleaseType}\FloatingGlucose.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\{#ReleaseType}\FloatingGlucose.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\{#ReleaseType}\FloatingGlucose.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\{#ReleaseType}\Newtonsoft.Json.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\{#ReleaseType}\Newtonsoft.Json.xml"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\{#ReleaseType}\README_attributions.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\{#ReleaseType}\version.txt"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

0 comments on commit bd33c64

Please sign in to comment.