Skip to content

Commit fe27896

Browse files
authored
Merge pull request #505 from tonyhallett/disableTestingPlatformServerCapability-if-test-project
only if IsTestProject
2 parents aee3b0e + 26b2c80 commit fe27896

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

SharedProject/Core/MsTestPlatform/TestingPlatform/DisableTestingPlatformServerCapabilityGlobalPropertiesProvider.cs

+13
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,24 @@ private bool AllProjectsDisabled()
5353
return !appOptions.Enabled && appOptions.DisabledNoCoverage;
5454
}
5555

56+
private async Task<bool> IsTestProjectAsync(ConfiguredProject configuredProject)
57+
{
58+
var commonProperties = configuredProject.Services.ProjectPropertiesProvider.GetCommonProperties();
59+
var isTestProjectPropertValue = await commonProperties.GetEvaluatedPropertyValueAsync("IsTestProject");
60+
if (String.IsNullOrEmpty(isTestProjectPropertValue)) { return false; }
61+
if (bool.TryParse(isTestProjectPropertValue, out var isTestProject)){
62+
return isTestProject;
63+
}
64+
return false;
65+
}
66+
5667
private async Task<bool> IsApplicableAsync()
5768
{
5869
try
5970
{
6071
var configuredProject = await unconfiguredProject.GetSuggestedConfiguredProjectAsync();
72+
var isTestProject = await IsTestProjectAsync(configuredProject);
73+
if (!isTestProject) return false;
6174
var references = await configuredProject.Services.PackageReferences.GetUnresolvedReferencesAsync();
6275
return !references.Any(r => r.UnevaluatedInclude == TUnitConstants.TUnitPackageId);
6376
}

0 commit comments

Comments
 (0)