Skip to content

Commit 02ab00a

Browse files
authored
Skip splitting for paths Fixes #48794 (#48874)
2 parents 6d5870d + 64e5cda commit 02ab00a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Cli/Microsoft.TemplateEngine.Cli/TemplatePackageCoordinator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ internal async Task<NewCommandStatus> EnterInstallFlowAsync(InstallCommandArgs a
208208

209209
foreach (string installArg in args.TemplatePackages)
210210
{
211-
string[] split = installArg.Split(["::"], StringSplitOptions.RemoveEmptyEntries).SelectMany(arg => arg.Split('@', StringSplitOptions.RemoveEmptyEntries)).ToArray();
211+
bool isPath = File.Exists(installArg) || Directory.Exists(installArg);
212+
string[] split = isPath ? new[] { installArg } : installArg.Split(["::"], StringSplitOptions.RemoveEmptyEntries).SelectMany(arg => arg.Split('@', StringSplitOptions.RemoveEmptyEntries)).ToArray();
212213
string identifier = split[0];
213214
string? version = split.Length > 1 ? split[1] : null;
214215

test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ public void CanInstallRemoteNuGetPackage(string commandName)
4141
.And.HaveStdOutContaining("blazorwasm");
4242
}
4343

44+
[Fact]
45+
public void CanInstallToPathWithAt()
46+
{
47+
string path = Path.Combine(Path.GetTempPath(), "repro@4");
48+
try
49+
{
50+
Directory.CreateDirectory(path);
51+
new DotnetCommand(_log, "new", "console", "-o", path, "-n", "myconsole").Execute().Should().Pass();
52+
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();
53+
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();
54+
}
55+
finally
56+
{
57+
Directory.Delete(path, recursive: true);
58+
}
59+
}
60+
4461
[Fact]
4562
public void CanInstallRemoteNuGetPackage_LatestVariations()
4663
{

0 commit comments

Comments
 (0)