Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.101",
"version": "10.0.102",
Comment thread
joperezr marked this conversation as resolved.
Outdated
"rollForward": "major",
"allowPrerelease": true,
"paths": [
Expand All @@ -10,7 +10,7 @@
"errorMessage": "The .NET SDK could not be found. Run ./restore.sh (Linux/macOS) or ./restore.cmd (Windows) to install the local SDK."
},
"tools": {
"dotnet": "10.0.101",
"dotnet": "10.0.102",
Comment thread
joperezr marked this conversation as resolved.
Outdated
"runtimes": {
"dotnet/x64": [
"$(DotNetRuntimePreviousVersionForTesting)",
Expand Down
9 changes: 6 additions & 3 deletions src/Aspire.Cli/DotNet/DotNetCliRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public async Task<int> TrustHttpCertificateAsync(DotNetCliRunnerInvocationOption
}
}

private static bool TryParsePackageVersionFromStdout(string stdout, [NotNullWhen(true)] out string? version)
internal static bool TryParsePackageVersionFromStdout(string stdout, [NotNullWhen(true)] out string? version)
{
var lines = stdout.Split(Environment.NewLine);
var successLine = lines.SingleOrDefault(x => x.StartsWith("Success: Aspire.ProjectTemplates"));
Expand All @@ -461,9 +461,12 @@ private static bool TryParsePackageVersionFromStdout(string stdout, [NotNullWhen
}

var templateVersion = successLine.Split(" ") switch { // Break up the success line.
{ Length: > 2 } chunks => chunks[1].Split("::") switch { // Break up the template+version string
{ Length: > 2 } chunks => chunks[1].Split("@") switch { // Break up the template+version string (@ separator for .NET 10.0+)
{ Length: 2 } versionChunks => versionChunks[1], // The version in the second chunk
_ => null
_ => chunks[1].Split("::") switch { // Fallback to :: separator for older SDK versions
{ Length: 2 } versionChunks => versionChunks[1],
_ => null
}
},
_ => null
};
Expand Down
15 changes: 15 additions & 0 deletions tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,21 @@ await runner.GetProjectItemsAndPropertiesAsync(
CancellationToken.None
);
}

[Theory]
[InlineData("Success: Aspire.ProjectTemplates@13.2.0-preview.1.26101.12 installed the following templates:", true, "13.2.0-preview.1.26101.12")] // New .NET 10.0 SDK format with @ separator
[InlineData("Success: Aspire.ProjectTemplates::13.2.0-preview.1.26101.12 installed the following templates:", true, "13.2.0-preview.1.26101.12")] // Old SDK format with :: separator
[InlineData("Some other output", false, null)] // Missing success line
[InlineData("Success: Aspire.ProjectTemplates installed the following templates:", false, null)] // Invalid format without version separator
public void TryParsePackageVersionFromStdout_ParsesCorrectly(string stdout, bool expectedResult, string? expectedVersion)
{
// Act
var result = DotNetCliRunner.TryParsePackageVersionFromStdout(stdout, out var version);

// Assert
Assert.Equal(expectedResult, result);
Assert.Equal(expectedVersion, version);
}
}

internal sealed class AssertingDotNetCliRunner(
Expand Down
Loading