Skip to content

Default dotnet new sln to slnx format for .NET 10 #50023

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

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ cmake/
# Test results
**/*.trx
/TestResults
**/TestResults
/test/dotnet.Tests/CompletionTests/snapshots/**/**.received.*

# Live Unit Testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"type": "parameter",
"displayName": "Solution file format",
"description": "Choose the format for the solution file: sln or slnx.",
"defaultValue": "sln",
"defaultValue": "slnx",
"datatype": "choice",
"choices": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ private void TestInvalidTargetFramework(string testName, string targetFramework,
new DotnetNewCommand(Log)
.WithVirtualHive()
.WithWorkingDirectory(testAsset.TestRoot)
.Execute("sln")
.Execute("sln", "--format", "sln")
.Should()
.Pass();

Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.NET.TestFramework/TestAssetsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public TestAsset CreateTestProjects(

var testAsset = CreateTestProjectsInDirectory(testProjects, testDestinationDirectory);

var slnCreationResult = new DotnetNewCommand(Log, "sln")
var slnCreationResult = new DotnetNewCommand(Log, "sln", "--format", "sln")
.WithVirtualHive()
.WithWorkingDirectory(testDestinationDirectory)
.Execute();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The template "%TEMPLATE_NAME%" was created successfully.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Solution>
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The template "%TEMPLATE_NAME%" was created successfully.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Solution>
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Processing post-creation actions...
Adding
project(s): %working directory%/MyProject.csproj
to solution file: %working directory%/MySolution.sln
to solution file: %working directory%/MySolution.slnx
solution folder: src
%CALLBACK OUTPUT%
Successfully added project(s) to a solution file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Processing post-creation actions...
Adding
project(s): %working directory%/MyProject.csproj
to solution file: %working directory%/MySolution.sln
to solution file: %working directory%/MySolution.slnx
solution folder: src
%CALLBACK OUTPUT%
Successfully added project(s) to a solution file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Processing post-creation actions...
Adding
project(s): %working directory%\MyProject.csproj
to solution file: %working directory%\MySolution.sln
to solution file: %working directory%\MySolution.slnx
solution folder: src
%CALLBACK OUTPUT%
Successfully added project(s) to a solution file.
2 changes: 2 additions & 0 deletions test/dotnet-new.IntegrationTests/CommonTemplatesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public CommonTemplatesTests(SharedHomeDirectory fixture, ITestOutputHelper log)
[InlineData("dotnet gitignore file", "gitignore", null)]
[InlineData("dotnet gitignore file", ".gitignore", null)]
[InlineData("Solution File", "sln", null)]
[InlineData("Solution File", "sln", new[] { "--format", "sln" })]
[InlineData("Solution File", "sln", new[] { "--format", "slnx" })]
[InlineData("Solution File", "solution", null)]
[InlineData("Dotnet local tool manifest file", "tool-manifest", null)]
[InlineData("Web Config", "webconfig", null)]
Expand Down
12 changes: 6 additions & 6 deletions test/dotnet-new.IntegrationTests/PostActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ public void AddProjectToSolution_Basic(string templatePartLocation, string templ
.And.HaveStdOutContaining("solution folder: src")
.And.NotHaveStdOutContaining("Manual instructions: Add the generated files to solution manually.");

Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(workingDirectory, "MySolution.sln")));
Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(workingDirectory, "MySolution.slnx")));
}

[Fact]
Expand Down Expand Up @@ -811,7 +811,7 @@ public void AddProjectToSolution_BasicInSolutionRoot()
.And.HaveStdOutContaining(Path.Combine(outputDirectory, "MySolution.sln"))
.And.HaveStdOutContaining(Path.Combine(outputDirectory, "MyProject.csproj"));

Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(outputDirectory, "MySolution.sln")));
Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(outputDirectory, "MySolution.slnx")));
}

[Fact]
Expand Down Expand Up @@ -847,7 +847,7 @@ public void AddProjectToSolution_WithOutputAbsolutePath()
.And.HaveStdOutContaining(Path.Combine(outputDirectory, "MySolution.sln"))
.And.HaveStdOutContaining(Path.Combine(outputDirectory, "MyProject.csproj"));

Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(outputDirectory, "MySolution.sln")));
Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(outputDirectory, "MySolution.slnx")));
}

[Fact]
Expand Down Expand Up @@ -883,7 +883,7 @@ public void AddProjectToSolution_WithOutputRelativePath()
.And.HaveStdOutContaining(Path.Combine(workingDirectory, outputDirectory, "MySolution.sln"))
.And.HaveStdOutContaining(Path.Combine(workingDirectory, outputDirectory, "MyProject.csproj"));

Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(workingDirectory, outputDirectory, "MySolution.sln")));
Assert.Contains("MyProject.csproj", File.ReadAllText(Path.Combine(workingDirectory, outputDirectory, "MySolution.slnx")));
}

[Fact]
Expand Down Expand Up @@ -916,11 +916,11 @@ public void AddProjectToSolution_PrimaryOutputIndexes()
.And.HaveStdOutContaining("solution folder: Server")
.And.NotHaveStdOutContaining("Manual instructions: Add generated Server project to solution manually to folder 'Server'.");

Assert.True(File.Exists(Path.Combine(workingDirectory, "MySolution.sln")));
Assert.True(File.Exists(Path.Combine(workingDirectory, "MySolution.slnx")));
Assert.True(File.Exists(Path.Combine(workingDirectory, "Server/Server.csproj")));
Assert.True(File.Exists(Path.Combine(workingDirectory, "Client/Client.csproj")));

string solutionFileContents = File.ReadAllText(Path.Combine(workingDirectory, "MySolution.sln"));
string solutionFileContents = File.ReadAllText(Path.Combine(workingDirectory, "MySolution.slnx"));
Assert.Contains("Server.csproj", solutionFileContents);
Assert.DoesNotContain("Client.csproj", solutionFileContents);
}
Expand Down