Skip to content

Commit

Permalink
CefSharp VC Redist
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Oct 9, 2023
1 parent 76901bb commit 26dfa7b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/Bundle/Sucrose.Bundle/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public partial class Main : Window

private static string Launcher => Path.Combine(InstallPath, Department, Executable);

private static string RedistPath => Path.Combine(Path.GetTempPath(), Redist);

private static string TemporaryFile => "Sucrose.Backgroundog.sys";

private static string TemporaryFolder => "Sucrose.Backgroundog";
Expand All @@ -58,6 +60,8 @@ public partial class Main : Window

private static string Publisher => "Taiizor";

private static string Redist => "Redist";

private static string Caches => "Caches";

private static int MaxDelay => 3000;
Expand Down Expand Up @@ -92,6 +96,39 @@ private void WindowCorner()
}
}

private static async Task InstallRedist()
{
string Command = $"/q /norestart";

#if X86
string Executable = Path.Combine(RedistPath, "x86.exe");
#elif ARM64
string Executable = Path.Combine(RedistPath, "arm64.exe");
#else
string Executable = Path.Combine(RedistPath, "x64.exe");
#endif

ProcessStartInfo Starter = new()
{
Arguments = Command,
FileName = Executable,
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true
};

using (Process Installer = new())
{
Installer.StartInfo = Starter;
Installer.Start();

Installer.WaitForExit();
}

await Task.CompletedTask;
}

private static void TerminateProcess(string Name)
{
#if NET48_OR_GREATER
Expand Down Expand Up @@ -148,7 +185,7 @@ private static async Task ControlDirectoryStable(string Location)
{
try
{
Directory.Delete(Record);
Directory.Delete(Record, true);
}
catch { }
}
Expand Down Expand Up @@ -250,11 +287,16 @@ private async void Window_ContentRendered(object sender, EventArgs e)

await Task.Delay(MaxDelay);

await ControlDirectory(RedistPath);
await ControlDirectory(PackagePath);
await ControlDirectoryStable(InstallPath);

await Task.Delay(MaxDelay);

await ExtractResources(Redist, RedistPath);

await Task.Delay(MinDelay);

await ExtractResources(Caches, PackagePath);

await Task.Delay(MinDelay);
Expand All @@ -263,6 +305,10 @@ private async void Window_ContentRendered(object sender, EventArgs e)

await Task.Delay(MaxDelay);

await InstallRedist();

await Task.Delay(MinDelay);

SWHS.Create(Desktop, Launcher, null, Path.GetDirectoryName(Launcher), null, Text);
SWHS.Create(StartMenu, Launcher, null, Path.GetDirectoryName(Launcher), null, Text);

Expand Down
Binary file added src/Bundle/Sucrose.Bundle/Redist/arm64.exe
Binary file not shown.
Binary file added src/Bundle/Sucrose.Bundle/Redist/x64.exe
Binary file not shown.
Binary file added src/Bundle/Sucrose.Bundle/Redist/x86.exe
Binary file not shown.
7 changes: 7 additions & 0 deletions src/Bundle/Sucrose.Bundle/Sucrose.Bundle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Redist\**">
<LogicalName>Redist\%(RecursiveDir)%(FileName)%(Extension)</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="..\..\Sucrose\Package\$(TargetFramework)\$(Platform)\**">
<LogicalName>Packages\%(RecursiveDir)%(FileName)%(Extension)</LogicalName>
</EmbeddedResource>
Expand All @@ -94,6 +97,10 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Remove="Redist\x64.exe" Condition="'$(PlatformTarget)' != 'x64'" />
<EmbeddedResource Remove="Redist\x86.exe" Condition="'$(PlatformTarget)' != 'x86'" />
<EmbeddedResource Remove="Redist\arm64.exe" Condition="'$(PlatformTarget)' != 'arm64'" />

<EmbeddedResource Remove="..\..\Sucrose\Package\$(TargetFramework)\$(Platform)\**\*.log" />
<EmbeddedResource Remove="..\..\Sucrose\Package\$(TargetFramework)\$(Platform)\**\*.txt" />
<EmbeddedResource Remove="..\..\Sucrose\Package\$(TargetFramework)\$(Platform)\**\*.pdb" />
Expand Down

0 comments on commit 26dfa7b

Please sign in to comment.