This repository has been archived by the owner on Jan 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
134 lines (115 loc) · 5.4 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using BLAZAM.Server;
using Microsoft.Deployment.WindowsInstaller;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using System.Runtime.CompilerServices;
using System.Windows.Controls;
using System.Windows.Forms;
using WixSharp;
using WixSharp.Bootstrapper;
using WixSharp.CommonTasks;
using WixSharp.UI.WPF;
namespace Setup
{
internal class Program
{
private const string SourcePath = @"..\BLAZAM\bin\Release\net6.0\publish\";
public static string DestinationPath = @"%ProgramFiles%\Blazam Server\";
public static File service;
static void Main()
{
//_ = AspNetCore6();
var msi = BuildMsi();
/*
var bootstrapper =
new Bundle("SampleInstaller",
AspNetCore6(),
new MsiPackage(msi) { DisplayInternalUI = true, Compressed = true })
{
UpgradeCode = new Guid("c14f14eb-6a0a-4969-a94e-3d2aa19b3ec4"),
Version = new Version(1, 0, 0, 0),
};
bootstrapper.IncludeWixExtension(WixExtension.Util);
bootstrapper.AddWixFragment("Wix/Bundle",
new UtilRegistrySearch
{
Root = WixSharp.RegistryHive.LocalMachine,
Key = @"SOFTWARE\WOW6432Node\Microsoft\Updates\.NET\Microsoft .NET *",
Value = "PackageVersion",
Variable = "NetVersion"
});
bootstrapper.Build("Install.exe");
*/
}
private static string BuildMsi()
{
var project = new ManagedProject("BLAZAM",
new ManagedAction(ApplyAppSettingsAction.Apply, Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed),
new Dir(DestinationPath,
new Files(SourcePath+"*"),
service = new File(SourcePath + "blazam.exe")));
project.ManagedUI = ManagedUI.Default;
project.ControlPanelInfo.NoModify = true;
project.ControlPanelInfo.Manufacturer = "BlazamApp";
project.ControlPanelInfo.Name = "Blazam";
project.InstallPrivileges = InstallPrivileges.elevated;
project.InstallScope = InstallScope.perMachine;
project.LicenceFile = SourcePath + "license.rtf";
project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");
project.UpgradeCode = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");
project.ProductId = Guid.NewGuid();
project.EnableUninstallFullUI();
// project.GenerateProductGuids();
service.ServiceInstaller = new ServiceInstaller
{
Name = "Blazam Server",
Account = ".\\LOCAL_SERVICE",
StartOn = SvcEvent.Install,
StopOn = SvcEvent.InstallUninstall_Wait,
RemoveOn = SvcEvent.Uninstall_Wait
};
// project.ManagedUI = ManagedUI.DefaultWpf; // all stock UI dialogs
//custom set of UI WPF dialogs
project.ManagedUI = new ManagedUI();
project.ManagedUI.InstallDialogs.Add<Setup.WelcomeDialog>()
.Add<Setup.LicenceDialog>()
.Add<WixSharpSetup.InstallationType>()
.Add<WixSharpSetup.ServiceSettings>()
.Add<WixSharpSetup.AspHostingDialog>()
.Add<WixSharpSetup.NetCoreDialog>()
.Add<Setup.InstallDirDialog>()
.Add<WixSharpSetup.DatabaseDialog>()
.Add<WixSharpSetup.ConfirmInstallDialog>()
.Add<Setup.ProgressDialog>()
.Add<Setup.ExitDialog>();
project.ManagedUI.ModifyDialogs.Add<Setup.MaintenanceTypeDialog>()
.Add<Setup.FeaturesDialog>()
.Add<Setup.ProgressDialog>()
.Add<Setup.ExitDialog>();
//project.SourceBaseDir = "<input dir path>";
//project.OutDir = "<output dir path>";
return project.BuildMsi();
}
private static ExePackage AspNetCore6()
{
string aspLink =
@"https://download.visualstudio.microsoft.com/download/pr/0cb3c095-c4f4-4d55-929b-3b4888a7b5f1/4156664d6bfcb46b63916a8cd43f8305/dotnet-hosting-6.0.13-win.exe";
string aspInstaller = "dotnet-hosting-win.exe";
using (var client = new WebClient())
{
client.DownloadFile(aspLink, aspInstaller);
}
ExePackage Net471exe = new ExePackage(aspInstaller)
{
Compressed = true,
Vital = false,
Name = aspInstaller,
PerMachine = true,
Permanent = true,
};
return Net471exe;
}
}
}