Skip to content

Commit 610c1b8

Browse files
Copilotdsplaisted
andcommitted
Remove .config subfolder creation for tool manifests by default
Co-authored-by: dsplaisted <[email protected]>
1 parent eab62eb commit 610c1b8

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

src/Cli/dotnet/ToolManifest/ToolManifestFinder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ private string WriteManifestFile(DirectoryPath folderPath)
250250
"tools": {}
251251
}
252252
""";
253-
_fileSystem.Directory.CreateDirectory(Path.Combine(folderPath.Value, Constants.DotConfigDirectoryName));
254-
string manifestFileLocation = Path.Combine(folderPath.Value, Constants.DotConfigDirectoryName, Constants.ToolManifestFileName);
253+
string manifestFileLocation = Path.Combine(folderPath.Value, Constants.ToolManifestFileName);
255254
_fileSystem.File.WriteAllText(manifestFileLocation, manifestFileContent);
256255

257256
return manifestFileLocation;
File renamed without changes.

test/dotnet.Tests/CommandTests/Tool/Install/ToolInstallLocalCommandTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManife
418418
_reporter);
419419

420420
installLocalCommand.Execute().Should().Be(0);
421-
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, ".config", "dotnet-tools.json")).Should().BeTrue();
421+
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, "dotnet-tools.json")).Should().BeTrue();
422422
}
423423

424424
[Fact]
@@ -440,7 +440,7 @@ public void GivenNoManifestFileItUsesCreateManifestIfNeededByDefault()
440440
_reporter);
441441

442442
installLocalCommand.Execute().Should().Be(0);
443-
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, ".config", "dotnet-tools.json")).Should().BeTrue();
443+
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, "dotnet-tools.json")).Should().BeTrue();
444444
}
445445

446446
[Fact]
@@ -465,7 +465,7 @@ public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManife
465465
_reporter);
466466

467467
installLocalCommand.Execute().Should().Be(0);
468-
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, ".config", "dotnet-tools.json")).Should().BeTrue();
468+
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, "dotnet-tools.json")).Should().BeTrue();
469469
}
470470

471471
[Fact]
@@ -487,7 +487,7 @@ public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManife
487487
_reporter);
488488

489489
installLocalCommand.Execute().Should().Be(0);
490-
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, ".config", "dotnet-tools.json")).Should().BeTrue();
490+
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, "dotnet-tools.json")).Should().BeTrue();
491491
}
492492

493493
private IToolPackageDownloader GetToolToolPackageInstallerWithPreviewInFeed()

test/dotnet.Tests/ToolManifestTests/ToolManifestFinderTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,22 @@ public void GivenNoManifestInspectShouldNotThrow()
764764
a.Should().NotThrow();
765765
}
766766

767+
[Fact]
768+
public void GivenNoManifestFileWhenCreatingNewManifestItShouldCreateInDirectFolder()
769+
{
770+
var toolManifest =
771+
new ToolManifestFinder(
772+
new DirectoryPath(_testDirectoryRoot),
773+
_fileSystem,
774+
new FakeDangerousFileDetector());
775+
776+
FilePath createdManifest = toolManifest.FindFirst(createIfNotFound: true);
777+
778+
createdManifest.Value.Should().Be(Path.Combine(_testDirectoryRoot, "dotnet-tools.json"));
779+
_fileSystem.File.Exists(Path.Combine(_testDirectoryRoot, "dotnet-tools.json")).Should().BeTrue();
780+
_fileSystem.Directory.Exists(Path.Combine(_testDirectoryRoot, ".config")).Should().BeFalse("New manifests should not create .config directories");
781+
}
782+
767783
private string _jsonContent =
768784
@"{
769785
""version"":1,

0 commit comments

Comments
 (0)