Skip to content
Merged
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
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 @@ -1294,11 +1294,11 @@
}

internal sealed class AssertingDotNetCliRunner(
ILogger<DotNetCliRunner> logger,

Check failure on line 1297 in tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire (Build Linux)

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs#L1297

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs(1297,30): error xUnit1041: (NETCORE_ENGINEERING_TELEMETRY=Build) Fixture argument 'logger' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041)

Check failure on line 1297 in tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs#L1297

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs(1297,30): error xUnit1041: (NETCORE_ENGINEERING_TELEMETRY=Build) Fixture argument 'logger' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041)
IServiceProvider serviceProvider,

Check failure on line 1298 in tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire (Build Linux)

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs#L1298

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs(1298,22): error xUnit1041: (NETCORE_ENGINEERING_TELEMETRY=Build) Fixture argument 'serviceProvider' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041)

Check failure on line 1298 in tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs#L1298

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs(1298,22): error xUnit1041: (NETCORE_ENGINEERING_TELEMETRY=Build) Fixture argument 'serviceProvider' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041)
AspireCliTelemetry telemetry,

Check failure on line 1299 in tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire (Build Linux)

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs#L1299

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs(1299,24): error xUnit1041: (NETCORE_ENGINEERING_TELEMETRY=Build) Fixture argument 'telemetry' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041)
IConfiguration configuration,

Check failure on line 1300 in tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire (Build Linux)

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs#L1300

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs(1300,20): error xUnit1041: (NETCORE_ENGINEERING_TELEMETRY=Build) Fixture argument 'configuration' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041)
IFeatures features,

Check failure on line 1301 in tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire (Build Linux)

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs#L1301

tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs(1301,15): error xUnit1041: (NETCORE_ENGINEERING_TELEMETRY=Build) Fixture argument 'features' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041)
IInteractionService interactionService,
CliExecutionContext executionContext,
IDiskCache diskCache,
Expand All @@ -1311,4 +1311,19 @@
assertionCallback(args, env, workingDirectory, projectFile, backchannelCompletionSource, options);
return Task.FromResult(exitCode);
}

[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);
}
}
Loading