Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ internal static int ProcessArgs(string[] args, TimeSpan startupTime)
// Get the global.json state to report in telemetry along with this command invocation.
// We don't care about the actual SDK resolution, just the global.json information,
// so just pass empty string as executable directory for resolution.
NativeWrapper.SdkResolutionResult result = NativeWrapper.NETCoreSdkResolverNativeWrapper.ResolveSdk(string.Empty, Environment.CurrentDirectory);
NativeWrapper.SdkResolutionResult result = NativeWrapper.NETCoreSdkResolverNativeWrapper.ResolveSdk(string.Empty, Environment.CurrentDirectory, doNotPrintErrors: true);
globalJsonState = result.GlobalJsonState;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Resolvers/Microsoft.DotNet.NativeWrapper/Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static Interop()
}

// MSBuild SDK resolvers are required to be AnyCPU, but we have a native dependency and .NETFramework does not
// have a built-in facility for dynamically loading user native dlls for the appropriate platform. We therefore
// have a built-in facility for dynamically loading user native dlls for the appropriate platform. We therefore
// preload the version with the correct architecture (from a corresponding sub-folder relative to us) on static
// construction so that subsequent P/Invokes can find it.
private static void PreloadWindowsLibrary(string dllFileName)
Expand Down Expand Up @@ -73,6 +73,7 @@ private static IntPtr HostFxrResolver(Assembly assembly, string libraryName)
internal enum hostfxr_resolve_sdk2_flags_t : int
{
disallow_prerelease = 0x1,
do_not_print_errors = 0x2,
}

internal enum hostfxr_resolve_sdk2_result_key_t : int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ public static class NETCoreSdkResolverNativeWrapper
public static SdkResolutionResult ResolveSdk(
string? dotnetExeDirectory,
string? globalJsonStartDirectory,
bool disallowPrerelease = false)
bool disallowPrerelease = false,
bool doNotPrintErrors = false)
{
var result = new SdkResolutionResult();
var flags = disallowPrerelease ? Interop.hostfxr_resolve_sdk2_flags_t.disallow_prerelease : 0;
flags |= doNotPrintErrors ? Interop.hostfxr_resolve_sdk2_flags_t.do_not_print_errors : 0;

int errorCode = Interop.RunningOnWindows
? Interop.Windows.hostfxr_resolve_sdk2(dotnetExeDirectory, globalJsonStartDirectory, flags, result.Initialize)
Expand Down