From ccfa1217cd0c68082f101a2c4aeb65ccd88048e5 Mon Sep 17 00:00:00 2001 From: Tony Hallett Date: Mon, 31 Mar 2025 11:43:15 +0100 Subject: [PATCH] catch exception --- ...ormServerCapabilityGlobalPropertiesProvider.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs b/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs index e59d05b0..ab7463d1 100644 --- a/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs +++ b/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs @@ -53,11 +53,16 @@ private bool AllProjectsDisabled() return !appOptions.Enabled && appOptions.DisabledNoCoverage; } - private async Task IsTUnitAsync() + private async Task IsApplicableAsync() { - var configuredProject = await unconfiguredProject.GetSuggestedConfiguredProjectAsync(); - var references = await configuredProject.Services.PackageReferences.GetUnresolvedReferencesAsync(); - return references.Any(r => r.UnevaluatedInclude == TUnitConstants.TUnitPackageId); + try + { + var configuredProject = await unconfiguredProject.GetSuggestedConfiguredProjectAsync(); + var references = await configuredProject.Services.PackageReferences.GetUnresolvedReferencesAsync(); + return !references.Any(r => r.UnevaluatedInclude == TUnitConstants.TUnitPackageId); + } + catch { } + return false; } private async Task ProjectEnabledAsync() @@ -99,7 +104,7 @@ private CoverageProject GetCoverageProject(Guid projectGuid) public override async Task> GetGlobalPropertiesAsync(CancellationToken cancellationToken) { - if (!await IsTUnitAsync() && !AllProjectsDisabled() && await ProjectEnabledAsync()) + if (await IsApplicableAsync() && !AllProjectsDisabled() && await ProjectEnabledAsync()) { return Empty.PropertiesMap.Add("DisableTestingPlatformServerCapability", "true"); }