Skip to content

Commit

Permalink
fix: embed dll information
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Nov 4, 2024
1 parent 03f2d65 commit 069f72b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ reqwest = { version = "0.12.8", default-features = false, features = ["http2", "
zip = "2.2.0"
tauri-plugin-dialog = "2"
tauri-plugin-process = "2"
tempfile = "3.13.0"

23 changes: 16 additions & 7 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
sync::Once,
};

use netcorehost::{hostfxr::AssemblyDelegateLoader, pdcstr};
use netcorehost::{hostfxr::AssemblyDelegateLoader, pdcstr, pdcstring::PdCString};
use reqwest::Client;
use std::ffi::CString;
use sysinfo::{ProcessRefreshKind, RefreshKind, System, UpdateKind};
Expand Down Expand Up @@ -395,18 +395,27 @@ struct AppState {
http: Client,
}

const RUNTIMECONFIG_JSON: &str = include_str!("../../csharp/bin/Release/net8.0/heliosphere-installer.runtimeconfig.json");
const DLL_BYTES: &[u8] = include_bytes!("../../csharp/bin/Release/net8.0/heliosphere-installer.dll");

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let tempdir = tempfile::tempdir().unwrap();
let runtimeconfig_path = tempdir.path().join("heliosphere-installer.runtimeconfig.json");
let dll_path = tempdir.path().join("heliosphere-installer.dll");

std::fs::write(&runtimeconfig_path, RUNTIMECONFIG_JSON).unwrap();
std::fs::write(&dll_path, DLL_BYTES).unwrap();

let runtimeconfig_path_pd = PdCString::try_from(runtimeconfig_path.to_str().unwrap()).unwrap();
let dll_path_pd = PdCString::try_from(dll_path.to_str().unwrap()).unwrap();

let host = netcorehost::nethost::load_hostfxr().unwrap();
let ctx = host
.initialize_for_runtime_config(pdcstr!(
"../csharp/bin/Release/net8.0/heliosphere-installer.runtimeconfig.json"
))
.initialize_for_runtime_config(runtimeconfig_path_pd)
.unwrap();
let delegate_loader = ctx
.get_delegate_loader_for_assembly(pdcstr!(
"../csharp/bin/Release/net8.0/heliosphere-installer.dll"
))
.get_delegate_loader_for_assembly(dll_path_pd)
.unwrap();

tauri::Builder::default()
Expand Down

0 comments on commit 069f72b

Please sign in to comment.