Updated to include new dir, inclusion of tags. Version appears in Control Panel now. Also appears in TItlebar of AppWindow.

This commit is contained in:
2025-10-10 14:32:49 +08:00
parent bab6cf7b75
commit 62cf2425b1
4 changed files with 170 additions and 83 deletions

View File

@@ -1,32 +1,46 @@
<!-- <!--
This file allow for customizing your build process. This file allows for customizing your build process.
See: https://learn.microsoft.com/visualstudio/msbuild/customize-your-build See: https://learn.microsoft.com/visualstudio/msbuild/customize-your-build
--> -->
<Project> <Project>
<!--
Uncomment if you need to enable inclusion of another Directory.Build.props file from a parent directory
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
-->
<PropertyGroup> <PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<LangVersion>12</LangVersion> <LangVersion>12</LangVersion>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio> <AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<!--
If you you like to see source generated files saved to disk you can enable the following:
https://learn.microsoft.com/dotnet/csharp/roslyn-sdk/source-generators-overview?WT.mc_id=DT-MVP-5003472
-->
<!--<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>--> <!--<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>-->
</PropertyGroup> </PropertyGroup>
<!--
This allows all projects to share the same user secrets file.
If you want project to have their own, set it to a different GUID on each project.
See: https://learn.microsoft.com/dotnet/architecture/microservices/secure-net-microservices-web-applications/developer-app-secrets-storage
-->
<PropertyGroup Label="User Secrets"> <PropertyGroup Label="User Secrets">
<UserSecretsId>1ef91ee6-7b55-474e-ab2b-2d164b723a56</UserSecretsId> <UserSecretsId>1ef91ee6-7b55-474e-ab2b-2d164b723a56</UserSecretsId>
</PropertyGroup> </PropertyGroup>
</Project>
<!-- 🔹 Automatically derive version from latest Git tag -->
<Target Name="GetVersionFromGit" BeforeTargets="GetAssemblyVersion">
<!-- Get the most recent tag (like v1.1.1) -->
<Exec Command="git describe --tags --abbrev=0" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitTag" />
</Exec>
<!-- Strip leading 'v' if present -->
<PropertyGroup>
<GitVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(GitTag)', '^v', ''))</GitVersion>
</PropertyGroup>
<!-- Fallback if no tags exist yet -->
<PropertyGroup Condition="'$(GitVersion)' == ''">
<GitVersion>0.0.0</GitVersion>
</PropertyGroup>
<!-- Apply to assembly and file versions -->
<Message Text="🔖 Using version: $(GitVersion)" Importance="High" />
<PropertyGroup>
<Version>$(GitVersion)</Version>
<FileVersion>$(GitVersion)</FileVersion>
<AssemblyVersion>$(GitVersion)</AssemblyVersion>
</PropertyGroup>
</Target>
</Project>

View File

@@ -57,8 +57,24 @@ namespace LD_SysInfo
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
InitializeComponent(); InitializeComponent();
var fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); var exePath = Assembly.GetEntryAssembly()?.Location;
VersionTextBlock.Text = $"v{fvi.ProductVersion}";
if (string.IsNullOrEmpty(exePath))
{
exePath = Process.GetCurrentProcess().MainModule?.FileName;
}
if (!string.IsNullOrEmpty(exePath))
{
var fvi = FileVersionInfo.GetVersionInfo(exePath);
var productVersion = fvi.ProductVersion ?? "0.0.0";
var cleanVersion = productVersion.Split('+')[0];
VersionTextBlock.Text = $"v{cleanVersion}";
}
else
{
VersionTextBlock.Text = "v0.0.0";
}
LoadConfig(); LoadConfig();
DisplaySystemInfo(); DisplaySystemInfo();
AutoLogin(); AutoLogin();

View File

