Skip to content

Commit

Permalink
Build self contained x86 & x64 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Timthreetwelve committed Dec 14, 2023
1 parent 965703a commit a7f3c84
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 16 deletions.
211 changes: 211 additions & 0 deletions WUView/Inno_Setup/WUViewEx.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
; ---------------------------------------------------------------------
; Inno Setup Script for Windows Update Viewer (WUView)
;----------------------------------------------------------------------
; The following #include file is created by the PubSetupEx.ps1 script.
;
; It contains #define statements for:
;
; InstallType: String denoting installer type.
; Inserted into the installer file name.
;
; PublishFolder: The output folder from MS Build.
; Varies depending on the type of build.
;----------------------------------------------------------------------
#include "D:\Temp\PubSetup.Temp.iss"

#define BaseDir "D:\Visual Studio\Source\Prod\WUView\WUView"
#define MySourceDir BaseDir + PublishFolder
#define MySetupIcon BaseDir + "\Images\UV.ico"
#define MyOutputDir "D:\InnoSetup\Output"
#define MyLargeImage "D:\InnoSetup\Images\WizardImageWUV2.bmp"
#define MySmallImage "D:\InnoSetup\Images\WizardSmallImage.bmp"

#define MyAppID "{3A152885-8378-4FDE-AFCC-85D096B16A1D}"
#define MyAppName "Windows Update Viewer"
#define MyAppNameNoSpaces StringChange(MyAppName, " ", "")
#define MyAppExeName "WUView.exe"
#define MyAppVersion GetVersionNumbersString(MySourceDir + "\" + MyAppExeName)
#define MyInstallerFilename MyAppNameNoSpaces + "_" + MyAppVersion + "_" + InstallType + "_Setup"
#define MyCompanyName "T_K"
#define MyPublisherName "Tim Kennedy"
#define StartCopyrightYear "2019"
#define CurrentYear GetDateTimeString('yyyy', '/', ':')
#define MyCopyright "(c) " + StartCopyrightYear + "-" + CurrentYear + " Tim Kennedy"
#define MyLicFile "D:\Visual Studio\Resources\License.rtf"
#define MyDateTimeString GetDateTimeString('yyyy/mm/dd hh:nn:ss', '/', ':')
#define MyAppSupportURL "https://github.com/Timthreetwelve/WUView"
#define RunRegKey "Software\Microsoft\Windows\CurrentVersion\Run"

; -----------------------------------------------------
; Include the localization file. Thanks bovirus!
; -----------------------------------------------------
#include "WUViewLocalization.iss"


