public void UnknownSdk_DotNetMSBuildSdkResolverDoesNotFatalReportError() { var resolution = SdkResolution.GetResolver(Runtime.SystemAssemblyService.CurrentRuntime); // Using a sdk with an invalid version to prevent the NuGet sdk resolver causing a test crash. // Invalid version numbers cause the NuGet sdk resolver to not try to resolve the sdk. The crash // only seems to happen with this test - using the IDE does not trigger the crash. There is a // separate NuGet sdk resolver test that runs the resolver. Crash error: // NuGet.Configuration.NuGetPathContext doesn't implement interface NuGet.Common.INuGetPathContext var sdkReference = new SdkReference("MonoDevelop.Unknown.Test.Sdk", "InvalidVersion", null); var logger = new TestLoggingService(); var context = new MSBuildContext(); string result = null; UserException ex = Assert.Throws <UserException> (() => { result = resolution.GetSdkPath(sdkReference, logger, context, null, null); }); var error = logger.FatalBuildErrors.FirstOrDefault(); Assert.AreEqual(0, logger.FatalBuildErrors.Count, "First error: " + error); Assert.IsNull(result); Assert.AreEqual("Unable to find SDK 'MonoDevelop.Unknown.Test.Sdk/InvalidVersion'", ex.Message); Assert.That(ex.Details, Contains.Substring("SDK not found")); // MonoDevelop.Projects.MSBuild.Resolver Assert.That(ex.Details, Contains.Substring("Check that a recent enough .NET Core SDK is installed")); // .NET Core SDK resolver }
public void UnknownSdk_DotNetMSBuildSdkResolverDoesNotFatalReportError() { var resolution = SdkResolution.GetResolver(Runtime.SystemAssemblyService.CurrentRuntime); // Using a sdk with an invalid version to prevent the NuGet sdk resolver causing a test crash. // Invalid version numbers cause the NuGet sdk resolver to not try to resolve the sdk. The crash // only seems to happen with this test - using the IDE does not trigger the crash. There is a // separate NuGet sdk resolver test that runs the resolver. Crash error: // NuGet.Configuration.NuGetPathContext doesn't implement interface NuGet.Common.INuGetPathContext var sdkReference = new SdkReference("MonoDevelop.Unknown.Test.Sdk", "InvalidVersion", null); var logger = new TestLoggingService(); var context = new MSBuildContext(); var result = resolution.GetSdkPath(sdkReference, logger, context, null, null); var error = logger.FatalBuildErrors.FirstOrDefault(); Assert.AreEqual(0, logger.FatalBuildErrors.Count, "First error: " + error); Assert.IsNull(result); }