@@ -1,34 +1,56 @@
<Project Sdk="WixToolset.Sdk/6.0.0"> <Project Sdk="WixToolset.Sdk/6.0.0">
<ItemGroup>
<PackageReference Include="WixToolset.UI.wixext" /> <!-- ✅ Defaults -->
</ItemGroup> <PropertyGroup>
<PropertyGroup> <Version>0.0.0</Version>
<!-- Force embedding files into the MSI (no external .cab file) --> <Platform>x64</Platform>
<EmbedCab>true</EmbedCab> <InstallerPlatform>x64</InstallerPlatform>
</PropertyGroup> <EmbedCab>true</EmbedCab>
<PropertyGroup> <WixExtensionInclude>WixToolset.UI.wixext</WixExtensionInclude>
<WixExtensionInclude>WixToolset.UI.wixext</WixExtensionInclude> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <!-- ✅ STEP 1: Run Git BEFORE WiX compilation -->
<DefineConstants>PublishDir=C:\Users\Sonder\source\repos\psg-oversight-app\PublishDir</DefineConstants> <Target Name="SetVersionFromGit" BeforeTargets="BeforeBuild">
</PropertyGroup> <Exec Command="git describe --tags --abbrev=0" ConsoleToMSBuild="true" IgnoreExitCode="true">
<ItemGroup> <Output TaskParameter="ConsoleOutput" PropertyName="GitTag" />
<Content Include="Assets\DLShortcut.ico"> </Exec>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> <PropertyGroup Condition="'$(GitTag)' != ''">
<Content Include="Assets\trayicon.ico"> <GitTagTrimmed>$([System.Text.RegularExpressions.Regex]::Replace('$(GitTag)', '\s', ''))</GitTagTrimmed>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <GitVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(GitTagTrimmed)', '^v', ''))</GitVersion>
</Content> <Version>$(GitVersion)</Version>
</ItemGroup> </PropertyGroup>
<ItemGroup>
<WixSource Include="HarvestedFiles.wxs" /> <PropertyGroup>
</ItemGroup> <DefineConstants>
<ItemGroup> Version=$(Version);
<Content Include="bpl.rtf"> PublishDir=C:\Users\Sonder\source\repos\psg-oversight-app\PublishDir
<CopyToOutputDirectory>Always</CopyToOutputDirectory> </DefineConstants>
</Content> <OutputName>OversightInstaller_$(Version)_$(Platform)</OutputName>
</ItemGroup> </PropertyGroup>
<ItemGroup>
<None Include="Assets\windowsdesktop-runtime-8.0.13-win-x64.exe" /> <Message Text="📦 Building OversightInstaller version $(Version)" Importance="high" />
</ItemGroup> <Message Text="📦 WiX DefineConstants=$(DefineConstants)" Importance="high" />
</Project> </Target>
<!-- ✅ STEP 2: Rename the MSI after build -->
<Target Name="RenameMsi" AfterTargets="Build">
<PropertyGroup>
<BuiltMsi>$(OutputPath)OversightInstaller_$(Version)_$(Platform).msi</BuiltMsi>
<ActualMsi>$(OutputPath)OversightInstaller.msi</ActualMsi>
</PropertyGroup>
<Message Text="📦 Renaming $(ActualMsi) → $(BuiltMsi)" Importance="high" />
<Exec Command="move /Y &quot;$(ActualMsi)&quot; &quot;$(BuiltMsi)&quot;" />
</Target>
<ItemGroup>
<PackageReference Include="WixToolset.UI.wixext" />
<WixSource Include="HarvestedFiles.wxs" />
<Content Include="Assets\DLShortcut.ico" CopyToOutputDirectory="Always" />
<Content Include="Assets\trayicon.ico" CopyToOutputDirectory="Always" />
<Content Include="bpl.rtf" CopyToOutputDirectory="Always" />
<None Include="Assets\windowsdesktop-runtime-8.0.13-win-x64.exe" />
</ItemGroup>
</Project>

View File

