diff --git a/README.md b/README.md index 2fbcb17..cd0d141 100644 --- a/README.md +++ b/README.md @@ -39,17 +39,18 @@ Simply run `dotnet commands` to see the options, which are similar to this: ```` .NET Commands + Usage: - dotnet commands install [--force] [--pre] [--verbose] + dotnet commands install [@] [--force] [--pre] [--verbose] dotnet commands uninstall [ --verbose] dotnet commands update ( | all) [--pre] [--verbose] - dotnet commands list [--verbose] - dotnet commands ls [--verbose] + dotnet commands (list|ls) [--verbose] dotnet commands --help dotnet commands --version + Options: --force Installs even if package was already installed. Optional. - --pre Include pre-release versions. Optional. + --pre Include pre-release versions. Ignored if version is supplied. Optional. --verbose Verbose. Optional. --help -h Show this screen. --version -v Show version. diff --git a/src/dotnet-commands/CommandDirectory.cs b/src/dotnet-commands/CommandDirectory.cs index 0981ed2..f7dc355 100644 --- a/src/dotnet-commands/CommandDirectory.cs +++ b/src/dotnet-commands/CommandDirectory.cs @@ -1,3 +1,4 @@ +using NuGet.Versioning; using System.IO; namespace DotNetCommands @@ -23,10 +24,10 @@ public CommandDirectory(string baseDir) Directory.CreateDirectory(binDir); } - public string GetDirectoryForPackage(string packageName, string packageVersion = null) => + public string GetDirectoryForPackage(string packageName, SemanticVersion packageVersion = null) => packageVersion == null ? Path.Combine(PackagesDir, packageName) - : Path.Combine(PackagesDir, packageName, packageVersion); + : Path.Combine(PackagesDir, packageName, packageVersion.ToString()); public string GetBinFile(string fileName) => Path.Combine(binDir, fileName.Replace('/', Path.DirectorySeparatorChar)); diff --git a/src/dotnet-commands/Installer.cs b/src/dotnet-commands/Installer.cs index 0c82822..c8f28c4 100644 --- a/src/dotnet-commands/Installer.cs +++ b/src/dotnet-commands/Installer.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; +using NuGet.Versioning; namespace DotNetCommands { @@ -17,7 +18,7 @@ public Installer(CommandDirectory commandDirectory) this.commandDirectory = commandDirectory; } - public async Task InstallAsync(string packageName, bool force, bool includePreRelease) + public async Task InstallAsync(string packageName, SemanticVersion packageVersion, bool force, bool includePreRelease) { WriteLineIfVerbose($"Installing {packageName}..."); PackageInfo packageInfo; @@ -25,7 +26,7 @@ public async Task InstallAsync(string packageName, bool force, bool includ { using (var downloader = new NugetDownloader(commandDirectory)) { - packageInfo = await downloader.DownloadAndExtractNugetAsync(packageName, force, includePreRelease); + packageInfo = await downloader.DownloadAndExtractNugetAsync(packageName, packageVersion, force, includePreRelease); if (packageInfo == null) return false; } } diff --git a/src/dotnet-commands/NugetDownloader.cs b/src/dotnet-commands/NugetDownloader.cs index cfb4cf9..308239a 100644 --- a/src/dotnet-commands/NugetDownloader.cs +++ b/src/dotnet-commands/NugetDownloader.cs @@ -16,7 +16,7 @@ namespace DotNetCommands public sealed class NugetDownloader : IDisposable { private readonly CommandDirectory commandDirectory; - private IList sourceInfos; + private readonly IList sourceInfos; public NugetDownloader(CommandDirectory commandDirectory) { @@ -59,6 +59,39 @@ public async Task GetLatestVersionAsync(string packageName, bool include return (await GetLatestVersionAndSourceInfoAsync(packageName, includePreRelease))?.Version.ToString(); } + private async Task GetSpecificVersionAndSourceInfoAsync(string packageName, SemanticVersion packageVersion) + { + foreach (var sourceInfo in sourceInfos) + { + WriteLineIfVerbose($"Searching for '{packageName}@{packageVersion.ToString()}' on '{sourceInfo.Source.Name}'..."); + NugetVersion latestNugetVersion; + try + { + latestNugetVersion = await sourceInfo.GetPackageAsync(packageName, packageVersion, true); + } + catch (Exception ex) + { + WriteLine($"Error when getting '{packageName}@{packageVersion.ToString()}'. Source used: '{sourceInfo.Source.Name}'."); + WriteLineIfVerbose($"Error details: {ex.ToString()}'."); + return null; + } + if (latestNugetVersion == null) + { + WriteLineIfVerbose($"Could not get a version for '{packageName}@{packageVersion.ToString()}' on '{sourceInfo.Source.Name}'."); + continue; + } + else + { + WriteLineIfVerbose($"Found version '{latestNugetVersion.Version}' for '{packageName}@{packageVersion.ToString()}' on '{sourceInfo.Source.Name}'."); + return latestNugetVersion; + } + } + WriteLine($"Package '{packageName}' not found. Sources used:"); + foreach (var source in sourceInfos.Select(p => p.Source)) + WriteLine($" - {source.Name}: {source.Source}"); + return null; + } + private async Task GetLatestVersionAndSourceInfoAsync(string packageName, bool includePreRelease) { NugetVersion currentNugetVersion = null; @@ -68,7 +101,7 @@ private async Task GetLatestVersionAndSourceInfoAsync(string packa NugetVersion latestNugetVersion; try { - latestNugetVersion = await sourceInfo.GetLatestVersionAsync(packageName, includePreRelease); + latestNugetVersion = await sourceInfo.GetPackageAsync(packageName, null, includePreRelease); } catch (Exception ex) { @@ -103,17 +136,20 @@ private async Task GetLatestVersionAndSourceInfoAsync(string packa /// Downloads the specified nupkg and extracts it to a directory /// /// The command to download, i.e. "dotnet-foo". + /// The version to install. If null, then latest will be used. /// Force the download be made again if it was already downloaded earlier. /// Allow pre-release versions. /// The directory where it is extracted - public async Task DownloadAndExtractNugetAsync(string packageName, bool force, bool includePreRelease) + public async Task DownloadAndExtractNugetAsync(string packageName, SemanticVersion packageVersion, bool force, bool includePreRelease) { if (!sourceInfos.Any()) { WriteLine("No NuGet sources found."); return null; } - var nugetVersion = await GetLatestVersionAndSourceInfoAsync(packageName, includePreRelease); + var nugetVersion = packageVersion == null + ? await GetLatestVersionAndSourceInfoAsync(packageName, includePreRelease) + : await GetSpecificVersionAndSourceInfoAsync(packageName, packageVersion); if (nugetVersion == null) { WriteLineIfVerbose($"Could not get latest version for package '{packageName}'."); @@ -134,7 +170,7 @@ public async Task DownloadAndExtractNugetAsync(string packageName, WriteLineIfVerbose($"Saving to '{tempFilePath}'."); using (var tempFileStream = File.OpenWrite(tempFilePath)) await nupkgResponse.Content.CopyToAsync(tempFileStream); - var destinationDir = commandDirectory.GetDirectoryForPackage(nugetVersion.PackageName, nugetVersion.Version.ToString()); + var destinationDir = commandDirectory.GetDirectoryForPackage(nugetVersion.PackageName, nugetVersion.Version); if (force) Directory.Delete(destinationDir, true); var shouldExtract = force || !Directory.Exists(destinationDir); @@ -185,6 +221,14 @@ private class ServiceData public string Id { get; set; } [JsonProperty("version")] public string Version { get; set; } + [JsonProperty("versions")] + public IList Versions { get; set; } + } + + private class ServiceDataVersion + { + [JsonProperty("version")] + public string Version { get; set; } } private class SourceInfo : IDisposable @@ -213,7 +257,7 @@ public async Task GetFeedAsync() return feed; } - public async Task GetLatestVersionAsync(string packageName, bool includePreRelease) + public async Task GetPackageAsync(string packageName, SemanticVersion packageVersion, bool includePreRelease) { var currentFeed = await GetFeedAsync(); if (currentFeed == null) @@ -254,14 +298,27 @@ public async Task GetLatestVersionAsync(string packageName, bool i var serviceData = supportsQueryById ? service.Data.FirstOrDefault() : service.Data.FirstOrDefault(sd => string.Compare(sd.Id, packageName, true) == 0); - var version = serviceData?.Version; - if (version == null) + var latest = serviceData?.Version; + if (latest == null) { - WriteLineIfVerbose($"There was no version info for '{packageName}' on '{Source.Name}'."); + WriteLineIfVerbose($"There was no package info for '{packageName}' on '{Source.Name}'."); return null; } - WriteLineIfVerbose($"Found version {version}."); - var currentSemanticVersion = SemanticVersion.Parse(version); + WriteLineIfVerbose($"Found package '{packageName}' with latest version {latest}."); + var currentSemanticVersion = SemanticVersion.Parse(latest); + if (packageVersion != null) + { + var versionExists = serviceData.Versions.Any(v => v.Version == packageVersion.ToString()); + if (versionExists) + { + currentSemanticVersion = packageVersion; + } + else + { + WriteLineIfVerbose($"Version '{packageVersion.ToString()}' was not found for '{packageName}' on '{Source.Name}'."); + return null; + } + } var nugetVersion = new NugetVersion(currentSemanticVersion, this, serviceData.Id); return nugetVersion; } diff --git a/src/dotnet-commands/Program.cs b/src/dotnet-commands/Program.cs index cfb37ac..6394e6e 100644 --- a/src/dotnet-commands/Program.cs +++ b/src/dotnet-commands/Program.cs @@ -18,7 +18,7 @@ private async static Task RunAsync(string[] args) const string usage = @".NET Commands Usage: - dotnet commands install [--force] [--pre] [--verbose] + dotnet commands install [@] [--force] [--pre] [--verbose] dotnet commands uninstall [ --verbose] dotnet commands update ( | all) [--pre] [--verbose] dotnet commands (list|ls) [--verbose] @@ -27,7 +27,7 @@ dotnet commands --version Options: --force Installs even if package was already installed. Optional. - --pre Include pre-release versions. Optional. + --pre Include pre-release versions. Ignored if version is supplied. Optional. --verbose Verbose. Optional. --help -h Show this screen. --version -v Show version. @@ -38,7 +38,7 @@ dotnet commands --version if (args.Length == 1 && args[0] == "bootstrap") { var installer = new Installer(commandDirectory); - var success = await installer.InstallAsync("dotnet-commands", force: true, includePreRelease: true); + var success = await installer.InstallAsync("dotnet-commands", null, force: true, includePreRelease: true); return (int)(success ? ExitCodes.Success : ExitCodes.BootstrapFailed); } var argsWithRun = args; @@ -59,16 +59,37 @@ dotnet commands --version { WriteLineIfVerbose("Request to update .NET Commands."); var updater = new Updater(commandDirectory); - var updateNeeded = await updater.IsUpdateNeeded(command, arguments["--pre"].IsTrue); + var updateNeeded = await updater.IsUpdateNeededAsync(command, arguments["--pre"].IsTrue); var exitCode = updateNeeded == Updater.UpdateNeeded.Yes ? ExitCodes.StartUpdate : ExitCodes.Success; WriteLineIfVerbose($"Should update .NET Commands: {updateNeeded}, exit code is going to be {exitCode} ({(int)exitCode})."); return (int)exitCode; } if (arguments["install"].IsTrue) { - + var commandParts = command.Split('@'); + NuGet.Versioning.SemanticVersion packageVersion = null; + switch (commandParts.Length) + { + case 1: + break; + case 2: + command = commandParts[0]; + try + { + packageVersion = NuGet.Versioning.SemanticVersion.Parse(commandParts[0]); + } + catch (ArgumentException) + { + Console.WriteLine($"Invalid version.\n{usage}"); + return (int)ExitCodes.InvalidVersion; + } + break; + default: + Console.WriteLine($"Invalid version.\n{usage}"); + return (int)ExitCodes.InvalidVersion; + } var installer = new Installer(commandDirectory); - var success = await installer.InstallAsync(command, arguments["--force"].IsTrue, arguments["--pre"].IsTrue); + var success = await installer.InstallAsync(command, packageVersion, arguments["--force"].IsTrue, arguments["--pre"].IsTrue); return (int)(success ? ExitCodes.Success : ExitCodes.InstallFailed); } if (arguments["uninstall"].IsTrue) @@ -119,6 +140,7 @@ enum ExitCodes : byte // 0 and from 64-113 according to http://tldp.org/LDP/abs/ InstallFailed = 69, UninstallFailed = 70, CantUninstallDotNetCommands = 71, + InvalidVersion = 72, StartUpdate = 113 } } diff --git a/src/dotnet-commands/Properties/launchSettings.json b/src/dotnet-commands/Properties/launchSettings.json index 5dd0f5f..752e761 100644 --- a/src/dotnet-commands/Properties/launchSettings.json +++ b/src/dotnet-commands/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "dotnet-commands": { "commandName": "Project", - "commandLineArgs": "install dotnet-foo" + "commandLineArgs": "install dotnet-foo@1.0.1" } } } \ No newline at end of file diff --git a/src/dotnet-commands/Updater.cs b/src/dotnet-commands/Updater.cs index eb6b681..b4c1c2f 100644 --- a/src/dotnet-commands/Updater.cs +++ b/src/dotnet-commands/Updater.cs @@ -18,18 +18,18 @@ public Updater(CommandDirectory commandDirectory) public async Task UpdateAsync(string packageName, bool force, bool includePreRelease) { - var updateNeeded = await IsUpdateNeeded(packageName, includePreRelease); + var updateNeeded = await IsUpdateNeededAsync(packageName, includePreRelease); if (updateNeeded == UpdateNeeded.No) return UpdateResult.NotNeeded; if (updateNeeded == UpdateNeeded.PackageNotFound) return UpdateResult.PackageNotFound; var uninstaller = new Uninstaller(commandDirectory); var uninstalled = await uninstaller.UninstallAsync(packageName); if (!uninstalled) return UpdateResult.CouldntUninstall; var installer = new Installer(commandDirectory); - var installed = await installer.InstallAsync(packageName, force, includePreRelease); + var installed = await installer.InstallAsync(packageName, null, force, includePreRelease); return installed ? UpdateResult.Success : UpdateResult.UninstalledAndNotReinstalled; } - public async Task IsUpdateNeeded(string packageName, bool includePreRelease) + public async Task IsUpdateNeededAsync(string packageName, bool includePreRelease) { SemanticVersion largestAvailableVersion; try diff --git a/src/dotnet-commands/project.json b/src/dotnet-commands/project.json index ee50bb2..b3e755c 100644 --- a/src/dotnet-commands/project.json +++ b/src/dotnet-commands/project.json @@ -1,5 +1,5 @@ { - "version": "0.4.2", + "version": "0.5.0", "description": "A .NET CLI Commands library.", "dependencies": { "Microsoft.NETCore.App": { diff --git a/src/dotnet-foo/project.json b/src/dotnet-foo/project.json index 3805f4b..6cbdbeb 100644 --- a/src/dotnet-foo/project.json +++ b/src/dotnet-foo/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.1-*", + "version": "1.0.2-*", "description": "A sample package only to validate that the tools installer works.", "dependencies": { "Microsoft.NETCore": "5.0.2" diff --git a/test/IntegrationTests/CommandDirectoryTests.cs b/test/IntegrationTests/CommandDirectoryTests.cs index 2a837af..517cb17 100644 --- a/test/IntegrationTests/CommandDirectoryTests.cs +++ b/test/IntegrationTests/CommandDirectoryTests.cs @@ -1,5 +1,6 @@ using DotNetCommands; using FluentAssertions; +using NuGet.Versioning; using NUnit.Framework; using System.IO; @@ -28,7 +29,7 @@ public void ClassInitialize() public void GetBinFile() => commandDirectory.GetBinFile("foo.cmd").Should().Be(Path.Combine(baseDir, "bin", "foo.cmd")); [Test] - public void GetDirectoryForPackage() => commandDirectory.GetDirectoryForPackage("foo", "1.2.3").Should().Be(Path.Combine(baseDir, "packages", "foo", "1.2.3")); + public void GetDirectoryForPackage() => commandDirectory.GetDirectoryForPackage("foo", SemanticVersion.Parse("1.2.3")).Should().Be(Path.Combine(baseDir, "packages", "foo", "1.2.3")); [Test] public void MakeRelativeToBaseDir() => commandDirectory.MakeRelativeToBaseDir(Path.Combine(baseDir, "foo", "bar")).Should().Be(Path.Combine("..", "foo", "bar")); diff --git a/test/IntegrationTests/DownloadNugetTest.cs b/test/IntegrationTests/DownloadNugetTest.cs index 95652f7..623825b 100644 --- a/test/IntegrationTests/DownloadNugetTest.cs +++ b/test/IntegrationTests/DownloadNugetTest.cs @@ -30,7 +30,7 @@ public void ClassCleanup() [Test, Retry] public async Task DownloadDotNetFooAsync() { - var packageInfo = await downloader.DownloadAndExtractNugetAsync("dotnet-foo", force: false, includePreRelease: false); + var packageInfo = await downloader.DownloadAndExtractNugetAsync("dotnet-foo", null, force: false, includePreRelease: false); Directory.Exists(packageInfo.PackageDir).Should().BeTrue(); var cmd = Directory.EnumerateFiles(packageInfo.PackageDir, "dotnet-foo.cmd", SearchOption.AllDirectories).FirstOrDefault(); cmd.Should().NotBeNull(); diff --git a/test/IntegrationTests/DownloadNugetTestWithoutPackageSources.cs b/test/IntegrationTests/DownloadNugetTestWithoutPackageSources.cs index ef7a73a..f452684 100644 --- a/test/IntegrationTests/DownloadNugetTestWithoutPackageSources.cs +++ b/test/IntegrationTests/DownloadNugetTestWithoutPackageSources.cs @@ -46,7 +46,7 @@ public void ClassCleanup() [Test, Retry] public async Task DownloadDotNetFooWithoutPackageSourcesAsync() { - var packageInfo = await downloader.DownloadAndExtractNugetAsync("dotnet-foo", force: false, includePreRelease: false); + var packageInfo = await downloader.DownloadAndExtractNugetAsync("dotnet-foo", null, force: false, includePreRelease: false); Directory.Exists(packageInfo.PackageDir).Should().BeTrue(); var cmd = Directory.EnumerateFiles(packageInfo.PackageDir, "dotnet-foo.cmd", SearchOption.AllDirectories).FirstOrDefault(); cmd.Should().NotBeNull(); diff --git a/test/IntegrationTests/GlobalSuppressions.cs b/test/IntegrationTests/GlobalSuppressions.cs new file mode 100644 index 0000000..5ed3c1c --- /dev/null +++ b/test/IntegrationTests/GlobalSuppressions.cs @@ -0,0 +1 @@ +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "CC0061:Async method can be terminating with 'Async' name.", Justification = "Tests don't need to end in Async.")] \ No newline at end of file diff --git a/test/IntegrationTests/InstallerTestForDotNetTool.cs b/test/IntegrationTests/InstallerTestForDotNetTool.cs index fb51856..3cd79d9 100644 --- a/test/IntegrationTests/InstallerTestForDotNetTool.cs +++ b/test/IntegrationTests/InstallerTestForDotNetTool.cs @@ -26,7 +26,7 @@ public async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; installer = new Installer(commandDirectoryCleanup.CommandDirectory); - installed = await installer.InstallAsync(packageName, force: false, includePreRelease: true); + installed = await installer.InstallAsync(packageName, null, force: false, includePreRelease: true); installed.Should().BeTrue(); } diff --git a/test/IntegrationTests/InstallerTestForGenericTool.cs b/test/IntegrationTests/InstallerTestForGenericTool.cs index 4e694f3..4701e1e 100644 --- a/test/IntegrationTests/InstallerTestForGenericTool.cs +++ b/test/IntegrationTests/InstallerTestForGenericTool.cs @@ -26,7 +26,7 @@ public async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; installer = new Installer(commandDirectoryCleanup.CommandDirectory); - installed = await installer.InstallAsync(packageName, force: false, includePreRelease: false); + installed = await installer.InstallAsync(packageName, null, force: false, includePreRelease: false); installed.Should().BeTrue(); } diff --git a/test/IntegrationTests/InstallerTestForGenericToolWithSpecificVersion.cs b/test/IntegrationTests/InstallerTestForGenericToolWithSpecificVersion.cs new file mode 100644 index 0000000..bce088a --- /dev/null +++ b/test/IntegrationTests/InstallerTestForGenericToolWithSpecificVersion.cs @@ -0,0 +1,64 @@ +using DotNetCommands; +using FluentAssertions; +using NuGet.Versioning; +using NUnit.Framework; +using System.IO; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using static IntegrationTests.Retrier; + +namespace IntegrationTests +{ + [TestFixture] + public class InstallerTestForGenericToolWithSpecificVersion + { + private const string packageName = "dotnet-foo"; + private CommandDirectoryCleanup commandDirectoryCleanup; + private Installer installer; + private bool installed; + private string baseDir; + + [OneTimeSetUp] + public Task OneTimeSetUp() => RetryAsync(SetupAsync); + + public async Task SetupAsync() + { + commandDirectoryCleanup = new CommandDirectoryCleanup(); + baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; + installer = new Installer(commandDirectoryCleanup.CommandDirectory); + installed = await installer.InstallAsync(packageName, SemanticVersion.Parse("1.0.1"), force: false, includePreRelease: false); + installed.Should().BeTrue(); + } + + [OneTimeTearDown] + public void ClassCleanup() => commandDirectoryCleanup.Dispose(); + + [Test] + public void WroteRedirectFileForWindows() + { + var wroteRedirectFile = File.Exists(Path.Combine(baseDir, "bin", $"{packageName}.cmd")); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + wroteRedirectFile.Should().BeTrue(); + else + wroteRedirectFile.Should().BeFalse(); + } + + [Test] + public void WroteRedirectFileForOtherPlatforms() + { + var wroteRedirectFile = File.Exists(Path.Combine(baseDir, "bin", packageName)); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + wroteRedirectFile.Should().BeTrue(); + else + wroteRedirectFile.Should().BeFalse(); + } + + [Test] + public void DidNotCreateRuntimeConfigDevJsonFileWithCorrectConfig() => + Directory.EnumerateFiles(baseDir, "*.runtimeconfig.dev.json", SearchOption.AllDirectories).Should().BeEmpty(); + + [Test] + public void InstalledCorrectPackageVersion() => + Directory.Exists(commandDirectoryCleanup.CommandDirectory.GetDirectoryForPackage(packageName, SemanticVersion.Parse("1.0.1"))).Should().BeTrue(); + } +} \ No newline at end of file diff --git a/test/IntegrationTests/InstallerTestForMultipleCommandsWithMetadata.cs b/test/IntegrationTests/InstallerTestForMultipleCommandsWithMetadata.cs index fd230e7..c6e0dd1 100644 --- a/test/IntegrationTests/InstallerTestForMultipleCommandsWithMetadata.cs +++ b/test/IntegrationTests/InstallerTestForMultipleCommandsWithMetadata.cs @@ -25,7 +25,7 @@ public async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; installer = new Installer(commandDirectoryCleanup.CommandDirectory); - installed = await installer.InstallAsync(packageName, force: false, includePreRelease: false); + installed = await installer.InstallAsync(packageName, null, force: false, includePreRelease: false); installed.Should().BeTrue(); } diff --git a/test/IntegrationTests/ListerListsPackagesInstalled.cs b/test/IntegrationTests/ListerListsPackagesInstalled.cs index 8c77553..6088b3e 100644 --- a/test/IntegrationTests/ListerListsPackagesInstalled.cs +++ b/test/IntegrationTests/ListerListsPackagesInstalled.cs @@ -24,9 +24,9 @@ public async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); var baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; var installer = new Installer(commandDirectoryCleanup.CommandDirectory); - var installed = await installer.InstallAsync("dotnet-foo", force: false, includePreRelease: false); + var installed = await installer.InstallAsync("dotnet-foo", null, force: false, includePreRelease: false); installed.Should().BeTrue(); - installed = await installer.InstallAsync("dotnet-bar", force: false, includePreRelease: false); + installed = await installer.InstallAsync("dotnet-bar", null, force: false, includePreRelease: false); installed.Should().BeTrue(); logger = new Mock>(); Logger.IsVerbose = false; @@ -47,7 +47,7 @@ public void ListedPackagesAndCommands() { #pragma warning disable CC0031 // Check for null before calling a delegate logger.Verify(l => l( -$"dotnet-bar (1.0.2){Environment.NewLine} dotnet-bar-aa{Environment.NewLine} dotnet-bar-bb{Environment.NewLine}dotnet-foo (1.0.1){Environment.NewLine}" +$"dotnet-bar (1.0.2){Environment.NewLine} dotnet-bar-aa{Environment.NewLine} dotnet-bar-bb{Environment.NewLine}dotnet-foo (1.0.2){Environment.NewLine}" ), Times.Once); #pragma warning restore CC0031 // Check for null before calling a delegate } diff --git a/test/IntegrationTests/UninstallerTestForGenericTool.cs b/test/IntegrationTests/UninstallerTestForGenericTool.cs index 076248a..ce4cffb 100644 --- a/test/IntegrationTests/UninstallerTestForGenericTool.cs +++ b/test/IntegrationTests/UninstallerTestForGenericTool.cs @@ -25,7 +25,7 @@ public async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; var installer = new Installer(commandDirectoryCleanup.CommandDirectory); - var installed = await installer.InstallAsync(packageName, force: false, includePreRelease: false); + var installed = await installer.InstallAsync(packageName, null, force: false, includePreRelease: false); installed.Should().BeTrue(); uninstaller = new Uninstaller(commandDirectoryCleanup.CommandDirectory); uninstalled = await uninstaller.UninstallAsync(packageName); diff --git a/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdate.cs b/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdate.cs index 1008b9d..17513e0 100644 --- a/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdate.cs +++ b/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdate.cs @@ -27,7 +27,7 @@ public async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; var installer = new Installer(commandDirectoryCleanup.CommandDirectory); - var installed = await installer.InstallAsync(packageName, force: false, includePreRelease: false); + var installed = await installer.InstallAsync(packageName, null, force: false, includePreRelease: false); installed.Should().BeTrue(); GetLastWriteTimes(); var updater = new Updater(commandDirectoryCleanup.CommandDirectory); diff --git a/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdateBecauseGreater.cs b/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdateBecauseGreater.cs index 0cbc76b..e3953f4 100644 --- a/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdateBecauseGreater.cs +++ b/test/IntegrationTests/UpdaterTestForGenericToolWhenDoesNotNeedUpdateBecauseGreater.cs @@ -28,7 +28,7 @@ public async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; var installer = new Installer(commandDirectoryCleanup.CommandDirectory); - var installed = await installer.InstallAsync(packageName, force: false, includePreRelease: false); + var installed = await installer.InstallAsync(packageName, null, force: false, includePreRelease: false); installed.Should().BeTrue(); MoveToLaterVersion(); GetLastWriteTimes(); diff --git a/test/IntegrationTests/UpdaterTestForGenericToolWhenNeedsUpdate.cs b/test/IntegrationTests/UpdaterTestForGenericToolWhenNeedsUpdate.cs index 153bd83..4574116 100644 --- a/test/IntegrationTests/UpdaterTestForGenericToolWhenNeedsUpdate.cs +++ b/test/IntegrationTests/UpdaterTestForGenericToolWhenNeedsUpdate.cs @@ -26,7 +26,7 @@ private async Task SetupAsync() commandDirectoryCleanup = new CommandDirectoryCleanup(); baseDir = commandDirectoryCleanup.CommandDirectory.BaseDir; var installer = new Installer(commandDirectoryCleanup.CommandDirectory); - var installed = await installer.InstallAsync(packageName, force: false, includePreRelease: false); + var installed = await installer.InstallAsync(packageName, null, force: false, includePreRelease: false); MoveToPreviousVersion(); installed.Should().BeTrue(); var updater = new Updater(commandDirectoryCleanup.CommandDirectory);