-
Notifications
You must be signed in to change notification settings - Fork 91
Modernize DotNetSdkLocationHelper and hostfxr interop.
#339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
hi @teo-tsirpanis |
|
@YuliiaKovalova conflicts resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, wait, something is wrong:
❯ .\samples\BuilderApp\bin\Debug\net8.0\BuilderApp.exe .\MSBuildLocator.sln
Sample MSBuild Builder App 1.9.7+e4c2ece661.
Process terminated. Assertion failed.
at Microsoft.Build.Locator.NativeMethods.hostfxr_resolve_sdk2_callback(hostfxr_resolve_sdk2_result_key_t key, Void* value) in S:\work\MSBuildLocator\src\MSBuildLocator\NativeMethods.cs:line 63
at Microsoft.Build.Locator.NativeMethods.<hostfxr_resolve_sdk2>g____PInvoke|4_0(Void* __exe_dir_native, Void* __working_dir_native, hostfxr_resolve_sdk2_flags_t __flags_native, __result_native)
at Microsoft.Build.Locator.NativeMethods.<hostfxr_resolve_sdk2>g____PInvoke|4_0(Void* __exe_dir_native, Void* __working_dir_native, hostfxr_resolve_sdk2_flags_t __flags_native, __result_native)
at Microsoft.Build.Locator.NativeMethods.hostfxr_resolve_sdk2(String exe_dir, String working_dir, hostfxr_resolve_sdk2_flags_t flags, result) in S:\work\MSBuildLocator\src\MSBuildLocator\obj\Debug\net8.0\Microsoft.Interop.LibraryImportGenerator\Microsoft.Interop.LibraryImportGenerator\LibraryImports.g.cs:line 19
at Microsoft.Build.Locator.NativeMethods.hostfxr_resolve_sdk2(String exe_dir, String working_dir, hostfxr_resolve_sdk2_flags_t flags, String& resolved_sdk_dir, String& global_json_path) in S:\work\MSBuildLocator\src\MSBuildLocator\NativeMethods.cs:line 36
at Microsoft.Build.Locator.DotNetSdkLocationHelper.<GetInstances>g__GetSdkFromGlobalSettings|4_2(String workingDirectory) in S:\work\MSBuildLocator\src\MSBuildLocator\DotNetSdkLocationHelper.cs:line 153
at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetInstances(String workingDirectory, Boolean allowQueryAllRuntimes, Boolean allowAllDotnetLocations)+MoveNext() in S:\work\MSBuildLocator\src\MSBuildLocator\DotNetSdkLocationHelper.cs:line 82
at Microsoft.Build.Locator.MSBuildLocator.GetInstances(VisualStudioInstanceQueryOptions options)+MoveNext() in S:\work\MSBuildLocator\src\MSBuildLocator\MSBuildLocator.cs:line 389
at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
at BuilderApp.Program.Main(String[] args) in S:\work\MSBuildLocator\samples\BuilderApp\Program.cs:line 26|
It is getting called twice, the first time with Maybe the assertions should be moved inside the switch @teo-tsirpanis? |
|
Removed assertions, as per the other native callback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thank you!
NativeMethodsclass was updated to use the P/Invoke source generator, and[UnmanagedCallersOnly]. The changes made are in a similar vein to UseUnmanagedCallersOnlyinAssemblyDependencyResolver. dotnet/runtime#119034.DotNetSdkLocationHelperclass was updated to use APIs added in newer frameworks, like the regex source generator, or APIs to resolve symlinks. The latter also lets us remove the P/Invokes tolibc.