diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs b/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs index ed20a0ee107d..ad5166cc91b0 100644 --- a/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs +++ b/src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs @@ -208,7 +208,8 @@ internal async Task EnterInstallFlowAsync(InstallCommandArgs a foreach (string installArg in args.TemplatePackages) { - string[] split = installArg.Split(["::"], StringSplitOptions.RemoveEmptyEntries).SelectMany(arg => arg.Split('@', StringSplitOptions.RemoveEmptyEntries)).ToArray(); + bool isPath = File.Exists(installArg) || Directory.Exists(installArg); + string[] split = isPath ? new[] { installArg } : installArg.Split(["::"], StringSplitOptions.RemoveEmptyEntries).SelectMany(arg => arg.Split('@', StringSplitOptions.RemoveEmptyEntries)).ToArray(); string identifier = split[0]; string? version = split.Length > 1 ? split[1] : null; diff --git a/test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs b/test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs index a0a32d7d5856..1b90e9d43929 100644 --- a/test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs +++ b/test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs @@ -41,6 +41,23 @@ public void CanInstallRemoteNuGetPackage(string commandName) .And.HaveStdOutContaining("blazorwasm"); } + [Fact] + public void CanInstallToPathWithAt() + { + string path = Path.Combine(Path.GetTempPath(), "repro@4"); + try + { + Directory.CreateDirectory(path); + new DotnetCommand(_log, "new", "console", "-o", path, "-n", "myconsole").Execute().Should().Pass(); + new DotnetCommand(_log, "add", "package", "--project", Path.Combine(path, "myconsole.csproj"), "Microsoft.Azure.Functions.Worker.ProjectTemplates", "-v", "4.0.5086", "--package-directory", path).Execute().Should().Pass(); + new DotnetCommand(_log, "new", "install", Path.Combine(path, "microsoft.azure.functions.worker.projecttemplates/4.0.5086/microsoft.azure.functions.worker.projecttemplates.4.0.5086.nupkg")).Execute().Should().Pass(); + } + finally + { + Directory.Delete(path, recursive: true); + } + } + [Fact] public void CanInstallRemoteNuGetPackage_LatestVariations() {