@@ -1,39 +1,54 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"> xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="Oversight" Manufacturer="Paragon Systems Group" Version="1.0.0.0" UpgradeCode="e0e26d46-ed26-425e-a1bb-9bc76523ae6b"> <!-- ✅ Safe default in case $(var.Version) is undefined -->
<MajorUpgrade DowngradeErrorMessage="A newer version of this application is already installed." /> <?ifndef Version?>
<?define Version="0.0.0"?>
<?endif?>
<WixVariable <Package
Id="WixUILicenseRtf" Name="Oversight"
Value="bpl.rtf" Manufacturer="Paragon Systems Group"
/> Version="$(var.Version)"
<!-- 🔍 Properties --> UpgradeCode="e0e26d46-ed26-425e-a1bb-9bc76523ae6b">
<Property Id="ARPPRODUCTICON" Value="DLShortcutIcon" />
<Property Id="SERVER_URL" Value="http://your-default-server/api/register" /> <Property Id="DisplayVersion" Value="$(var.Version)" />
<!-- 🔁 Automatic major-upgrade behavior -->
<MajorUpgrade DowngradeErrorMessage="A newer version of this application is already installed." />
<!-- ✅ Only define custom ARP metadata that isnt built-in -->
<Property Id="ARPPRODUCTICON" Value="DLShortcutIcon" />
<Property Id="ARPHELPLINK" Value="https://psg.net.au/" />
<Property Id="ARPCONTACT" Value="support@psg.net.au" />
<Property Id="ARPINSTALLLOCATION" Value="[INSTALLFOLDER]" />
<!-- Optional custom properties -->
<Property Id="SERVER_URL" Value="http://your-default-server/api/register" />
<Property Id="APP_EXECUTABLE" Value="PSG-Oversight.exe" /> <Property Id="APP_EXECUTABLE" Value="PSG-Oversight.exe" />
<!-- 💬 EULA -->
<WixVariable Id="WixUILicenseRtf" Value="bpl.rtf" />
<!-- 🔧 UI --> <!-- 🔧 UI -->
<ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLFOLDER" /> <ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLFOLDER" />
<!-- 🎨 Icon for Add/Remove Programs --> <!-- 🎨 Icon for Add/Remove Programs -->
<Icon Id="DLShortcutIcon" SourceFile="Assets\DLShortcut.ico" /> <Icon Id="DLShortcutIcon" SourceFile="Assets\DLShortcut.ico" />
<!-- 📂 Installation Directory --> <!-- 📂 Installation Directory -->
<StandardDirectory Id="ProgramFiles64Folder"> <StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Oversight"> <Directory Id="PSGROOT" Name="PSG">
<Directory Id="INSTALLFOLDER" Name="Oversight">
<!-- Your files and harvested components go here -->
</Directory>
</Directory>
</StandardDirectory>
<!-- 📦 Application Files -->
<ComponentGroupRef Id="AppFiles" />
<!-- 📁 Assets Folder --> <!-- 📁 Start Menu Shortcut -->
</Directory>
</StandardDirectory>
<ComponentGroupRef Id="AppFiles" />
<!-- 📁 Start Menu Shortcut -->
<StandardDirectory Id="ProgramMenuFolder"> <StandardDirectory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Oversight"> <Directory Id="ApplicationProgramsFolder" Name="Oversight">
<Component Id="StartMenuShortcutComponent" Guid="4C5466A9-CE33-48AE-B80C-08915A864DF2"> <Component Id="StartMenuShortcutComponent" Guid="4C5466A9-CE33-48AE-B80C-08915A864DF2">
@@ -46,19 +61,39 @@
IconIndex="0" /> IconIndex="0" />
<RemoveFile Id="RemoveStartMenuShortcut" Name="Oversight.lnk" On="uninstall" /> <RemoveFile Id="RemoveStartMenuShortcut" Name="Oversight.lnk" On="uninstall" />
<RemoveFolder Id="RemoveStartMenuFolder" On="uninstall" /> <RemoveFolder Id="RemoveStartMenuFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Oversight" Name="StartMenuShortcut" Type="integer" Value="1" KeyPath="yes"/> <RegistryValue Root="HKCU" Key="Software\Oversight"
Name="StartMenuShortcut" Type="integer" Value="1" KeyPath="yes"/>
</Component> </Component>
</Directory> </Directory>
</StandardDirectory> </StandardDirectory>
<!-- 📦 Feature References --> <!-- 64-bit component so ARP keys go to HKLM\Software (not Wow6432Node) -->
<Feature Id="Main" Title="DL SysInfo" Level="1"> <Component Id="AppMetadata" Guid="E62354E8-3C7B-4B13-AFE2-A1E65A7F2E77" Bitness="always64">
<ComponentGroupRef Id="AppFiles" /> <RegistryKey
<ComponentRef Id="StartMenuShortcutComponent" /> Root="HKLM"
</Feature> Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductCode]">
<!-- 💿 Media --> <!-- Nice, branded ARP entry -->
<Media Id="1" Cabinet="embedded.cab" EmbedCab="yes" /> <RegistryValue Name="DisplayName" Value="Oversight" Type="string" />
<RegistryValue Name="Publisher" Value="Paragon Systems Group" Type="string" />
<!-- Make version show in Control Panel; compile-time value from your wixproj -->
<RegistryValue Name="DisplayVersion" Value="$(var.Version)" Type="string" KeyPath="yes" />
</RegistryKey>
</Component>
</Package>
<!-- 🧱 Primary Feature -->
<Feature Id="Main" Title="DL SysInfo" Level="1">
<ComponentGroupRef Id="AppFiles" />
<ComponentRef Id="StartMenuShortcutComponent" />
<ComponentRef Id="AppMetadata" />
</Feature>
<!-- 💿 Media -->
<Media Id="1" Cabinet="embedded.cab" EmbedCab="yes" />
</Package>
</Wix> </Wix>