-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d017796
commit d4609f3
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/Wissance.Zerial/Wissance.Zerial.WinInstaller.Bootstrap/HttpClientUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/Wissance.Zerial/Wissance.Zerial.WinInstaller.Bootstrap/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...rial/Wissance.Zerial.WinInstaller.Bootstrap/Wissance.Zerial.WinInstaller.Bootstrap.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters