Skip to content

Commit

Permalink
bootsrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilLord666 committed Feb 25, 2024
1 parent d017796 commit d4609f3
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Wissance.Zerial.WinInstaller.Bootstrap
{
public static class HttpClientUtils
{
public static async Task DownloadFileTaskAsync(this HttpClient client, Uri uri, string fileName)
{
if (File.Exists(fileName))
File.Delete(fileName);
using (Stream s = await client.GetStreamAsync(uri))
{
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
await s.CopyToAsync(fs);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Diagnostics;

namespace Wissance.Zerial.WinInstaller.Bootstrap
{
public class Program
{
public static async Task Main(string[] args)
{
// 1. Download .exe installer depends on OS/CPU architecture
string installerUrl = Environment.Is64BitOperatingSystem ? WinX64Installer : WinX86Installer;
string fileName = "Wissance.Zerial.Installer.exe";
string fullFilePath = Path.GetFullPath(".", fileName);

using (HttpClient client = new HttpClient())
{
await client.DownloadFileTaskAsync(new Uri(installerUrl), fullFilePath);
}

// 2. Run installer silently
Process installerProcess = Process.Start(fullFilePath, @"\SILENT");
installerProcess.Close();
installerProcess.Dispose();

}

private const string WinX64Installer = "https://github.com/Wissance/Zerial/raw/master/app/Wissance.Zerial/Wissance.Zerial.Installer/Windows/Wissance.Zerial.Win.X64.exe";
private const string WinX86Installer = "https://github.com/Wissance/Zerial/raw/master/app/Wissance.Zerial/Wissance.Zerial.Installer/Windows/Wissance.Zerial.Win.X86.exe";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
18 changes: 18 additions & 0 deletions app/Wissance.Zerial/Wissance.Zerial.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wissance.Zerial.Desktop", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wissance.Zerial.Common", "Wissance.Zerial.Common\Wissance.Zerial.Common.csproj", "{7D078E35-1775-458B-A943-9EA4F8250159}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wissance.Zerial.WinInstaller.Bootstrap", "Wissance.Zerial.WinInstaller.Bootstrap\Wissance.Zerial.WinInstaller.Bootstrap.csproj", "{D753676C-2012-49B7-9722-105A66960E89}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -51,6 +53,22 @@ Global
{7D078E35-1775-458B-A943-9EA4F8250159}.Release|x64.Build.0 = Release|Any CPU
{7D078E35-1775-458B-A943-9EA4F8250159}.Release|x86.ActiveCfg = Release|Any CPU
{7D078E35-1775-458B-A943-9EA4F8250159}.Release|x86.Build.0 = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|ARM64.Build.0 = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|x64.ActiveCfg = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|x64.Build.0 = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|x86.ActiveCfg = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Debug|x86.Build.0 = Debug|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|Any CPU.Build.0 = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|ARM64.ActiveCfg = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|ARM64.Build.0 = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|x64.ActiveCfg = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|x64.Build.0 = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|x86.ActiveCfg = Release|Any CPU
{D753676C-2012-49B7-9722-105A66960E89}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit d4609f3

Please sign in to comment.