diff --git a/WUView/Inno_Setup/WUViewEx.iss b/WUView/Inno_Setup/WUViewEx.iss new file mode 100644 index 0000000..5b301e1 --- /dev/null +++ b/WUView/Inno_Setup/WUViewEx.iss @@ -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; diff --git a/WUView/Properties/PublishProfiles/Framework_Dependent.pubxml b/WUView/Properties/PublishProfiles/Framework_Dependent.pubxml new file mode 100644 index 0000000..430fcbc --- /dev/null +++ b/WUView/Properties/PublishProfiles/Framework_Dependent.pubxml @@ -0,0 +1,13 @@ + + + + + Release + Any CPU + bin\Framework_Dependent + FileSystem + <_TargetId>Folder + + \ No newline at end of file diff --git a/WUView/Properties/PublishProfiles/Self_Contained_x64.pubxml b/WUView/Properties/PublishProfiles/Self_Contained_x64.pubxml new file mode 100644 index 0000000..60a20a2 --- /dev/null +++ b/WUView/Properties/PublishProfiles/Self_Contained_x64.pubxml @@ -0,0 +1,19 @@ + + + + + Release + Any CPU + bin\Self_Contained_x64 + FileSystem + <_TargetId>Folder + net6.0-windows + win-x64 + true + false + false + false + + \ No newline at end of file diff --git a/WUView/Properties/PublishProfiles/Self_Contained_x86.pubxml b/WUView/Properties/PublishProfiles/Self_Contained_x86.pubxml new file mode 100644 index 0000000..6630dbc --- /dev/null +++ b/WUView/Properties/PublishProfiles/Self_Contained_x86.pubxml @@ -0,0 +1,19 @@ + + + + + Release + Any CPU + bin\Self_Contained_x86 + FileSystem + <_TargetId>Folder + net6.0-windows + win-x86 + true + false + false + false + + \ No newline at end of file diff --git a/WUView/WUView.csproj b/WUView/WUView.csproj index 9500d2b..f6d0678 100644 --- a/WUView/WUView.csproj +++ b/WUView/WUView.csproj @@ -12,6 +12,9 @@ Windows Update Viewer Images\UV.ico en-US + False + False + False @@ -63,21 +66,58 @@ - - - -File "D:\Visual Studio\Source\PowerShell\PublishZip\PubZip.ps1" - -name "Windows Update Viewer" - -version $(AssemblyVersion) - -path "$(ProjectDir)" - - - + + + + -File "D:\Visual Studio\Source\PowerShell\PublishZip\PubZipEx.ps1" + -name "Windows Update Viewer" + -version $(AssemblyVersion) + -path "$(ProjectDir)" + -pubDir $(PublishDir) + - - - -File "D:\Visual Studio\Source\PowerShell\PublishInnoSetup\PubSetup.ps1" - -issScript "$(ProjectDir)Inno_Setup\WUView.iss" - - - + + + -pubType "" + + + + + -pubType SC_x64 + + + + + -pubType SC_x86 + + + + + + + + + + -File "D:\Visual Studio\Source\PowerShell\PublishInnoSetup\PubSetupEx.ps1" + -issScript "$(ProjectDir)Inno_Setup\WUViewEx.iss" + + + + + -publishType "" + + + + + -publishType SC_x64 + + + + + -publishType SC_x86 + + + + + \ No newline at end of file