diff --git a/src/Cli/dotnet/ToolPackage/IToolPackageDownloader.cs b/src/Cli/dotnet/ToolPackage/IToolPackageDownloader.cs index 816ead4cdf73..b65ad6522913 100644 --- a/src/Cli/dotnet/ToolPackage/IToolPackageDownloader.cs +++ b/src/Cli/dotnet/ToolPackage/IToolPackageDownloader.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Threading.Tasks; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; using Microsoft.DotNet.ToolPackage; using NuGet.Versioning; @@ -13,7 +14,8 @@ IToolPackage InstallPackage(PackageLocation packageLocation, PackageId packageId VerbosityOptions verbosity, VersionRange versionRange = null, string targetFramework = null, - bool isGlobalTool = false + bool isGlobalTool = false, + RestoreActionConfig restoreActionConfig = null ); } } diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs index be97e3937ab0..1a924551bfe6 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs @@ -72,7 +72,8 @@ public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId pa VerbosityOptions verbosity = VerbosityOptions.normal, VersionRange versionRange = null, string targetFramework = null, - bool isGlobalTool = false + bool isGlobalTool = false, + RestoreActionConfig restoreActionConfig = null ) { var packageRootDirectory = _toolPackageStore.GetRootPackageDirectory(packageId); @@ -95,7 +96,11 @@ public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId pa var toolDownloadDir = isGlobalTool ? _globalToolStageDir : _localToolDownloadDir; var assetFileDirectory = isGlobalTool ? _globalToolStageDir : _localToolAssetDir; - var nugetPackageDownloader = new NuGetPackageDownloader.NuGetPackageDownloader(toolDownloadDir, verboseLogger: nugetLogger, isNuGetTool: true); + var nugetPackageDownloader = new NuGetPackageDownloader.NuGetPackageDownloader( + toolDownloadDir, + verboseLogger: nugetLogger, + isNuGetTool: true, + restoreActionConfig: restoreActionConfig); var packageSourceLocation = new PackageSourceLocation(packageLocation.NugetConfig, packageLocation.RootConfigDirectory, null, packageLocation.AdditionalFeeds); diff --git a/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs b/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs index a9cbfe8d1a63..cf48d48c1607 100644 --- a/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs @@ -44,6 +44,8 @@ internal class ToolInstallGlobalOrToolPathCommand : CommandBase private readonly string _architectureOption; private IEnumerable _forwardRestoreArguments; + internal readonly RestoreActionConfig _restoreActionConfig; + public ToolInstallGlobalOrToolPathCommand( ParseResult parseResult, CreateToolPackageStoresAndDownloader createToolPackageStoreAndDownloader = null, @@ -74,11 +76,11 @@ public ToolInstallGlobalOrToolPathCommand( var configOption = parseResult.GetValue(ToolInstallCommandParser.ConfigOption); var sourceOption = parseResult.GetValue(ToolInstallCommandParser.AddSourceOption); var packageSourceLocation = new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), additionalSourceFeeds: sourceOption); - var restoreAction = new RestoreActionConfig(DisableParallel: parseResult.GetValue(ToolCommandRestorePassThroughOptions.DisableParallelOption), + _restoreActionConfig = new RestoreActionConfig(DisableParallel: parseResult.GetValue(ToolCommandRestorePassThroughOptions.DisableParallelOption), NoCache: parseResult.GetValue(ToolCommandRestorePassThroughOptions.NoCacheOption), IgnoreFailedSources: parseResult.GetValue(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption), Interactive: parseResult.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption)); - nugetPackageDownloader ??= new NuGetPackageDownloader(tempDir, verboseLogger: new NullLogger(), restoreActionConfig: restoreAction); + nugetPackageDownloader ??= new NuGetPackageDownloader(tempDir, verboseLogger: new NullLogger(), restoreActionConfig: _restoreActionConfig); _shellShimTemplateFinder = new ShellShimTemplateFinder(nugetPackageDownloader, tempDir, packageSourceLocation); _reporter = (reporter ?? Reporter.Output); @@ -132,7 +134,8 @@ public override int Execute() versionRange: versionRange, targetFramework: _framework, verbosity: _verbosity, - isGlobalTool: true + isGlobalTool: true, + restoreActionConfig: _restoreActionConfig ); NuGetFramework framework; diff --git a/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalCommand.cs b/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalCommand.cs index 9f9980ba9371..1cf4c5e01442 100644 --- a/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalCommand.cs @@ -3,6 +3,7 @@ using System.CommandLine; using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; using Microsoft.DotNet.Cli.ToolPackage; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ToolManifest; @@ -23,6 +24,8 @@ internal class ToolInstallLocalCommand : CommandBase private readonly string _explicitManifestFile; private readonly bool _createManifestIfNeeded; + internal readonly RestoreActionConfig _restoreActionConfig; + public ToolInstallLocalCommand( ParseResult parseResult, IToolPackageDownloader toolPackageDownloader = null, @@ -43,7 +46,11 @@ public ToolInstallLocalCommand( new ToolManifestFinder(new DirectoryPath(Directory.GetCurrentDirectory())); _toolManifestEditor = toolManifestEditor ?? new ToolManifestEditor(); _localToolsResolverCache = localToolsResolverCache ?? new LocalToolsResolverCache(); - _toolLocalPackageInstaller = new ToolInstallLocalInstaller(parseResult, toolPackageDownloader); + _restoreActionConfig = new RestoreActionConfig(DisableParallel: parseResult.GetValue(ToolCommandRestorePassThroughOptions.DisableParallelOption), + NoCache: parseResult.GetValue(ToolCommandRestorePassThroughOptions.NoCacheOption), + IgnoreFailedSources: parseResult.GetValue(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption), + Interactive: parseResult.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption)); + _toolLocalPackageInstaller = new ToolInstallLocalInstaller(parseResult, toolPackageDownloader, _restoreActionConfig); } public override int Execute() diff --git a/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalInstaller.cs b/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalInstaller.cs index 4c370c34523f..1b778332aa69 100644 --- a/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalInstaller.cs +++ b/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalInstaller.cs @@ -4,6 +4,7 @@ using System.CommandLine; using System.IO; using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; using Microsoft.DotNet.Cli.ToolPackage; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ToolPackage; @@ -24,10 +25,12 @@ internal class ToolInstallLocalInstaller private readonly string _configFilePath; private readonly string[] _sources; private readonly VerbosityOptions _verbosity; + private readonly RestoreActionConfig _restoreActionConfig; public ToolInstallLocalInstaller( ParseResult parseResult, - IToolPackageDownloader toolPackageDownloader = null) + IToolPackageDownloader toolPackageDownloader = null, + RestoreActionConfig restoreActionConfig = null) { _parseResult = parseResult; _packageId = new PackageId(parseResult.GetValue(ToolInstallCommandParser.PackageIdArgument)); @@ -43,7 +46,7 @@ public ToolInstallLocalInstaller( additionalRestoreArguments: parseResult.OptionValuesToBeForwarded(ToolInstallCommandParser.GetCommand())); _toolPackageStore = toolPackageStoresAndDownloader.store; _toolPackageDownloader = toolPackageDownloader?? toolPackageStoresAndDownloader.downloader; - + _restoreActionConfig = restoreActionConfig; TargetFrameworkToInstall = BundledTargetFramework.GetTargetFrameworkMoniker(); } @@ -76,7 +79,8 @@ public IToolPackage Install(FilePath manifestFile) _packageId, verbosity: _verbosity, versionRange, - TargetFrameworkToInstall + TargetFrameworkToInstall, + restoreActionConfig: _restoreActionConfig ); return toolDownloadedPackage; diff --git a/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateGlobalOrToolPathCommand.cs b/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateGlobalOrToolPathCommand.cs index 86a737cb6693..f2b90365ceac 100644 --- a/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateGlobalOrToolPathCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateGlobalOrToolPathCommand.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.EnvironmentAbstractions; using NuGet.Versioning; using Microsoft.DotNet.Cli.ToolPackage; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; namespace Microsoft.DotNet.Tools.Tool.Update { @@ -38,6 +39,8 @@ internal class ToolUpdateGlobalOrToolPathCommand : CommandBase private readonly IEnumerable _forwardRestoreArguments; private readonly string _packageVersion; + internal readonly RestoreActionConfig _restoreActionConfig; + public ToolUpdateGlobalOrToolPathCommand(ParseResult parseResult, CreateToolPackageStoresAndDownloaderAndUninstaller createToolPackageStoreDownloaderUninstaller = null, CreateShellShimRepository createShellShimRepository = null, @@ -60,6 +63,11 @@ public ToolUpdateGlobalOrToolPathCommand(ParseResult parseResult, _createShellShimRepository = createShellShimRepository ?? ShellShimRepositoryFactory.CreateShellShimRepository; + _restoreActionConfig = new RestoreActionConfig(DisableParallel: parseResult.GetValue(ToolCommandRestorePassThroughOptions.DisableParallelOption), + NoCache: parseResult.GetValue(ToolCommandRestorePassThroughOptions.NoCacheOption), + IgnoreFailedSources: parseResult.GetValue(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption), + Interactive: parseResult.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption)); + _reporter = (reporter ?? Reporter.Output); _errorReporter = (reporter ?? Reporter.Error); } @@ -111,7 +119,8 @@ public override int Execute() versionRange: versionRange, targetFramework: _framework, verbosity: _verbosity, - isGlobalTool: true + isGlobalTool: true, + restoreActionConfig: _restoreActionConfig ); EnsureVersionIsHigher(oldPackageNullable, newInstalledPackage); diff --git a/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateLocalCommand.cs b/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateLocalCommand.cs index 8118adee5229..cf48d4ab6092 100644 --- a/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateLocalCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateLocalCommand.cs @@ -3,6 +3,7 @@ using System.CommandLine; using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; using Microsoft.DotNet.Cli.ToolPackage; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ToolManifest; @@ -26,6 +27,8 @@ internal class ToolUpdateLocalCommand : CommandBase private readonly PackageId _packageId; private readonly string _explicitManifestFile; + internal readonly RestoreActionConfig _restoreActionConfig; + public ToolUpdateLocalCommand( ParseResult parseResult, IToolPackageDownloader toolPackageDownloader = null, @@ -59,7 +62,12 @@ public ToolUpdateLocalCommand( _toolManifestEditor = toolManifestEditor ?? new ToolManifestEditor(); _localToolsResolverCache = localToolsResolverCache ?? new LocalToolsResolverCache(); - _toolLocalPackageInstaller = new ToolInstallLocalInstaller(parseResult, toolPackageDownloader); + _restoreActionConfig = new RestoreActionConfig(DisableParallel: parseResult.GetValue(ToolCommandRestorePassThroughOptions.DisableParallelOption), + NoCache: parseResult.GetValue(ToolCommandRestorePassThroughOptions.NoCacheOption), + IgnoreFailedSources: parseResult.GetValue(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption), + Interactive: parseResult.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption)); + + _toolLocalPackageInstaller = new ToolInstallLocalInstaller(parseResult, toolPackageDownloader, _restoreActionConfig); _toolInstallLocalCommand = new Lazy( () => new ToolInstallLocalCommand( parseResult, diff --git a/src/Tests/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageDownloaderMock.cs b/src/Tests/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageDownloaderMock.cs index 8ce41aef115d..73c95c137e38 100644 --- a/src/Tests/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageDownloaderMock.cs +++ b/src/Tests/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageDownloaderMock.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text.Json; using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; using Microsoft.DotNet.Cli.ToolPackage; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ToolPackage; @@ -96,7 +97,8 @@ public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId pa VerbosityOptions verbosity, VersionRange versionRange = null, string targetFramework = null, - bool isGlobalTool = false + bool isGlobalTool = false, + RestoreActionConfig restoreActionConfig = null ) { string rollbackDirectory = null; diff --git a/src/Tests/dotnet.Tests/CommandTests/ToolInstallGlobalOrToolPathCommandTests.cs b/src/Tests/dotnet.Tests/CommandTests/ToolInstallGlobalOrToolPathCommandTests.cs index e0c4e247d4fb..99a70b75dd1f 100644 --- a/src/Tests/dotnet.Tests/CommandTests/ToolInstallGlobalOrToolPathCommandTests.cs +++ b/src/Tests/dotnet.Tests/CommandTests/ToolInstallGlobalOrToolPathCommandTests.cs @@ -63,6 +63,30 @@ public ToolInstallGlobalOrToolPathCommandTests(ITestOutputHelper log): base(log) _parseResult = Parser.Instance.Parse($"dotnet tool install -g {PackageId}"); } + [Fact] + public void WhenPassingRestoreActionConfigOptions() + { + var parseResult = Parser.Instance.Parse($"dotnet tool install -g {PackageId} --ignore-failed-sources"); + var toolInstallCommand = new ToolInstallGlobalOrToolPathCommand(parseResult); + toolInstallCommand._restoreActionConfig.IgnoreFailedSources.Should().BeTrue(); + } + + [Fact] + public void WhenPassingIgnoreFailedSourcesItShouldNotThrow() + { + _fileSystem.File.WriteAllText(Path.Combine(_temporaryDirectory, "nuget.config"), _nugetConfigWithInvalidSources); + + var toolInstallGlobalOrToolPathCommand = new ToolInstallGlobalOrToolPathCommand( + _parseResult, + _createToolPackageStoresAndDownloader, + _createShellShimRepository, + _environmentPathInstructionMock, + _reporter); + + toolInstallGlobalOrToolPathCommand.Execute().Should().Be(0); + _fileSystem.File.Delete(Path.Combine(_temporaryDirectory, "nuget.config")); + } + [Fact] public void WhenRunWithPackageIdItShouldCreateValidShim() { @@ -630,6 +654,16 @@ public void SetPermission(string path, string chmodArgument) { } } + + private string _nugetConfigWithInvalidSources = @"{ + + + + + + + +}"; } } diff --git a/src/Tests/dotnet.Tests/CommandTests/ToolInstallLocalCommandTests.cs b/src/Tests/dotnet.Tests/CommandTests/ToolInstallLocalCommandTests.cs index 898223f16c62..55f8fd56df83 100644 --- a/src/Tests/dotnet.Tests/CommandTests/ToolInstallLocalCommandTests.cs +++ b/src/Tests/dotnet.Tests/CommandTests/ToolInstallLocalCommandTests.cs @@ -96,6 +96,32 @@ public ToolInstallLocalCommandTests(ITestOutputHelper log):base(log) 1); } + [Fact] + public void WhenPassingRestoreActionConfigOptions() + { + var parseResult = Parser.Instance.Parse($"dotnet tool install {_packageIdA.ToString()} --ignore-failed-sources"); + var command = new ToolInstallLocalCommand(parseResult); + command._restoreActionConfig.IgnoreFailedSources.Should().BeTrue(); + } + + [Fact] + public void WhenPassingIgnoreFailedSourcesItShouldNotThrow() + { + _fileSystem.File.WriteAllText(Path.Combine(_temporaryDirectory, "nuget.config"), _nugetConfigWithInvalidSources); + var parseResult = Parser.Instance.Parse($"dotnet tool install {_packageIdA.ToString()} --ignore-failed-sources"); + var installLocalCommand = new ToolInstallLocalCommand( + parseResult, + _toolPackageDownloaderMock, + _toolManifestFinder, + _toolManifestEditor, + _localToolsResolverCache, + _reporter); + + installLocalCommand.Execute().Should().Be(0); + + _fileSystem.File.Delete(Path.Combine(_temporaryDirectory, "nuget.config")); + } + [Fact] public void WhenRunWithPackageIdItShouldSaveToCacheAndAddToManifestFile() { @@ -440,6 +466,16 @@ out RestoredCommand restoredCommand ""isRoot"":true, ""tools"":{ } +}"; + + private string _nugetConfigWithInvalidSources = @"{ + + + + + + + }"; } } diff --git a/src/Tests/dotnet.Tests/CommandTests/ToolUpdateGlobalOrToolPathCommandTests.cs b/src/Tests/dotnet.Tests/CommandTests/ToolUpdateGlobalOrToolPathCommandTests.cs index b5eb57b1ea78..366eaee12edd 100644 --- a/src/Tests/dotnet.Tests/CommandTests/ToolUpdateGlobalOrToolPathCommandTests.cs +++ b/src/Tests/dotnet.Tests/CommandTests/ToolUpdateGlobalOrToolPathCommandTests.cs @@ -12,6 +12,8 @@ using Microsoft.DotNet.ShellShim; using System.CommandLine; using Parser = Microsoft.DotNet.Cli.Parser; +using Microsoft.DotNet.InternalAbstractions; +using Microsoft.DotNet.Tools.Tool.Uninstall; namespace Microsoft.DotNet.Tests.Commands.Tool { @@ -28,14 +30,15 @@ public class ToolUpdateGlobalOrToolPathCommandTests private const string HigherPreviewPackageVersion = "1.0.5-preview3"; private readonly string _shimsDirectory; private readonly string _toolsDirectory; + private readonly string _tempDirectory; public ToolUpdateGlobalOrToolPathCommandTests() { _reporter = new BufferedReporter(); _fileSystem = new FileSystemMockBuilder().UseCurrentSystemTemporaryDirectory().Build(); - var tempDirectory = _fileSystem.Directory.CreateTemporaryDirectory().DirectoryPath; - _shimsDirectory = Path.Combine(tempDirectory, "shims"); - _toolsDirectory = Path.Combine(tempDirectory, "tools"); + _tempDirectory = _fileSystem.Directory.CreateTemporaryDirectory().DirectoryPath; + _shimsDirectory = Path.Combine(_tempDirectory, "shims"); + _toolsDirectory = Path.Combine(_tempDirectory, "tools"); _environmentPathInstructionMock = new EnvironmentPathInstructionMock(_reporter, _shimsDirectory); _store = new ToolPackageStoreMock(new DirectoryPath(_toolsDirectory), _fileSystem); _mockFeeds = new List @@ -68,6 +71,25 @@ public ToolUpdateGlobalOrToolPathCommandTests() }; } + [Fact] + public void WhenPassingRestoreActionConfigOptions() + { + var parseResult = Parser.Instance.Parse($"dotnet tool update -g {_packageId} --ignore-failed-sources"); + var toolUpdateCommand = new ToolUpdateGlobalOrToolPathCommand(parseResult); + toolUpdateCommand._restoreActionConfig.IgnoreFailedSources.Should().BeTrue(); + } + + [Fact] + public void WhenPassingIgnoreFailedSourcesItShouldNotThrow() + { + _fileSystem.File.WriteAllText(Path.Combine(_tempDirectory, "nuget.config"), _nugetConfigWithInvalidSources); + + var command = CreateUpdateCommand($"-g {_packageId} --ignore-failed-sources"); + + command.Execute().Should().Be(0); + _fileSystem.File.Delete(Path.Combine(_tempDirectory, "nuget.config")); + } + [Fact] public void GivenANonFeedExistentPackageItErrors() { @@ -373,6 +395,16 @@ private ShellShimRepository GetMockedShellShimRepository() appHostShellShimMaker: new AppHostShellShimMakerMock(_fileSystem), filePermissionSetter: new ToolInstallGlobalOrToolPathCommandTests.NoOpFilePermissionSetter()); } + + private string _nugetConfigWithInvalidSources = @"{ + + + + + + + +}"; } } diff --git a/src/Tests/dotnet.Tests/CommandTests/ToolUpdateLocalCommandTests.cs b/src/Tests/dotnet.Tests/CommandTests/ToolUpdateLocalCommandTests.cs index 78c4958e1c18..760f50b58051 100644 --- a/src/Tests/dotnet.Tests/CommandTests/ToolUpdateLocalCommandTests.cs +++ b/src/Tests/dotnet.Tests/CommandTests/ToolUpdateLocalCommandTests.cs @@ -7,6 +7,7 @@ using Microsoft.DotNet.ToolManifest; using Microsoft.DotNet.ToolPackage; using Microsoft.DotNet.Tools.Tests.ComponentMocks; +using Microsoft.DotNet.Tools.Tool.Install; using Microsoft.DotNet.Tools.Tool.Restore; using Microsoft.DotNet.Tools.Tool.Update; using Microsoft.Extensions.DependencyModel.Tests; @@ -112,6 +113,32 @@ public ToolUpdateLocalCommandTests() _reporter); } + [Fact] + public void WhenPassingRestoreActionConfigOptions() + { + var parseResult = Parser.Instance.Parse($"dotnet tool update {_packageIdA.ToString()} --ignore-failed-sources"); + var command = new ToolUpdateLocalCommand(parseResult); + command._restoreActionConfig.IgnoreFailedSources.Should().BeTrue(); + } + + [Fact] + public void WhenPassingIgnoreFailedSourcesItShouldNotThrow() + { + _fileSystem.File.WriteAllText(Path.Combine(_temporaryDirectory, "nuget.config"), _nugetConfigWithInvalidSources); + var parseResult = Parser.Instance.Parse($"dotnet tool update {_packageIdA.ToString()} --ignore-failed-sources"); + var updateLocalCommand = new ToolUpdateLocalCommand( + parseResult, + _toolPackageDownloaderMock, + _toolManifestFinder, + _toolManifestEditor, + _localToolsResolverCache, + _reporter); + + updateLocalCommand.Execute().Should().Be(0); + + _fileSystem.File.Delete(Path.Combine(_temporaryDirectory, "nuget.config")); + } + [Fact] public void WhenRunWithPackageIdItShouldUpdateFromManifestFile() { @@ -349,6 +376,16 @@ out RestoredCommand restoredCommand ""version"": 1, ""isRoot"": false, ""tools"": {} +}"; + + private string _nugetConfigWithInvalidSources = @"{ + + + + + + + }"; } }