Skip to content

Commit 7e0e9cf

Browse files
committed
installer(WIP) and support nativeaot build
1 parent a7229af commit 7e0e9cf

11 files changed

+87
-7
lines changed

.nuke/build.schema.json

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"type": "string",
7272
"enum": [
7373
"Archive",
74+
"BuildInstaller",
7475
"BuildInstallerBinary",
7576
"Clean",
7677
"Compile",
@@ -88,6 +89,7 @@
8889
"type": "string",
8990
"enum": [
9091
"Archive",
92+
"BuildInstaller",
9193
"BuildInstallerBinary",
9294
"Clean",
9395
"Compile",

WEventViewer.Installer/Folders.wxs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2+
<Fragment>
3+
<StandardDirectory Id="ProgramFiles6432Folder">
4+
<Directory Id="INSTALLFOLDER" Name="!(bind.Property.ProductName)">
5+
</Directory>
6+
</StandardDirectory>
7+
<StandardDirectory Id="ProgramMenuFolder">
8+
<Directory Id="MyShortcutFolder" Name="!(bind.Property.ProductName)"/>
9+
</StandardDirectory>
10+
</Fragment>
11+
</Wix>
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!--
2+
This file contains the declaration of all the localizable strings.
3+
-->
4+
<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
5+
6+
<String Id="DowngradeError" Value="A newer version of [ProductName] is already installed." />
7+
8+
</WixLocalization>

WEventViewer.Installer/Package.wxs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2+
<Package Name="WEventViewer" Manufacturer="itn3000" Version="1.0.0.0" UpgradeCode="61e8e723-2259-43eb-b767-cec8a5b7db1f">
3+
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
4+
5+
<Feature Id="Main">
6+
<ComponentGroupRef Id="WEventViewerComponent" />
7+
<ComponentGroupRef Id="WEventViewerShortcutGroup"/>
8+
9+
</Feature>
10+
</Package>
11+
</Wix>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="WixToolset.Sdk/5.0.1">
2+
<PropertyGroup Condition="'$(ExeArch)' == ''">
3+
<ExeArch>win-x64</ExeArch>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<BindPath Include="$(MSBuildThisFileDirectory)..\dist\publish\$(Configuration)\$(ExeArch)\WEventViewer">
7+
<BindName>bin</BindName>
8+
</BindPath>
9+
</ItemGroup>
10+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3+
<Fragment>
4+
<ComponentGroup Id="WEventViewerComponent" Directory="INSTALLFOLDER">
5+
<Component Id="WEventViewerExe" Guid="{2A695591-0376-4A46-8119-0BA0B862D63B}">
6+
<File Id="WEventViewer.exe" KeyPath="yes" Source="!(bindpath.bin)\WEventViewer.exe">
7+
8+
</File>
9+
</Component>
10+
</ComponentGroup>
11+
<ComponentGroup Id="WEventViewerShortcutGroup" Directory="MyShortcutFolder">
12+
<Component Id="WEventViewerShortcut" Guid="{983A88F9-ECF3-471F-9837-3CAD1F5654C4}">
13+
<Shortcut Id="WEventViewer.lnk" Name="!(bind.Property.ProductName)" Directory="MyShortcutFolder" Target=""/>
14+
</Component>
15+
</ComponentGroup>
16+
</Fragment>
17+
</Wix>

WEventViewer.sln

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{230BCF21-943
1919
README.md = README.md
2020
EndProjectSection
2121
EndProject
22-
Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "WEventViewer.Msi", "WEventViewer.Msi\WEventViewer.Msi.wixproj", "{61D89AD6-426B-4A48-998D-413309FE3A4D}"
22+
Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "WEventViewer.Installer", "WEventViewer.Installer\WEventViewer.Installer.wixproj", "{61D89AD6-426B-4A48-998D-413309FE3A4D}"
2323
EndProject
2424
Global
2525
GlobalSection(SolutionConfigurationPlatforms) = preSolution

build/Build.cs

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ partial class Build : NukeBuild, NativeBuild, Installer
6767
var outdir = GetPublishOutputDirectory();
6868
outdir.ZipTo(outdir.Parent / $"WEventViewer-{Runtime}.zip", fileMode: System.IO.FileMode.Create);
6969
});
70+
Target BuildInstaller => _ => _
71+
.DependsOn(Publish, ((Installer)this).BuildInstallerBinary)
72+
;
73+
7074
AbsolutePath GetPublishOutputDirectory()
7175
{
7276
return RootDirectory / "dist" / "publish" / Configuration / Runtime / "WEventViewer";

build/Installer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ interface Installer : INukeBuild
1414
{
1515
[Parameter]
1616
public string Configuration => TryGetValue(() => Configuration) ?? "Release";
17-
public Target BuildInstallerBinary => _ => _
17+
Target BuildInstallerBinary => _ => _
1818
.Executes(() =>
1919
{
20-
var project = RootDirectory / "WEventViewer.Msi" / "WEventViewer.Msi.wixproj";
20+
var project = RootDirectory / "WEventViewer.Installer" / "WEventViewer.Installer.wixproj";
2121
DotNetBuild(cfg => cfg.SetProjectFile(project)
2222
.SetProcessWorkingDirectory(project.Parent)
2323
.SetConfiguration(Configuration));

src/WEventViewer/DetailedLogMessageWIndow.axaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828
HeadersVisibility="Column"
2929
CanUserReorderColumns="True"
3030
CanUserResizeColumns="True"
31-
AutoGenerateColumns="True"
31+
AutoGenerateColumns="False"
3232
>
33-
33+
<DataGrid.Columns>
34+
<DataGridTextColumn Header="Key" Binding="{Binding Key}"/>
35+
<DataGridTextColumn Header="Value" Binding="{Binding Value}"/>
36+
</DataGrid.Columns>
3437
</DataGrid>
3538
</ScrollViewer>
3639
</TabItem>

src/WEventViewer/ViewModel/DetailedLogViewModel.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111

1212
namespace WEventViewer.ViewModel
1313
{
14+
internal class DetailedLogRecordValue
15+
{
16+
17+
public string Key { get; set; } = string.Empty;
18+
public string? Value { get; set; } = null;
19+
public DetailedLogRecordValue() : this("", null)
20+
{
21+
}
22+
public DetailedLogRecordValue(string key, string? value)
23+
{
24+
this.Key = key;
25+
this.Value = value;
26+
}
27+
}
1428
internal class DetailedLogViewModel
1529
{
1630
public DetailedLogViewModel() : this(null)
@@ -36,7 +50,7 @@ public DetailedLogViewModel(LogRecord? logRecord)
3650
}
3751
if(logRecord != null)
3852
{
39-
Items = new KeyValuePair<string, string?>[]
53+
Items = new DetailedLogRecordValue[]
4054
{
4155
new("Id", logRecord.Id.ToString()),
4256
new("RecordId", logRecord.RecordId?.ToString()),
@@ -54,7 +68,7 @@ public DetailedLogViewModel(LogRecord? logRecord)
5468
};
5569
}
5670
}
57-
public KeyValuePair<string, string?>[] Items { get; private set; } = Array.Empty<KeyValuePair<string, string?>>();
71+
public IEnumerable<DetailedLogRecordValue> Items { get; private set; } = Array.Empty<DetailedLogRecordValue>();
5872
string _FormattedXmlString;
5973
public string XmlString => _FormattedXmlString;
6074
public string? FormattedString => logRecord?.Formatted;

0 commit comments

Comments
 (0)