Skip to content

dotnet tool install --local works by default, by creating a manifest by default, utilizing --create-manifest-if-needed #48906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6ac6981
Set the default value of Create Manifest If Needed to True
nagilson May 12, 2025
6c059f9
Add test to show it uses manifest if needed by default
nagilson May 12, 2025
9973ff0
Update Tests
nagilson May 12, 2025
ac1eae1
Fix Test
nagilson May 12, 2025
11d59e6
Accept 'false' instead of just empty arity and add 0 arity test
nagilson May 12, 2025
ff21731
Update completions test bash
nagilson May 12, 2025
fbc755f
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson May 12, 2025
99b0d0e
Update snapshots
nagilson May 12, 2025
a3124b9
Merge branch 'nagilson-create-tool-manifest-by-default' of https://gi…
nagilson May 12, 2025
85792ad
Remove `ToolInstallNoManifestGuide` and Fix `CannotFindAManifestFile `
nagilson Jun 2, 2025
878dd64
Update xlf
nagilson Jun 2, 2025
f99aa7d
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 2, 2025
dff877f
update xlf again
nagilson Jun 3, 2025
ea6a8c1
Remove ListOfSearched
nagilson Jun 4, 2025
fb759dc
Update XLF
nagilson Jun 4, 2025
7c86837
Fix Test
nagilson Jun 4, 2025
e9d6d70
Fix test string format
nagilson Jun 6, 2025
e5823e9
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 6, 2025
80cf895
Fix variables in restore-toolset.sh/.ps1
akoeplinger Jun 6, 2025
3979190
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 10, 2025
76fe22d
Fix all of the tests
nagilson Jun 10, 2025
2543536
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ internal static class ToolInstallCommandParser
public static readonly Option<bool> CreateManifestIfNeededOption = new("--create-manifest-if-needed")
{
Description = CliCommandStrings.CreateManifestIfNeededOptionDescription,
Arity = ArgumentArity.Zero
Arity = ArgumentArity.ZeroOrOne,
DefaultValueFactory = _ => true,
};

public static readonly Option<bool> AllowPackageDowngradeOption = new("--allow-downgrade")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,41 @@ public void WhenRunWithPackageIdItShouldSaveToCacheAndAddToManifestFile()
}

[Fact]
public void GivenNoManifestFileItShouldThrow()
public void GivenCreateManifestIfNeededWithoutArgumentTheDefaultIsTrueForLegacyBehavior()
{
_fileSystem.File.Delete(_manifestFilePath);
var toolInstallLocalCommand = GetDefaultTestToolInstallLocalCommand();
ParseResult parseResult =
Parser.Instance.Parse(
$"dotnet tool install {_packageIdA.ToString()} --create-manifest-if-needed");

Action a = () => toolInstallLocalCommand.Execute();
a.Should().Throw<GracefulException>()
.And.Message.Should()
.Contain(CliStrings.CannotFindAManifestFile);
var toolInstallLocalCommand = new ToolInstallLocalCommand(
parseResult,
_packageIdA,
_toolPackageDownloaderMock,
_toolManifestFinder,
_toolManifestEditor,
_localToolsResolverCache,
_reporter);

toolInstallLocalCommand.Execute().Should().Be(0);
}

[Fact]
public void GivenNoManifestFileItShouldThrowAndContainNoManifestGuide()
{
_fileSystem.File.Delete(_manifestFilePath);
var toolInstallLocalCommand = GetDefaultTestToolInstallLocalCommand();
ParseResult parseResult =
Parser.Instance.Parse(
$"dotnet tool install {_packageIdA.ToString()} --create-manifest-if-needed false");

var toolInstallLocalCommand = new ToolInstallLocalCommand(
parseResult,
_packageIdA,
_toolPackageDownloaderMock,
_toolManifestFinder,
_toolManifestEditor,
_localToolsResolverCache,
_reporter);

Action a = () => toolInstallLocalCommand.Execute();
a.Should().Throw<GracefulException>()
Expand Down Expand Up @@ -408,6 +427,28 @@ public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManife
_fileSystem.File.Exists(Path.Combine(_temporaryDirectory, ".config", "dotnet-tools.json")).Should().BeTrue();
}

[Fact]
public void GivenNoManifestFileItUsesCreateManifestIfNeededByDefault()
{
_fileSystem.File.Delete(_manifestFilePath);

ParseResult parseResult =
Parser.Instance.Parse(
$"dotnet tool install {_packageIdA.ToString()}");

var installLocalCommand = new ToolInstallLocalCommand(
parseResult,
_packageIdA,
_toolPackageDownloaderMock,
_toolManifestFinder,
_toolManifestEditor,
_localToolsResolverCache,
_reporter);

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

[Fact]
public void GivenNoManifestFileAndCreateManifestIfNeededFlagItShouldCreateManifestInSln()
{
Expand Down
Loading