Skip to content

Commit f532611

Browse files
committed
quote --configfile and added test
1 parent 92bcc44 commit f532611

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

src/Dotnet.Script.DependencyModel/Context/DotnetRestorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ string CreateConfigFileArgument()
4646
{
4747
return string.IsNullOrWhiteSpace(projectFileInfo.NuGetConfigFile)
4848
? string.Empty
49-
: $"--configfile {projectFileInfo.NuGetConfigFile}";
49+
: $"--configfile \"{projectFileInfo.NuGetConfigFile}\"";
5050

5151
}
5252
}

src/Dotnet.Script.Tests/ScriptExecutionTests.cs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public void ShouldHandleLocalNuGetConfigWithRelativePath()
391391

392392
using (var packageLibraryFolder = new DisposableFolder())
393393
{
394-
CreateTestPackage(packageLibraryFolder);
394+
CreateTestPackage(packageLibraryFolder.Path);
395395

396396
string pathToScriptFile = CreateTestScript(packageLibraryFolder.Path);
397397

@@ -407,7 +407,7 @@ public void ShouldHandleLocalNuGetConfigWithRelativePathInParentFolder()
407407

408408
using (var packageLibraryFolder = new DisposableFolder())
409409
{
410-
CreateTestPackage(packageLibraryFolder);
410+
CreateTestPackage(packageLibraryFolder.Path);
411411

412412
var scriptFolder = Path.Combine(packageLibraryFolder.Path, "ScriptFolder");
413413
Directory.CreateDirectory(scriptFolder);
@@ -418,6 +418,26 @@ public void ShouldHandleLocalNuGetConfigWithRelativePathInParentFolder()
418418
}
419419
}
420420

421+
[Fact]
422+
public void ShouldHandleLocalNuGetFileWhenPathContainsSpace()
423+
{
424+
TestPathUtils.RemovePackageFromGlobalNugetCache("NuGetConfigTestLibrary");
425+
426+
using (var packageLibraryFolder = new DisposableFolder())
427+
{
428+
var packageLibraryFolderPath = Path.Combine(packageLibraryFolder.Path, "library folder");
429+
Directory.CreateDirectory(packageLibraryFolderPath);
430+
431+
CreateTestPackage(packageLibraryFolderPath);
432+
433+
string pathToScriptFile = CreateTestScript(packageLibraryFolderPath);
434+
435+
var result = ScriptTestRunner.Default.Execute($"\"{pathToScriptFile}\"");
436+
Assert.Contains("Success", result.output);
437+
}
438+
}
439+
440+
421441
private static string CreateTestScript(string scriptFolder)
422442
{
423443
string script = @"
@@ -429,11 +449,16 @@ private static string CreateTestScript(string scriptFolder)
429449
return pathToScriptFile;
430450
}
431451

432-
private static void CreateTestPackage(DisposableFolder packageLibraryFolder)
452+
private static void CreateTestPackage(string packageLibraryFolder)
453+
{
454+
ProcessHelper.RunAndCaptureOutput("dotnet", "new classlib -n NuGetConfigTestLibrary", packageLibraryFolder);
455+
var projectFolder = Path.Combine(packageLibraryFolder, "NuGetConfigTestLibrary");
456+
ProcessHelper.RunAndCaptureOutput("dotnet", $"pack -o \"{Path.Combine(packageLibraryFolder, "packagePath")}\"", projectFolder);
457+
CreateNuGetConfig(packageLibraryFolder);
458+
}
459+
460+
private static void CreateNuGetConfig(string packageLibraryFolder)
433461
{
434-
ProcessHelper.RunAndCaptureOutput("dotnet", "new classlib -n NuGetConfigTestLibrary", packageLibraryFolder.Path);
435-
var projectFolder = Path.Combine(packageLibraryFolder.Path, "NuGetConfigTestLibrary");
436-
ProcessHelper.RunAndCaptureOutput("dotnet", $"pack -o {Path.Combine(packageLibraryFolder.Path, "packagePath")}", projectFolder);
437462
string nugetConfig = @"
438463
<configuration>
439464
<packageSources>
@@ -442,7 +467,7 @@ private static void CreateTestPackage(DisposableFolder packageLibraryFolder)
442467
</packageSources>
443468
></configuration>
444469
";
445-
File.WriteAllText(Path.Combine(packageLibraryFolder.Path, "NuGet.Config"), nugetConfig);
470+
File.WriteAllText(Path.Combine(packageLibraryFolder, "NuGet.Config"), nugetConfig);
446471
}
447472
}
448473
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy