Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Add support for legacy MSTest using nuget packages #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions src/MSBuild.Abstractions/MSBuildHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,20 @@ public static bool IsAspNetCore(IProjectRootElement projectRoot, string tfm) =>
/// <returns></returns>
public static bool IsNETFrameworkMSTestProject(IProjectRootElement projectRoot)
{
var packages = GetOrCreatePackageReferencesItemGroup(projectRoot).Items.Select(elem => elem.Include);
var references = projectRoot.ItemGroups.SelectMany(GetReferences)?.Select(elem => elem.Include.Split(',').First());
if (references is null)
if (references is null && packages is null)
{
return false;
}
else
{
return MSTestFacts.MSTestReferences.All(reference => references.Contains(reference, StringComparer.OrdinalIgnoreCase));
var hasTestReference = false;
if(references != null)
hasTestReference = MSTestFacts.MSTestReferences.All(reference => references.Contains(reference, StringComparer.OrdinalIgnoreCase));
if (references != null)
hasTestReference = hasTestReference || MSTestFacts.MSTestPackages.All(package => packages.Contains(package, StringComparer.OrdinalIgnoreCase));
return hasTestReference;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/MSBuild.Conversion.Facts/MSTestFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public static class MSTestFacts
"Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions"
);

public static ImmutableArray<string> MSTestPackages = ImmutableArray.Create(
"MSTest.TestAdapter",
"MSTest.TestFramework"
);

public const string IsCodedUITestNodeName = "IsCodedUITest";
public const string TestProjectTypeNodeName = "TestProjectType";
public const string UnitTestTestProjectType = "UnitTest";
Expand Down