forked from LANraragi/Karen
Fix most issues with the Setup project
This commit is contained in:
parent
d7f302e097
commit
0c47d34174
@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Microsoft.Deployment.WindowsInstaller;
|
||||
using WixSharp;
|
||||
using WixSharp.CommonTasks;
|
||||
using WixSharp.Controls;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using File = WixSharp.File;
|
||||
|
||||
namespace Setup
|
||||
{
|
||||
@ -28,34 +31,27 @@ namespace Setup
|
||||
new Files(@"..\External\LxRunOffline\*.*")),
|
||||
uninstallerShortcut
|
||||
),
|
||||
new ElevatedManagedAction(RegisterWslDistro,
|
||||
new Dir(@"%ProgramMenu%\LANraragi for Windows",
|
||||
new ExeFileShortcut("LANraragi", "[INSTALLDIR]Karen.exe", ""),
|
||||
new ExeFileShortcut("Uninstall LANraragi", "[System64Folder]msiexec.exe", "/x [ProductCode]")),
|
||||
new RegValue(RegistryHive.LocalMachineOrUsers, @"Software\Microsoft\Windows\CurrentVersion\Run", "Karen", "[INSTALLDIR]Karen.exe"),
|
||||
new ManagedAction(RegisterWslDistro,
|
||||
Return.check,
|
||||
When.After,
|
||||
Step.InstallFiles,
|
||||
Step.InstallFinalize,
|
||||
Condition.NOT_BeingRemoved),
|
||||
new ElevatedManagedAction(UnRegisterWslDistro,
|
||||
new ManagedAction(UnRegisterWslDistro,
|
||||
Return.check,
|
||||
When.Before,
|
||||
Step.RemoveFiles,
|
||||
Condition.BeingUninstalled)
|
||||
);
|
||||
|
||||
project.ResolveWildCards()
|
||||
.FindFile((f) => f.Name.EndsWith("Karen.exe"))
|
||||
.First()
|
||||
.Shortcuts = new[] {
|
||||
new FileShortcut("LANraragi for Windows", "INSTALLDIR"),
|
||||
new FileShortcut("LANraragi for Windows", "%Desktop%")
|
||||
};
|
||||
|
||||
project.GUID = new Guid("6fe30b47-2577-43ad-1337-1861ba25889b");
|
||||
project.Platform = Platform.x64;
|
||||
project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
|
||||
project.Version = Version.Parse("1.0.0.1"); //TODO: override by env var
|
||||
|
||||
// TODO: remove reg key on uninstall
|
||||
// Remove-ItemProperty -Name 'Karen' -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
|
||||
|
||||
// Check for x64 Windows 10
|
||||
project.LaunchConditions.Add(new LaunchCondition("VersionNT64","LANraragi for Windows can only be installed on a 64-bit Windows."));
|
||||
project.LaunchConditions.Add(new LaunchCondition("VersionNT>=\"603\"", "LANraragi for Windows can only be installed on Windows 10 and up."));
|
||||
@ -73,26 +69,41 @@ namespace Setup
|
||||
[CustomAction]
|
||||
public static ActionResult RegisterWslDistro(Session session)
|
||||
{
|
||||
UnRegisterWslDistro(session);
|
||||
#if DEBUG
|
||||
System.Diagnostics.Debugger.Launch();
|
||||
#endif
|
||||
MessageBox.Show("The WSL Distro will now be installed on your system. You should see one or two cmd windows.");
|
||||
|
||||
var result = UnRegisterWslDistro(session);
|
||||
|
||||
if (session.IsUninstalling())
|
||||
return ActionResult.Success;
|
||||
return result;
|
||||
|
||||
var packageLocation = session.Property("INSTALLDIR") + @"\package.tar";
|
||||
var packageLocation = session.Property("INSTALLDIR") + @"package.tar";
|
||||
var lxRunLocation = session.Property("INSTALLDIR") + @"LxRunOffline";
|
||||
var distroLocation = session.Property("INSTALLDIR") + @"Distro";
|
||||
var distroLocation = @"%AppData%\LANraragi\Distro";
|
||||
|
||||
Directory.CreateDirectory(distroLocation);
|
||||
|
||||
return session.HandleErrors(() =>
|
||||
{
|
||||
// Use LxRunOffline to either install or uninstall the WSL distro.
|
||||
session.Log("Installing WSL Distro from package.tar");
|
||||
var lxProc = Process.Start(lxRunLocation + @"\LxRunOffline.exe", "i -n lanraragi -d " + distroLocation + " -f " + packageLocation);
|
||||
lxProc.OutputDataReceived += (s, e) => session.Log(e.Data);
|
||||
lxProc.ErrorDataReceived += (s, e) => session.Log(e.Data);
|
||||
session.Log("LxRunOffline location: " + lxRunLocation);
|
||||
session.Log("package.tar location: " + packageLocation);
|
||||
|
||||
var lxProc = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "cmd",
|
||||
Arguments = "/K " + lxRunLocation + @"\LxRunOffline.exe i -n lanraragi -d " + distroLocation + " -f " + packageLocation + " && pause && exit"
|
||||
}
|
||||
};
|
||||
|
||||
lxProc.Start();
|
||||
lxProc.WaitForExit();
|
||||
|
||||
session.Log("Removing package.tar");
|
||||
System.IO.File.Delete(packageLocation);
|
||||
session.Log("Exit code of LxRunOffline is " + lxProc.ExitCode);
|
||||
});
|
||||
}
|
||||
|
||||
@ -103,8 +114,6 @@ namespace Setup
|
||||
{
|
||||
session.Log("Removing previous WSL Distro");
|
||||
var wslProc = Process.Start("wslconfig.exe", "/unregister lanraragi");
|
||||
wslProc.OutputDataReceived += (s, e) => session.Log(e.Data);
|
||||
wslProc.ErrorDataReceived += (s, e) => session.Log(e.Data);
|
||||
wslProc.WaitForExit();
|
||||
});
|
||||
}
|
||||
@ -112,7 +121,7 @@ namespace Setup
|
||||
[CustomAction]
|
||||
public static ActionResult ShowDialogIfWslDisabled(Session session)
|
||||
{
|
||||
return WixCLRDialog.ShowAsMsiDialog(new CustomDialog(session));
|
||||
return WixCLRDialog.ShowAsMsiDialog(new WslCheckDialog(session));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,11 +67,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="CustomDialog.cs">
|
||||
<Compile Include="WslCheckDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CustomDialog.Designer.cs">
|
||||
<DependentUpon>CustomDialog.cs</DependentUpon>
|
||||
<Compile Include="WslCheckDialog.Designer.cs">
|
||||
<DependentUpon>WslCheckDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
@ -86,8 +86,8 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CustomDialog.resx">
|
||||
<DependentUpon>CustomDialog.cs</DependentUpon>
|
||||
<EmbeddedResource Include="WslCheckDialog.resx">
|
||||
<DependentUpon>WslCheckDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
|
@ -1,4 +1,4 @@
|
||||
partial class CustomDialog
|
||||
partial class WslCheckDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -26,7 +26,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomDialog));
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WslCheckDialog));
|
||||
this.cancelBtn = new System.Windows.Forms.Button();
|
||||
this.nextBtn = new System.Windows.Forms.Button();
|
||||
this.backBtn = new System.Windows.Forms.Button();
|
@ -5,16 +5,16 @@ using System.Windows.Forms;
|
||||
using Microsoft.Deployment.WindowsInstaller;
|
||||
using WixSharp;
|
||||
|
||||
public partial class CustomDialog : WixCLRDialog
|
||||
public partial class WslCheckDialog : WixCLRDialog
|
||||
{
|
||||
private string obj;
|
||||
|
||||
public CustomDialog()
|
||||
public WslCheckDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public CustomDialog(Session session)
|
||||
public WslCheckDialog(Session session)
|
||||
: base(session)
|
||||
{
|
||||
InitializeComponent();
|
Loading…
Reference in New Issue
Block a user