Skip to content

Commit 46e5748

Browse files
authored
Manual backport of 48874 to release 9.0.3xx (#50940)
2 parents 969c74e + 95f92b8 commit 46e5748

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
foreach (string expandedIdentifier in InstallRequestPathResolution.ExpandMaskedPath(identifier, _engineEnvironmentSettings))

test/dotnet-new.Tests/DotnetNewInstallTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ public void CanInstallRemoteNuGetPackage_LatestVariations(string separator)
8585
Assert.Equal(command1.StdOut, command3Out);
8686
}
8787

88+
[Fact]
89+
public void CanInstallToPathWithAt()
90+
{
91+
string path = Path.Combine(Path.GetTempPath(), "repro@4");
92+
try
93+
{
94+
Directory.CreateDirectory(path);
95+
new DotnetCommand(_log, "new", "console", "-o", path, "-n", "myconsole").Execute().Should().Pass();
96+
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();
97+
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();
98+
}
99+
finally
100+
{
101+
Directory.Delete(path, recursive: true);
102+
}
103+
}
104+
88105
[Theory]
89106
[InlineData("-i")]
90107
[InlineData("install")]

0 commit comments

Comments
 (0)