diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs b/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs index 313a7fd31501..9e04501f49d1 100644 --- a/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs +++ b/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs @@ -207,9 +207,9 @@ internal async Task EnterInstallFlowAsync(InstallCommandArgs a foreach (string installArg in args.TemplatePackages) { - string[] splitByColons = installArg.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries); - string identifier = splitByColons[0]; - string? version = splitByColons.Length > 1 ? splitByColons[1] : null; + string[] split = installArg.Split(["::"], StringSplitOptions.RemoveEmptyEntries).SelectMany(arg => arg.Split('@', StringSplitOptions.RemoveEmptyEntries)).ToArray(); + string identifier = split[0]; + string? version = split.Length > 1 ? split[1] : null; foreach (string expandedIdentifier in InstallRequestPathResolution.ExpandMaskedPath(identifier, _engineEnvironmentSettings)) { installRequests.Add(new InstallRequest(expandedIdentifier, version, details: details, force: args.Force)); diff --git a/test/dotnet-new.Tests/DotnetNewInstallTests.cs b/test/dotnet-new.Tests/DotnetNewInstallTests.cs index 2ebcaff0bb44..9f515bfffb10 100644 --- a/test/dotnet-new.Tests/DotnetNewInstallTests.cs +++ b/test/dotnet-new.Tests/DotnetNewInstallTests.cs @@ -42,21 +42,22 @@ public void CanInstallRemoteNuGetPackage(string commandName) } [Theory] - [InlineData("-i")] - [InlineData("install")] - public void CanInstallRemoteNuGetPackage_LatestVariations(string commandName) + [InlineData("::")] + [InlineData("@")] + public void CanInstallRemoteNuGetPackage_LatestVariations(string separator) { + var commandName = "install"; CommandResult command1 = new DotnetNewCommand(_log, commandName, "Microsoft.DotNet.Common.ProjectTemplates.5.0") .WithCustomHive(CreateTemporaryFolder(folderName: "Home")) .WithWorkingDirectory(CreateTemporaryFolder()) .Execute(); - CommandResult command2 = new DotnetNewCommand(_log, commandName, "Microsoft.DotNet.Common.ProjectTemplates.5.0::") + CommandResult command2 = new DotnetNewCommand(_log, commandName, $"Microsoft.DotNet.Common.ProjectTemplates.5.0{separator}") .WithCustomHive(CreateTemporaryFolder(folderName: "Home")) .WithWorkingDirectory(CreateTemporaryFolder()) .Execute(); - CommandResult command3 = new DotnetNewCommand(_log, commandName, "Microsoft.DotNet.Common.ProjectTemplates.5.0::*") + CommandResult command3 = new DotnetNewCommand(_log, commandName, $"Microsoft.DotNet.Common.ProjectTemplates.5.0{separator}*") .WithCustomHive(CreateTemporaryFolder(folderName: "Home")) .WithWorkingDirectory(CreateTemporaryFolder()) .Execute();