[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.)
;---------------------------------------------
AppId={{#MyAppID}

;---------------------------------------------
; Uncomment the following line to run in non administrative install mode (install for current user only.)
; Installs in %localappdata%\Programs\ instead of \Program Files(x86)
;---------------------------------------------
PrivilegesRequired=lowest
;---------------------------------------------

AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}

AppCopyright={#MyCopyright}
AppPublisherURL={#MyAppSupportURL}
AppSupportURL={#MyAppSupportURL}
AppUpdatesURL={#MyAppSupportURL}

VersionInfoDescription={#MyAppName} installer
VersionInfoProductName={#MyAppName}
VersionInfoVersion={#MyAppVersion}

UninstallDisplayName={#MyAppName}
UninstallDisplayIcon={app}\{#MyAppExeName}
AppPublisher={#MyPublisherName}

ShowLanguageDialog=yes
UsePreviousLanguage=no
WizardStyle=modern
WizardSizePercent=100,100
WizardImageFile={#MyLargeImage}
WizardSmallImageFile={#MySmallImage}

AllowNoIcons=yes
Compression=lzma
DefaultDirName={autopf}\{#MyCompanyName}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyMemo=no
DisableStartupPrompt=yes
DisableWelcomePage=no
OutputBaseFilename={#MyInstallerFilename}
OutputDir={#MyOutputDir}
OutputManifestFile={#MyAppName}_{#MyAppVersion}_{#InstallType}_FileList.txt
SetupIconFile={#MySetupIcon}
SetupLogging=yes
SolidCompression=no
SourceDir={#MySourceDir}

[Files]
Source: "{#MySourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourceDir}\*.dll"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
Source: "{#MySourceDir}\*.json"; Excludes: "usersettings.json"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourceDir}\ReadMe.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourceDir}\License.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourceDir}\Strings.test.xaml"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[InstallDelete]
; Delete these files & folders from previous installs
Type: filesandordirs; Name: "{group}"
Type: files; Name: "{app}\Nlog.config"
Type: files; Name: "{app}\Newtonsoft.Json.dll"

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"

[Registry]
Root: HKCU; Subkey: "Software\{#MyCompanyName}"; Flags: uninsdeletekeyifempty
Root: HKCU; Subkey: "Software\{#MyCompanyName}\{#MyAppName}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\{#MyCompanyName}\{#MyAppName}"; ValueType: string; ValueName: "Copyright"; ValueData: "{#MyCopyright}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\{#MyCompanyName}\{#MyAppName}"; ValueType: string; ValueName: "Install Date"; ValueData: "{#MyDateTimeString}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\{#MyCompanyName}\{#MyAppName}"; ValueType: string; ValueName: "Version"; ValueData: "{#MyAppVersion}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\{#MyCompanyName}\{#MyAppName}"; ValueType: string; ValueName: "Install Folder"; ValueData: "{autopf}\{#MyCompanyName}\{#MyAppName}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\{#MyCompanyName}\{#MyAppName}"; ValueType: string; ValueName: "Installer Language"; ValueData:"{language}" ;Flags: uninsdeletekey
; Delete this key from previous installs
Root: HKCU; Subkey: "Software\{#MyCompanyName}\{#MyAppName}"; ValueType: none; ValueName: "Edition"; Flags: uninsdeletekey deletevalue

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

[UninstallRun]
Filename: "{sys}\taskkill.exe"; Parameters: "/im {#MyAppExeName} /t /f"; RunOnceId: "DelService"; Flags: runhidden skipifdoesntexist

[UninstallDelete]
Type: files; Name: "{app}\*.txt"

; -----------------------------------------------------------------------------
; Code section follows
; -----------------------------------------------------------------------------
[Code]
// function used to check if app is currently running
function IsAppRunning(const FileName : string): Boolean;
var
FSWbemLocator: Variant;
FWMIService : Variant;
FWbemObjectSet: Variant;
begin
Result := false;
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet :=
FWMIService.ExecQuery(
Format('SELECT Name FROM Win32_Process Where Name="%s"', [FileName]));
Result := (FWbemObjectSet.Count > 0);
FWbemObjectSet := Unassigned;
FWMIService := Unassigned;
FSWbemLocator := Unassigned;
end;
// Checks if app is running, if so, displays msgbox asking to close running app
function InitializeSetup(): Boolean;
var
Answer: Integer;
ThisApp: String;
begin
Result := true;
ThisApp := ExpandConstant('{#MyAppExeName}');
while IsAppRunning(ThisApp) do
begin
Answer := MsgBox(ThisApp + ' ' + CustomMessage('AppIsRunning'), mbError, MB_OKCANCEL);
If Answer = IDCANCEL then
begin
Result := false;
Exit;
end;
end;
end;
// Copies setup log to app folder
procedure CurStepChanged(CurStep: TSetupStep);
var
logfilepathname, newfilepathname: string;
begin
if CurStep = ssDone then
begin
logfilepathname := ExpandConstant('{log}');
newfilepathname := ExpandConstant('{app}\') + 'Setup_Log.txt';
Log('Setup log file copied to: ' + newfilepathname);
FileCopy(logfilepathname, newfilepathname, False);
end;
end;
// Uninstall
procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
mres : integer;
begin
case CurUninstallStep of
usPostUninstall:
begin
mres := MsgBox(CustomMessage('DeleteConfigFiles'), mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
if mres = IDYES then
begin
DelTree(ExpandConstant('{app}\*.json'), False, True, False);
DelTree(ExpandConstant('{app}'), True, True, True);
end;
end;
end;
end;
13 changes: 13 additions & 0 deletions WUView/Properties/PublishProfiles/Framework_Dependent.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Framework_Dependent</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions WUView/Properties/PublishProfiles/Self_Contained_x64.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Self_Contained_x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions WUView/Properties/PublishProfiles/Self_Contained_x86.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Self_Contained_x86</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>
72 changes: 56 additions & 16 deletions WUView/WUView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<Product>Windows Update Viewer</Product>
<ApplicationIcon>Images\UV.ico</ApplicationIcon>
<NeutralLanguage>en-US</NeutralLanguage>
<GenerateAssemblyFileVersionAttribute>False</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyVersionAttribute>False</GenerateAssemblyVersionAttribute>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -63,21 +66,58 @@
<Exec Command="powershell -NoProfile -File &quot;$(ProjectDir)Powershell\GenBuildInfo.ps1&quot; -assemblyName $(AssemblyName) -assemblyVersion $(AssemblyVersion)" />
</Target>

<Target Name="PublishZip" AfterTargets="Publish">
<PropertyGroup>
<PowerShellScript>-File "D:\Visual Studio\Source\PowerShell\PublishZip\PubZip.ps1"</PowerShellScript>
<Name>-name "Windows Update Viewer"</Name>
<Version>-version $(AssemblyVersion)</Version>
<Path>-path "$(ProjectDir)"</Path>
</PropertyGroup>
<Exec Command="pwsh -NoProfile $(PowerShellScript) $(Name) $(Version) $(Path)" />
</Target>
<!-- Publish to Zip file -->
<Target Name="PublishZip" AfterTargets="Publish">
<PropertyGroup >
<PowerShellScript>-File "D:\Visual Studio\Source\PowerShell\PublishZip\PubZipEx.ps1"</PowerShellScript>
<Name>-name "Windows Update Viewer"</Name>
<Version>-version $(AssemblyVersion)</Version>
<Path>-path "$(ProjectDir)"</Path>
<PublishFolder>-pubDir $(PublishDir)</PublishFolder>
</PropertyGroup>

<Target Name="CompileSetup" AfterTargets="PublishZip">
<PropertyGroup>
<PowerShellScript>-File "D:\Visual Studio\Source\PowerShell\PublishInnoSetup\PubSetup.ps1"</PowerShellScript>
<ScriptName>-issScript "$(ProjectDir)Inno_Setup\WUView.iss"</ScriptName>
</PropertyGroup>
<Exec Command="pwsh -NoProfile $(PowerShellScript) $(ScriptName)" />
</Target>
<!-- This is the framework dependent version -->
<PropertyGroup Condition="'$(PublishDir.Contains(`Framework_Dependent`))'">
<PubType>-pubType ""</PubType>
</PropertyGroup>

<!-- This is the x64 self contained version-->
<PropertyGroup Condition="'$(PublishDir.Contains(`Self_Contained_x64`))'">
<PubType>-pubType SC_x64</PubType>
</PropertyGroup>

<!-- This is the x86 self contained version-->
<PropertyGroup Condition="'$(PublishDir.Contains(`Self_Contained_x86`))'">
<PubType>-pubType SC_x86</PubType>
</PropertyGroup>

<!-- Execute the PowerShell script -->
<Exec Command="pwsh -NoProfile $(PowerShellScript) $(Name) $(Version) $(PubType) $(PublishFolder) $(Path)"/>
</Target>

<!-- Publish to Inno Setup installer-->
<Target Name="CompileSetup" AfterTargets="PublishZip">
<PropertyGroup>
<PowerShellScript>-File "D:\Visual Studio\Source\PowerShell\PublishInnoSetup\PubSetupEx.ps1"</PowerShellScript>
<ScriptName>-issScript "$(ProjectDir)Inno_Setup\WUViewEx.iss"</ScriptName>
</PropertyGroup>

<!-- This is the framework dependent version -->
<PropertyGroup Condition="'$(PublishDir.Contains(`Framework_Dependent`))'">
<PubType>-publishType ""</PubType>
</PropertyGroup>

<!-- This is the x64 self contained version-->
<PropertyGroup Condition="'$(PublishDir.Contains(`Self_Contained_x64`))'">
<PubType>-publishType SC_x64</PubType>
</PropertyGroup>

<!-- This is the x86 self contained version-->
<PropertyGroup Condition="'$(PublishDir.Contains(`Self_Contained_x86`))'">
<PubType>-publishType SC_x86</PubType>
</PropertyGroup>

<!-- Execute the PowerShell script -->
<Exec Command="pwsh -NoProfile $(PowerShellScript) $(ScriptName) $(PublishDir) $(PubType) " />
</Target>
</Project>

0 comments on commit a7f3c84

Please sign in to comment.