Skip to content

Commit

Permalink
add slnx support
Browse files Browse the repository at this point in the history
  • Loading branch information
sensslen committed Dec 27, 2024
1 parent fc1e313 commit 7ba90c2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ProjectsCollector(IMsBuildAbstraction msBuild)

public IEnumerable<string> GetProjects(string inputPath)
{
return Path.GetExtension(inputPath).Equals(".sln")
return Path.GetExtension(inputPath).StartsWith(".sln")
? _msBuild.GetProjectsFromSolution(Path.GetFullPath(inputPath)).Where(File.Exists).Select(Path.GetFullPath)
: new[] { Path.GetFullPath(inputPath) };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace NuGetUtility.Test.LicenseValidator
[TestFixture]
public class UrlToLicenseMappingTest
{
[Ignore("chrome")]
[Parallelizable(scope: ParallelScope.All)]
[TestCaseSource(typeof(UrlToLicenseMapping), nameof(UrlToLicenseMapping.Default))]
public async Task License_Should_Be_Available_And_Match_Expected_License(KeyValuePair<Uri, string> mappedValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void GetProjects_Should_ReturnProjectsAsListDirectly(string projectFile)
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("A.slnx")]
public void GetProjects_Should_QueryMsBuildToGetProjectsForSolutionFiles(string solutionFile)
{
_ = _uut.GetProjects(solutionFile);
Expand All @@ -54,6 +55,7 @@ public void GetProjects_Should_QueryMsBuildToGetProjectsForSolutionFiles(string
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("C.slnx")]
public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsNoProjects(string solutionFile)
{
_msBuild.GetProjectsFromSolution(Arg.Any<string>()).Returns(Enumerable.Empty<string>());
Expand All @@ -67,6 +69,7 @@ public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsNoProjects(st
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("B.slnx")]
public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsProjectsThatDontExist(string solutionFile)
{
IEnumerable<string> projects = _fixture.CreateMany<string>();
Expand All @@ -81,6 +84,7 @@ public void GetProjects_Should_ReturnEmptyArray_If_SolutionContainsProjectsThatD
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("C.slnx")]
public void GetProjects_Should_ReturnArrayOfProjects_If_SolutionContainsProjectsThatDoExist(string solutionFile)
{
string[] projects = _fixture.CreateMany<string>().ToArray();
Expand All @@ -96,6 +100,7 @@ public void GetProjects_Should_ReturnArrayOfProjects_If_SolutionContainsProjects
[TestCase("A.sln")]
[TestCase("B.sln")]
[TestCase("C.sln")]
[TestCase("A.slnx")]
public void GetProjects_Should_ReturnOnlyExistingProjectsInSolutionFile(string solutionFile)
{
string[] existingProjects = _fixture.CreateMany<string>().ToArray();
Expand All @@ -120,6 +125,14 @@ public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionF
await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings);
}

[Test, Ignore("Ignore this specific test as long as msbuild does not fully support slnx solutions everywhere")]
public async Task GetProjectsFromXmlSolution_Should_ReturnProjectsInActualSolutionFileRelativePath()
{
var msbuild = new MsBuildAbstraction();
IEnumerable<string> result = msbuild.GetProjectsFromSolution("../../../../targets/slnx/slnx.slnx");
await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings);
}

[Test]
public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath()
{
Expand Down
8 changes: 8 additions & 0 deletions tests/targets/slnx/slnx.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Solution>
<Configurations>
<BuildType Name="Debug" />
<BuildType Name="Release" />
<BuildType Name="TestWindows" />
</Configurations>
<Project Path="../ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj" Id="875c0575-95c4-4006-a910-bb1555c90c75" />
</Solution>

0 comments on commit 7ba90c2

Please sign in to comment.