embed ui executable directly into c# assembly
This commit is contained in:
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -52,19 +52,15 @@ jobs:
|
|||||||
- name: Restore NuGet packages
|
- name: Restore NuGet packages
|
||||||
run: dotnet restore -r win-x64 ./Il2CppInspector.Redux.GUI
|
run: dotnet restore -r win-x64 ./Il2CppInspector.Redux.GUI
|
||||||
|
|
||||||
- name: Build GUI C# component
|
# note: we embed the exe directly into the c# component, and it it is built alongside it
|
||||||
|
# in another msbuild target.
|
||||||
|
- name: Build GUI
|
||||||
run: dotnet publish ./Il2CppInspector.Redux.GUI/Il2CppInspector.Redux.GUI.csproj -r win-x64 --no-self-contained
|
run: dotnet publish ./Il2CppInspector.Redux.GUI/Il2CppInspector.Redux.GUI.csproj -r win-x64 --no-self-contained
|
||||||
|
|
||||||
- name: Build GUI TS component
|
|
||||||
run: pnpm tauri build --no-bundle
|
|
||||||
working-directory: ./Il2CppInspector.Redux.GUI.UI
|
|
||||||
|
|
||||||
- name: Copy components to output directory
|
- name: Copy components to output directory
|
||||||
run: |
|
run: |
|
||||||
mkdir ./build_output
|
mkdir ./build_output
|
||||||
mkdir ./build_output/resources
|
|
||||||
cp ./Il2CppInspector.Redux.GUI/bin/Release/net9.0/win-x64/publish/Il2CppInspector.Redux.GUI.exe ./build_output/
|
cp ./Il2CppInspector.Redux.GUI/bin/Release/net9.0/win-x64/publish/Il2CppInspector.Redux.GUI.exe ./build_output/
|
||||||
cp ./Il2CppInspector.Redux.GUI.UI/src-tauri/target/release/il2cppinspectorredux.exe ./build_output/resources/
|
|
||||||
|
|
||||||
- name: Upload GUI Artifact
|
- name: Upload GUI Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
<PublishAot>false</PublishAot>
|
|
||||||
<!-- todo: enable this once the app is aot compliant! -->
|
<!-- todo: enable this once the app is aot compliant! -->
|
||||||
|
<PublishAot>false</PublishAot>
|
||||||
<OutputType Condition="'$(Configuration)' == 'Release'">WinExe</OutputType>
|
<OutputType Condition="'$(Configuration)' == 'Release'">WinExe</OutputType>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -16,4 +16,12 @@
|
|||||||
<ProjectReference Include="..\Il2CppInspector.Common\Il2CppInspector.csproj" />
|
<ProjectReference Include="..\Il2CppInspector.Common\Il2CppInspector.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- todo: this needs to be adjusted for multiplatform support -->
|
||||||
|
<Target Name="BuildTauriFrontend" BeforeTargets="BeforeBuild">
|
||||||
|
<Exec Command="pnpm tauri build --no-bundle" WorkingDirectory="..\Il2CppInspector.Redux.GUI.UI" />
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="..\Il2CppInspector.Redux.GUI.UI\src-tauri\target\release\il2cppinspectorredux.exe" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -4,14 +4,39 @@ namespace Il2CppInspector.Redux.GUI;
|
|||||||
|
|
||||||
public class UiProcessService(IHostApplicationLifetime lifetime) : BackgroundService
|
public class UiProcessService(IHostApplicationLifetime lifetime) : BackgroundService
|
||||||
{
|
{
|
||||||
// NOTE: this is not really a good solution for getting people to launch the correct program.
|
// TODO: This needs to be adjusted for multiplatform support
|
||||||
private const string UiExecutableName = "./resources/il2cppinspectorredux.exe";
|
private const string UiExecutableName = "il2cppinspectorredux.exe";
|
||||||
|
|
||||||
private Process? _uiProcess;
|
private Process? _uiProcess;
|
||||||
|
private string? _uiExectuablePath;
|
||||||
|
|
||||||
public void LaunchUiProcess(int port)
|
public void LaunchUiProcess(int port)
|
||||||
{
|
{
|
||||||
_uiProcess = Process.Start(new ProcessStartInfo(UiExecutableName, [port.ToString()]));
|
_uiExectuablePath ??= ExtractUiExecutable();
|
||||||
|
_uiProcess = Process.Start(new ProcessStartInfo(_uiExectuablePath, [port.ToString()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ExtractUiExecutable()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var executable =
|
||||||
|
typeof(UiProcessService).Assembly.GetManifestResourceStream(
|
||||||
|
$"{typeof(UiProcessService).Namespace!}.{UiExecutableName}");
|
||||||
|
if (executable == null)
|
||||||
|
throw new FileNotFoundException("Failed to open resource as stream.");
|
||||||
|
|
||||||
|
var tempDir = Directory.CreateTempSubdirectory("il2cppinspectorredux-ui");
|
||||||
|
var uiExePath = Path.Join(tempDir.FullName, UiExecutableName);
|
||||||
|
|
||||||
|
using var fs = File.Create(uiExePath);
|
||||||
|
executable.CopyTo(fs);
|
||||||
|
return uiExePath;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Failed to find embedded UI executable: {ex}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
@@ -28,6 +53,9 @@ public class UiProcessService(IHostApplicationLifetime lifetime) : BackgroundSer
|
|||||||
if (_uiProcess is { HasExited: false })
|
if (_uiProcess is { HasExited: false })
|
||||||
_uiProcess.Kill();
|
_uiProcess.Kill();
|
||||||
|
|
||||||
|
if (_uiExectuablePath != null)
|
||||||
|
File.Delete(_uiExectuablePath);
|
||||||
|
|
||||||
return base.StopAsync(cancellationToken);
|
return base.StopAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user