8000 Slnx should now be found when using the DotnetSlnPostAction by nobowned · Pull Request #48879 · dotnet/sdk · GitHub
[go: up one dir, main page]

Skip to content

Slnx should now be found when using the DotnetSlnPostAction #48879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: release/9.0.3xx
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Slnx should now be found when using the DotnetSlnPostAction
  • Loading branch information
nobowned committed May 8, 2025
commit 860c6c21cfa6de0c4ba5b6f83f84d4e578ae7fc0
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public DotnetSlnPostActionProcessor(Func<string, IReadOnlyList<string>, string?,

internal static IReadOnlyList<string> FindSolutionFilesAtOrAbovePath(IPhysicalFileSystem fileSystem, string outputBasePath)
{
return FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.sln")
?? FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.slnx");
var slnFiles = FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.sln");
if (slnFiles.Count > 0)
{
return slnFiles;
}
return FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.slnx");
}

// The project files to add are a subset of the primary outputs, specifically the primary outputs indicated by the primaryOutputIndexes post action argument (semicolon separated)
Expand Down
48 changes: 30 additions & 18 deletions test/dotnet.Tests/dotnet-new/DotnetSlnPostActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ public DotnetSlnPostActionTests(EnvironmentSettingsHelper environmentSettingsHel
_engineEnvironmentSettings = environmentSettingsHelper.CreateEnvironment(hostIdentifier: GetType().Name, virtualize: true);
}

[Fact(DisplayName = nameof(AddProjectToSolutionPostActionFindSolutionFileAtOutputPath))]
public void AddProjectToSolutionPostActionFindSolutionFileAtOutputPath()
[Theory]
[InlineData("MySln.sln")]
[InlineData("MySln.slnx")]
public void AddProjectToSolutionPostActionFindSolutionFileAtOutputPath(string solutionFileName)
{
string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
string solutionFileFullPath = Path.Combine(targetBasePath, "MySln.sln");
string solutionFileFullPath = Path.Combine(targetBasePath, solutionFileName);
_engineEnvironmentSettings.Host.FileSystem.WriteAllText(solutionFileFullPath, string.Empty);

IReadOnlyList<string> solutionFiles = DotnetSlnPostActionProcessor.FindSolutionFilesAtOrAbovePath(_engineEnvironmentSettings.Host.FileSystem, targetBasePath);
Expand Down Expand Up @@ -160,14 +162,16 @@ public void AddProjectToSolutionPostActionWithoutPrimaryOutputIndexesWithOutputB
Assert.Contains(outputFileFullPath1, foundProjectFiles.ToList());
}

[Fact(DisplayName = nameof(AddProjectToSolutionCanTargetASingleProjectWithAJsonArray))]
public void AddProjectToSolutionCanTargetASingleProjectWithAJsonArray()
[Theory]
[InlineData("MySln.sln")]
[InlineData("MySln.slnx")]
public void AddProjectToSolutionCanTargetASingleProjectWithAJsonArray(string solutionFileName)
{
var callback = new MockAddProjectToSolutionCallback();
var actionProcessor = new DotnetSlnPostActionProcessor(callback.AddProjectToSolution);

string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
string slnFileFullPath = Path.Combine(targetBasePath, "MyApp.sln");
string slnFileFullPath = Path.Combine(targetBasePath, solutionFileName);
string projFileFullPath = Path.Combine(targetBasePath, "MyApp.csproj");

_engineEnvironmentSettings.Host.FileSystem.WriteAllText(slnFileFullPath, "");
Expand All @@ -189,14 +193,16 @@ public void AddProjectToSolutionCanTargetASingleProjectWithAJsonArray()
Assert.Equal(slnFileFullPath, callback.Solution);
}

[Fact(DisplayName = nameof(AddProjectToSolutionCanTargetASingleProjectWithTheProjectName))]
public void AddProjectToSolutionCanTargetASingleProjectWithTheProjectName()
[Theory]
[InlineData("MySln.sln")]
[InlineData("MySln.slnx")]
public void AddProjectToSolutionCanTargetASingleProjectWithTheProjectName(string solutionFileName)
{
var callback = new MockAddProjectToSolutionCallback();
var actionProcessor = new DotnetSlnPostActionProcessor(callback.AddProjectToSolution);

string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
string slnFileFullPath = Path.Combine(targetBasePath, "MyApp.sln");
string slnFileFullPath = Path.Combine(targetBasePath, solutionFileName);
string projFileFullPath = Path.Combine(targetBasePath, "MyApp.csproj");

_engineEnvironmentSettings.Host.FileSystem.WriteAllText(slnFileFullPath, "");
Expand All @@ -218,14 +224,16 @@ public void AddProjectToSolutionCanTargetASingleProjectWithTheProjectName()
Assert.Equal(slnFileFullPath, callback.Solution);
}

[Fact(DisplayName = nameof(AddProjectToSolutionCanPlaceProjectInSolutionRoot))]
public void AddProjectToSolutionCanPlaceProjectInSolutionRoot()
[Theory]
[InlineData("MySln.sln")]
[InlineData("MySln.slnx")]
public void AddProjectToSolutionCanPlaceProjectInSolutionRoot(string solutionFileName)
{
var callback = new MockAddProjectToSolutionCallback();
var actionProcessor = new DotnetSlnPostActionProcessor(callback.AddProjectToSolution);

string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
string slnFileFullPath = Path.Combine(targetBasePath, "MyApp.sln");
string slnFileFullPath = Path.Combine(targetBasePath, solutionFileName);
string projFileFullPath = Path.Combine(targetBasePath, "MyApp.csproj");

_engineEnvironmentSettings.Host.FileSystem.WriteAllText(slnFileFullPath, "");
Expand All @@ -250,14 +258,16 @@ public void AddProjectToSolutionCanPlaceProjectInSolutionRoot()
Assert.Null(callback.TargetFolder);
}

[Fact]
public void AddProjectToSolutionCanPlaceProjectInSolutionFolder()
[Theory]
[InlineData("MySln.sln")]
[InlineData("MySln.slnx")]
public void AddProjectToSolutionCanPlaceProjectInSolutionFolder(string solutionFileName)
{
var callback = new MockAddProjectToSolutionCallback();
var actionProcessor = new DotnetSlnPostActionProcessor(callback.AddProjectToSolution);

string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
string slnFileFullPath = Path.Combine(targetBasePath, "MyApp.sln");
string slnFileFullPath = Path.Combine(targetBasePath, solutionFileName);
string projFileFullPath = Path.Combine(targetBasePath, "MyApp.csproj");

_engineEnvironmentSettings.Host.FileSystem.WriteAllText(slnFileFullPath, "");
Expand All @@ -282,14 +292,16 @@ public void AddProjectToSolutionCanPlaceProjectInSolutionFolder()
Assert.Equal("src", callback.TargetFolder);
}

[Fact]
public void AddProjectToSolutionFailsWhenSolutionFolderAndInRootSpecified()
[Theory]
[InlineData("MySln.sln")]
[InlineData("MySln.slnx")]
public void AddProjectToSolutionFailsWhenSolutionFolderAndInRootSpecified(string solutionFileName)
{
var callback = new MockAddProjectToSolutionCallback();
var actionProcessor = new DotnetSlnPostActionProcessor(callback.AddProjectToSolution);

string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
string slnFileFullPath = Path.Combine(targetBasePath, "MyApp.sln");
string slnFileFullPath = Path.Combine(targetBasePath, solutionFileName);
string projFileFullPath = Path.Combine(targetBasePath, "MyApp.csproj");

_engineEnvironmentSettings.Host.FileSystem.WriteAllText(slnFileFullPath, "");
Expand Down
Loading
0