@@ -315,6 +315,35 @@ out ToolCommand restoredCommand
315
315
"But restore do not need to 'revert' since it just set in nuget global directory" ) ;
316
316
}
317
317
318
+ [ Fact ]
319
+ public void WhenRunWithExistingManifestInConfigDirectoryItShouldAddToExistingManifest ( )
320
+ {
321
+ // Test backward compatibility: ensure tools can be added to existing manifests in .config directories
322
+ _fileSystem . File . Delete ( _manifestFilePath ) ;
323
+ var configDirectory = Path . Combine ( _temporaryDirectory , ".config" ) ;
324
+ _fileSystem . Directory . CreateDirectory ( configDirectory ) ;
325
+ var configManifestPath = Path . Combine ( configDirectory , "dotnet-tools.json" ) ;
326
+ _fileSystem . File . WriteAllText ( configManifestPath , _jsonContent ) ;
327
+
328
+ var toolInstallLocalCommand = GetDefaultTestToolInstallLocalCommand ( ) ;
329
+
330
+ toolInstallLocalCommand . Execute ( ) . Should ( ) . Be ( 0 ) ;
331
+
332
+ // Verify the tool was added to the existing .config manifest
333
+ var manifestPackages = _toolManifestFinder . Find ( ) ;
334
+ manifestPackages . Should ( ) . HaveCount ( 1 ) ;
335
+ manifestPackages . First ( ) . PackageId . Should ( ) . Be ( _packageIdA ) ;
336
+
337
+ // Verify that the manifest under the .config folder has been updated
338
+ _fileSystem . File . Exists ( configManifestPath ) . Should ( ) . BeTrue ( "The .config manifest file should exist" ) ;
339
+ var configManifestContent = _fileSystem . File . ReadAllText ( configManifestPath ) ;
340
+ configManifestContent . Should ( ) . Contain ( _packageIdA . ToString ( ) , "The .config manifest should contain the installed tool" ) ;
341
+ configManifestContent . Should ( ) . NotBe ( _jsonContent , "The .config manifest should have been updated with the new tool" ) ;
342
+
343
+ // Verify that no manifest exists in the root folder after the install command is run
344
+ _fileSystem . File . Exists ( _manifestFilePath ) . Should ( ) . BeFalse ( "No manifest should exist in the root folder" ) ;
345
+ }
346
+
318
347
private ToolInstallLocalCommand GetDefaultTestToolInstallLocalCommand ( )
319
348
{
320
349
return new ToolInstallLocalCommand (
@@ -418,7 +447,7 @@ public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManife
418
447
_reporter ) ;
419
448
420
449
installLocalCommand . Execute ( ) . Should ( ) . Be ( 0 ) ;
421
- _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , ".config" , " dotnet-tools.json") ) . Should ( ) . BeTrue ( ) ;
450
+ _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , "dotnet-tools.json" ) ) . Should ( ) . BeTrue ( ) ;
422
451
}
423
452
424
453
[ Fact ]
@@ -440,7 +469,7 @@ public void GivenNoManifestFileItUsesCreateManifestIfNeededByDefault()
440
469
_reporter ) ;
441
470
442
471
installLocalCommand . Execute ( ) . Should ( ) . Be ( 0 ) ;
443
- _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , ".config" , " dotnet-tools.json") ) . Should ( ) . BeTrue ( ) ;
472
+ _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , "dotnet-tools.json" ) ) . Should ( ) . BeTrue ( ) ;
444
473
}
445
474
446
475
[ Fact ]
@@ -465,7 +494,7 @@ public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManife
465
494
_reporter ) ;
466
495
467
496
installLocalCommand . Execute ( ) . Should ( ) . Be ( 0 ) ;
468
- _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , ".config" , " dotnet-tools.json") ) . Should ( ) . BeTrue ( ) ;
497
+ _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , "dotnet-tools.json" ) ) . Should ( ) . BeTrue ( ) ;
469
498
}
470
499
471
500
[ Fact ]
@@ -487,7 +516,7 @@ public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManife
487
516
_reporter ) ;
488
517
489
518
installLocalCommand . Execute ( ) . Should ( ) . Be ( 0 ) ;
490
- _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , ".config" , " dotnet-tools.json") ) . Should ( ) . BeTrue ( ) ;
519
+ _fileSystem . File . Exists ( Path . Combine ( _temporaryDirectory , "dotnet-tools.json" ) ) . Should ( ) . BeTrue ( ) ;
491
520
}
492
521
493
522
private IToolPackageDownloader GetToolToolPackageInstallerWithPreviewInFeed ( )
0 commit comments