Skip to content

Commit

Permalink
Try to fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Braunsperger committed Feb 2, 2024
1 parent fd329aa commit e138854
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/hostfxr/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ impl Hostfxr {
pub fn load_with_nethost() -> Result<Self, LoadHostfxrError> {
crate::nethost::load_hostfxr()
}

/// Returns the path to the dotnet root.
pub fn get_dotnet_root(&self) -> PathBuf {
self.get_dotnet_exe().parent().unwrap().to_owned()
}

/// Returns the path to the dotnet executable of the same installation as hostfxr.
pub fn get_dotnet_exe(&self) -> PathBuf {
self.dotnet_exe.to_os_string().into()
}
}

/// Either the exit code of the app if it ran successful, otherwise the error from the hosting components.
Expand Down
6 changes: 4 additions & 2 deletions src/hostfxr/library6_0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use hostfxr_sys::hostfxr_dotnet_environment_info;
use crate::{
error::{HostingError, HostingResult},
hostfxr::Hostfxr,
pdcstring::PdCStr,
pdcstring::{PdCStr, PdCString},
};
use std::{ffi::c_void, mem::MaybeUninit, path::PathBuf, ptr, slice};

Expand Down Expand Up @@ -104,10 +104,12 @@ impl Hostfxr {
/// then it will also enumerate SDKs and frameworks from the global install location.
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "net6_0")))]
pub fn get_dotnet_environment_info(&self) -> Result<EnvironmentInfo, HostingError> {
let dotnet_root = PdCString::from_os_str(self.get_dotnet_root()).ok();
let dotnet_root_ptr = dotnet_root.as_ref().map_or_else(ptr::null, |p| p.as_ptr());
let mut info = MaybeUninit::<EnvironmentInfo>::uninit();
let result = unsafe {
self.lib.hostfxr_get_dotnet_environment_info(
ptr::null(),
dotnet_root_ptr,
ptr::null_mut(),
get_dotnet_environment_info_callback,
info.as_mut_ptr().cast(),
Expand Down

0 comments on commit e138854

Please sign in to comment.