@@ -391,29 +391,58 @@ public void ShouldHandleLocalNuGetConfigWithRelativePath()
391
391
392
392
using ( var packageLibraryFolder = new DisposableFolder ( ) )
393
393
{
394
- ProcessHelper . RunAndCaptureOutput ( "dotnet" , "new classlib -n NuGetConfigTestLibrary" , packageLibraryFolder . Path ) ;
395
- var projectFolder = Path . Combine ( packageLibraryFolder . Path , "NuGetConfigTestLibrary" ) ;
396
- ProcessHelper . RunAndCaptureOutput ( "dotnet" , $ "pack -o { Path . Combine ( packageLibraryFolder . Path , "packagePath" ) } ", projectFolder ) ;
397
- string nugetConfig = @"
394
+ CreateTestPackage ( packageLibraryFolder ) ;
395
+
396
+ string pathToScriptFile = CreateTestScript ( packageLibraryFolder . Path ) ;
397
+
398
+ var result = ScriptTestRunner . Default . Execute ( pathToScriptFile ) ;
399
+ Assert . Contains ( "Success" , result . output ) ;
400
+ }
401
+ }
402
+
403
+ [ Fact ]
404
+ public void ShouldHandleLocalNuGetConfigWithRelativePathInParentFolder ( )
405
+ {
406
+ TestPathUtils . RemovePackageFromGlobalNugetCache ( "NuGetConfigTestLibrary" ) ;
407
+
408
+ using ( var packageLibraryFolder = new DisposableFolder ( ) )
409
+ {
410
+ CreateTestPackage ( packageLibraryFolder ) ;
411
+
412
+ var scriptFolder = Path . Combine ( packageLibraryFolder . Path , "ScriptFolder" ) ;
413
+ Directory . CreateDirectory ( scriptFolder ) ;
414
+ string pathToScriptFile = CreateTestScript ( scriptFolder ) ;
415
+
416
+ var result = ScriptTestRunner . Default . Execute ( pathToScriptFile ) ;
417
+ Assert . Contains ( "Success" , result . output ) ;
418
+ }
419
+ }
420
+
421
+ private static string CreateTestScript ( string scriptFolder )
422
+ {
423
+ string script = @"
424
+ #r ""nuget:NuGetConfigTestLibrary, 1.0.0""
425
+ WriteLine(""Success"");
426
+ " ;
427
+ string pathToScriptFile = Path . Combine ( scriptFolder , "testscript.csx" ) ;
428
+ File . WriteAllText ( pathToScriptFile , script ) ;
429
+ return pathToScriptFile ;
430
+ }
431
+
432
+ private static void CreateTestPackage ( DisposableFolder packageLibraryFolder )
433
+ {
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 ) ;
437
+ string nugetConfig = @"
398
438
<configuration>
399
439
<packageSources>
400
440
<clear/>
401
441
<add key=""localSource"" value=""packagePath""/>
402
442
</packageSources>
403
443
></configuration>
404
444
" ;
405
- File . WriteAllText ( Path . Combine ( packageLibraryFolder . Path , "NuGet.Config" ) , nugetConfig ) ;
406
-
407
- string script = @"
408
- #r ""nuget:NuGetConfigTestLibrary, 1.0.0""
409
- WriteLine(""Success"");
410
- " ;
411
- string pathToScriptFile = Path . Combine ( packageLibraryFolder . Path , "testscript.csx" ) ;
412
- File . WriteAllText ( pathToScriptFile , script ) ;
413
-
414
- var result = ScriptTestRunner . Default . Execute ( pathToScriptFile ) ;
415
- Assert . Contains ( "Success" , result . output ) ;
416
- }
445
+ File . WriteAllText ( Path . Combine ( packageLibraryFolder . Path , "NuGet.Config" ) , nugetConfig ) ;
417
446
}
418
447
}
419
448
}
0 commit comments