From 26b2c808d5a9f1839f1315112b4f8a11574f2465 Mon Sep 17 00:00:00 2001 From: Tony Hallett Date: Mon, 31 Mar 2025 13:18:13 +0100 Subject: [PATCH] only if IsTestProject --- ...tformServerCapabilityGlobalPropertiesProvider.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs b/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs index ab7463d1..cee56e68 100644 --- a/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs +++ b/SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs @@ -53,11 +53,24 @@ private bool AllProjectsDisabled() return !appOptions.Enabled && appOptions.DisabledNoCoverage; } + private async Task IsTestProjectAsync(ConfiguredProject configuredProject) + { + var commonProperties = configuredProject.Services.ProjectPropertiesProvider.GetCommonProperties(); + var isTestProjectPropertValue = await commonProperties.GetEvaluatedPropertyValueAsync("IsTestProject"); + if (String.IsNullOrEmpty(isTestProjectPropertValue)) { return false; } + if (bool.TryParse(isTestProjectPropertValue, out var isTestProject)){ + return isTestProject; + } + return false; + } + private async Task IsApplicableAsync() { try { var configuredProject = await unconfiguredProject.GetSuggestedConfiguredProjectAsync(); + var isTestProject = await IsTestProjectAsync(configuredProject); + if (!isTestProject) return false; var references = await configuredProject.Services.PackageReferences.GetUnresolvedReferencesAsync(); return !references.Any(r => r.UnevaluatedInclude == TUnitConstants.TUnitPackageId); }