From 69cc81fb56dbaeaed4ba3c0b6fa7aa73dd922a6c Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Mon, 19 Dec 2022 16:50:56 -0600 Subject: [PATCH 1/4] (#508) Attempt to resolve relative paths for sources When setting up NuGet sources, if NuGet is unable to parse the path, this tries to resolve relative paths to absolute, and then retries setting up the NuGet source. If the path is unable to be resolved, then this ignores the error and lets NuGet handle the resulting invalid source. This path resolution requires the filesystem to be passed in. This means that various method signatures change to allow access to the filesystem. When using NuGet.Core, then relative paths were able to be resolved. But now with NuGet.Client, relative paths are resolved by clients, not by libraries, which is why this change has to be made. https://github.com/NuGet/NuGet.Client/pull/3783 --- .../nuget/NugetCommonSpecs.cs | 4 +- .../infrastructure.app/nuget/NugetCommon.cs | 37 +++++++++++++++++-- .../infrastructure.app/nuget/NugetList.cs | 13 ++++--- .../infrastructure.app/nuget/NugetPush.cs | 5 ++- .../services/NugetService.cs | 12 +++--- .../services/TemplateService.cs | 2 +- 6 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs index 2453b2c79c..3fa1d43835 100644 --- a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs @@ -21,6 +21,7 @@ namespace chocolatey.tests.infrastructure.app.nuget using System.Linq; using chocolatey.infrastructure.app.configuration; using chocolatey.infrastructure.app.nuget; + using chocolatey.infrastructure.filesystem; using Moq; using NuGet.Common; using NuGet.Packaging; @@ -35,6 +36,7 @@ private class when_gets_remote_repository : TinySpec private Action because; private readonly Mock nugetLogger = new Mock(); private readonly Mock packageDownloader = new Mock(); + private readonly Mock filesystem = new Mock(); private ChocolateyConfiguration configuration; private IEnumerable packageRepositories; @@ -47,7 +49,7 @@ public override void Context() public override void Because() { - because = () => packageRepositories = NugetCommon.GetRemoteRepositories(configuration, nugetLogger.Object); + because = () => packageRepositories = NugetCommon.GetRemoteRepositories(configuration, nugetLogger.Object, filesystem.Object); } [Fact] diff --git a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs index d9eb5b0460..c4cca7a224 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs @@ -23,6 +23,7 @@ namespace chocolatey.infrastructure.app.nuget using System.Net; using System.Net.Http; using System.Net.Security; + using System.Runtime.CompilerServices; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading; @@ -92,7 +93,7 @@ public static IPackageRepository GetLocalRepository(IPackagePathResolver pathRes } */ - public static IEnumerable GetRemoteRepositories(ChocolateyConfiguration configuration, ILogger nugetLogger) + public static IEnumerable GetRemoteRepositories(ChocolateyConfiguration configuration, ILogger nugetLogger, IFileSystem filesystem) { //TODO, fix @@ -185,9 +186,39 @@ public static IEnumerable GetRemoteRepositories(ChocolateyConf } } - updatedSources.AppendFormat("{0};", source); - var nugetSource = new PackageSource(source); + + // If not parsed as a http(s) or local source, let's try resolving the path + // Since NuGet.Client is not able to parse all relative paths + // Conversion to absolute paths is handled by clients, not by the libraries as per + // https://github.com/NuGet/NuGet.Client/pull/3783 + if (nugetSource.TrySourceAsUri is null) + { + string fullsource; + try + { + fullsource = filesystem.get_full_path(source); + } + catch + { + // If an invalid source was passed in, we don't care here, pass it along + fullsource = source; + } + nugetSource = new PackageSource(fullsource); + + if (!nugetSource.IsLocal) + { + throw new ApplicationException("Source '{0}' is unable to be parsed".format_with(source)); + } + + "chocolatey".Log().Debug("Updating Source path from {0} to {1}".format_with(source, fullsource)); + updatedSources.AppendFormat("{0};", fullsource); + } + else + { + updatedSources.AppendFormat("{0};", source); + } + nugetSource.ClientCertificates = sourceClientCertificates; var repo = Repository.Factory.GetCoreV3(nugetSource); diff --git a/src/chocolatey/infrastructure.app/nuget/NugetList.cs b/src/chocolatey/infrastructure.app/nuget/NugetList.cs index cbf01b24ee..432ee1bea3 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetList.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetList.cs @@ -26,6 +26,7 @@ namespace chocolatey.infrastructure.app.nuget using System.Threading; using System.Threading.Tasks; using configuration; + using filesystem; using NuGet.Common; using NuGet.Configuration; using NuGet.PackageManagement; @@ -39,19 +40,19 @@ namespace chocolatey.infrastructure.app.nuget public static class NugetList { - public static IEnumerable GetPackages(ChocolateyConfiguration configuration, ILogger nugetLogger) + public static IEnumerable GetPackages(ChocolateyConfiguration configuration, ILogger nugetLogger, IFileSystem filesystem) { - return execute_package_search(configuration, nugetLogger).GetAwaiter().GetResult(); + return execute_package_search(configuration, nugetLogger, filesystem).GetAwaiter().GetResult(); } - public static int GetCount(ChocolateyConfiguration configuration, ILogger nugetLogger) + public static int GetCount(ChocolateyConfiguration configuration, ILogger nugetLogger, IFileSystem filesystem) { - return execute_package_search(configuration, nugetLogger).GetAwaiter().GetResult().Count(); + return execute_package_search(configuration, nugetLogger, filesystem).GetAwaiter().GetResult().Count(); } - private async static Task> execute_package_search(ChocolateyConfiguration configuration, ILogger nugetLogger) + private async static Task> execute_package_search(ChocolateyConfiguration configuration, ILogger nugetLogger, IFileSystem filesystem) { - var packageRepositories = NugetCommon.GetRemoteRepositories(configuration, nugetLogger); + var packageRepositories = NugetCommon.GetRemoteRepositories(configuration, nugetLogger, filesystem); var packageRepositoriesResources = NugetCommon.GetRepositoryResources(packageRepositories); string searchTermLower = configuration.Input.to_lower(); SearchFilter searchFilter = new SearchFilter(configuration.Prerelease); diff --git a/src/chocolatey/infrastructure.app/nuget/NugetPush.cs b/src/chocolatey/infrastructure.app/nuget/NugetPush.cs index c0ee27c585..d2daf958cd 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetPush.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetPush.cs @@ -22,6 +22,7 @@ namespace chocolatey.infrastructure.app.nuget using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; + using filesystem; using NuGet.Common; using NuGet.Configuration; using NuGet.Protocol; @@ -29,7 +30,7 @@ namespace chocolatey.infrastructure.app.nuget public class NugetPush { - public static void push_package(ChocolateyConfiguration config, string nupkgFilePath, ILogger nugetLogger, string nupkgFileName) + public static void push_package(ChocolateyConfiguration config, string nupkgFilePath, ILogger nugetLogger, string nupkgFileName, IFileSystem filesystem) { var timeout = TimeSpan.FromSeconds(Math.Abs(config.CommandExecutionTimeoutSeconds)); if (timeout.Seconds <= 0) @@ -42,7 +43,7 @@ public static void push_package(ChocolateyConfiguration config, string nupkgFile const bool noServiceEndpoint = true; //OK to use FirstOrDefault in this case as the command validates that there is only one source - SourceRepository sourceRepository = NugetCommon.GetRemoteRepositories(config, nugetLogger).FirstOrDefault(); + SourceRepository sourceRepository = NugetCommon.GetRemoteRepositories(config, nugetLogger, filesystem).FirstOrDefault(); PackageUpdateResource packageUpdateResource = sourceRepository.GetResource(); var nupkgFilePaths = new List() { nupkgFilePath }; UserAgent.SetUserAgentString(new UserAgentStringBuilder("{0}/{1} via NuGet Client".format_with(ApplicationParameters.UserAgent, config.Information.ChocolateyProductVersion))); diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 73ea509a20..fcbf2c92e7 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -108,7 +108,7 @@ public virtual int count_run(ChocolateyConfiguration config) int? pageValue = config.ListCommand.Page; try { - return NugetList.GetCount(config, _nugetLogger); + return NugetList.GetCount(config, _nugetLogger, _fileSystem); } finally { @@ -147,7 +147,7 @@ public virtual IEnumerable list_run(ChocolateyConfiguration confi if (config.RegularOutput) this.Log().Debug(() => "Running list with the following filter = '{0}'".format_with(config.Input)); if (config.RegularOutput) this.Log().Debug(ChocolateyLoggers.Verbose, () => "--- Start of List ---"); - foreach (var pkg in NugetList.GetPackages(config, _nugetLogger)) + foreach (var pkg in NugetList.GetPackages(config, _nugetLogger, _fileSystem)) { var package = pkg; // for lamda access @@ -378,7 +378,7 @@ public virtual void push_run(ChocolateyConfiguration config) string nupkgFileName = _fileSystem.get_file_name(nupkgFilePath); if (config.RegularOutput) this.Log().Info(() => "Attempting to push {0} to {1}".format_with(nupkgFileName, config.Sources)); - NugetPush.push_package(config, _fileSystem.get_full_path(nupkgFilePath), _nugetLogger, nupkgFileName); + NugetPush.push_package(config, _fileSystem.get_full_path(nupkgFilePath), _nugetLogger, nupkgFileName, _fileSystem); if (config.RegularOutput && (config.Sources.is_equal_to(ApplicationParameters.ChocolateyCommunityFeedPushSource) || config.Sources.is_equal_to(ApplicationParameters.ChocolateyCommunityFeedPushSourceOld))) { @@ -438,7 +438,7 @@ public virtual ConcurrentDictionary install_run(Chocolate if (config.Force) config.AllowDowngrade = true; var sourceCacheContext = new ChocolateySourceCacheContext(config); - var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger); + var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger, _fileSystem); var localRepositorySource = NugetCommon.GetLocalRepository(); var pathResolver = NugetCommon.GetPathResolver(config, _fileSystem); var nugetProject = new FolderNuGetProject(ApplicationParameters.PackagesLocation, pathResolver, NuGetFramework.AnyFramework); @@ -868,7 +868,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate if (config.Force) config.AllowDowngrade = true; var sourceCacheContext = new ChocolateySourceCacheContext(config); - var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger); + var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger, _fileSystem); var localRepositorySource = NugetCommon.GetLocalRepository(); var projectContext = new ChocolateyNuGetProjectContext(config, _nugetLogger); @@ -1365,7 +1365,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate public virtual ConcurrentDictionary get_outdated(ChocolateyConfiguration config) { - var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger); + var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger, _fileSystem); var pathResolver = NugetCommon.GetPathResolver(config, _fileSystem); var outdatedPackages = new ConcurrentDictionary(); diff --git a/src/chocolatey/infrastructure.app/services/TemplateService.cs b/src/chocolatey/infrastructure.app/services/TemplateService.cs index 65bba9f55c..09da070e92 100644 --- a/src/chocolatey/infrastructure.app/services/TemplateService.cs +++ b/src/chocolatey/infrastructure.app/services/TemplateService.cs @@ -274,7 +274,7 @@ public void list(ChocolateyConfiguration configuration) protected void list_custom_template_info(ChocolateyConfiguration configuration) { - var packageRepositories = NugetCommon.GetRemoteRepositories(configuration, _nugetLogger); + var packageRepositories = NugetCommon.GetRemoteRepositories(configuration, _nugetLogger, _fileSystem); var sourceCacheContext = new ChocolateySourceCacheContext(configuration); var pkg = NugetList.find_package( "{0}.template".format_with(configuration.TemplateCommand.Name), From 05980979ed46209248e472ee26db67640c79a4d5 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Tue, 20 Dec 2022 14:49:30 -0600 Subject: [PATCH 2/4] (#508) Add unit tests for NuGet source parsing This adds tests to ensure that NuGet is able to parse various types of NuGet sources correctly. This includes http, https, and local paths, where local paths include absolute, different types of relative paths, and UNC. --- .../nuget/NugetCommonSpecs.cs | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs index 3fa1d43835..a2e8143ccd 100644 --- a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs @@ -45,6 +45,12 @@ public override void Context() configuration = new ChocolateyConfiguration(); nugetLogger.ResetCalls(); packageDownloader.ResetCalls(); + filesystem.ResetCalls(); + + filesystem.Setup(f => f.get_full_path(It.IsAny())).Returns((string a) => + { + return "C:\\packages\\" + a; + }); } public override void Because() @@ -62,6 +68,99 @@ public void should_create_repository_when_source_is_null() packageRepositories.Count().ShouldEqual(0); } + + [Fact] + public void should_parse_http_source() + { + Context(); + var source = "http://nexus.example.com:8081/repository/choco"; + configuration.Sources = source; + configuration.CacheLocation = "C:\\temp"; + + because(); + + packageRepositories.First().PackageSource.TrySourceAsUri.ShouldNotBeNull(); + packageRepositories.First().PackageSource.SourceUri.to_string().ShouldEqual(source); + packageRepositories.First().PackageSource.IsHttp.ShouldBeTrue(); + } + + [Fact] + public void should_parse_https_source() + { + Context(); + var source = "https://nexus.example.com/repository/choco"; + configuration.Sources = source; + configuration.CacheLocation = "C:\\temp"; + + because(); + + packageRepositories.First().PackageSource.TrySourceAsUri.ShouldNotBeNull(); + packageRepositories.First().PackageSource.SourceUri.to_string().ShouldEqual(source); + packageRepositories.First().PackageSource.IsHttps.ShouldBeTrue(); + } + + [Fact] + public void should_parse_absolute_path_source() + { + Context(); + var source = "C:\\packages"; + configuration.Sources = source; + + because(); + + packageRepositories.First().PackageSource.TrySourceAsUri.ShouldNotBeNull(); + packageRepositories.First().PackageSource.SourceUri.to_string() + .ShouldEqual(("file:///" + source).Replace("\\","/")); + packageRepositories.First().PackageSource.IsLocal.ShouldBeTrue(); + } + + [Fact] + public void should_parse_relative_path_source() + { + Context(); + var source = "choco"; + var fullsource = "C:\\packages\\choco"; + configuration.Sources = source; + + because(); + + packageRepositories.First().PackageSource.TrySourceAsUri.ShouldNotBeNull(); + packageRepositories.First().PackageSource.SourceUri.to_string() + .ShouldEqual(("file:///" + fullsource).Replace("\\", "/")); + packageRepositories.First().PackageSource.IsLocal.ShouldBeTrue(); + } + + [Fact] + public void should_parse_dot_relative_path_source() + { + Context(); + var source = "."; + var fullsource = "C:\\packages"; + configuration.Sources = source; + + because(); + + packageRepositories.First().PackageSource.TrySourceAsUri.ShouldNotBeNull(); + packageRepositories.First().PackageSource.SourceUri.to_string() + .ShouldEqual(("file:///" + fullsource + "/").Replace("\\", "/")); + packageRepositories.First().PackageSource.IsLocal.ShouldBeTrue(); + } + + [Fact] + public void should_parse_unc_source() + { + Context(); + var source = "\\\\samba-server\\choco-share"; + configuration.Sources = source; + + because(); + + packageRepositories.First().PackageSource.TrySourceAsUri.ShouldNotBeNull(); + packageRepositories.First().PackageSource.SourceUri.to_string() + .ShouldEqual(("file:" + source).Replace("\\", "/")); + packageRepositories.First().PackageSource.IsLocal.ShouldBeTrue(); + packageRepositories.First().PackageSource.SourceUri.IsUnc.ShouldBeTrue(); + } } } } From dde3671e3fa3a5b3f6cf5379d632b7610678ce1e Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Thu, 22 Dec 2022 09:58:45 -0600 Subject: [PATCH 3/4] (#508) Tweak info/verbose list output This makes the info output the same as it was when using NuGet.Core so as to keep the info output the same as it is with v1.x --- .../infrastructure.app/services/NugetService.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index fcbf2c92e7..4b482d1078 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -198,7 +198,7 @@ public virtual IEnumerable list_run(ChocolateyConfiguration confi if (config.Verbose && !config.ListCommand.IdOnly) this.Log().Info(() => @" Title: {0} | Published: {1}{2}{3} Number of Downloads: {4} | Downloads for this version: {5} - Package url: {6} + Package url{6} Chocolatey Package Source: {7}{8} Tags: {9} Software Site: {10} @@ -217,12 +217,12 @@ public virtual IEnumerable list_run(ChocolateyConfiguration confi package.PackageTestResultStatus, package.PackageValidationResultDate.GetValueOrDefault().ToString("MMM dd yyyy HH:mm:ss") ), - package.DownloadCount <= 0 ? "n/a" : package.DownloadCount.to_string(), - package.VersionDownloadCount <= 0 ? "n/a" : package.VersionDownloadCount.to_string(), - package.PackageDetailsUrl == null || string.IsNullOrWhiteSpace(package.PackageDetailsUrl.AbsoluteUri) ? "N/A" : package.PackageDetailsUrl.AbsoluteUri, + (package.DownloadCount == null || package.DownloadCount <= 0) ? "n/a" : package.DownloadCount.to_string(), + (package.VersionDownloadCount == null || package.VersionDownloadCount <= 0) ? "n/a" : package.VersionDownloadCount.to_string(), + package.PackageDetailsUrl == null || string.IsNullOrWhiteSpace(package.PackageDetailsUrl.AbsoluteUri) ? string.Empty : " " + package.PackageDetailsUrl.AbsoluteUri, packageLocalMetadata != null && packageLocalMetadata.PackageSourceUrl != null && !string.IsNullOrWhiteSpace(packageLocalMetadata.PackageSourceUrl.to_string()) ? packageLocalMetadata.PackageSourceUrl.to_string() - : "N/A", + : "n/a", string.IsNullOrWhiteSpace(package.PackageHash) ? string.Empty : "{0} Package Checksum: '{1}' ({2})".format_with( Environment.NewLine, package.PackageHash, @@ -235,7 +235,7 @@ public virtual IEnumerable list_run(ChocolateyConfiguration confi packageLocalMetadata != null && packageLocalMetadata.DocsUrl != null && !string.IsNullOrWhiteSpace(packageLocalMetadata.DocsUrl.to_string()) ? "{0} Documentation: {1}".format_with(Environment.NewLine, packageLocalMetadata.DocsUrl.to_string()) : string.Empty, packageLocalMetadata != null && packageLocalMetadata.MailingListUrl != null && !string.IsNullOrWhiteSpace(packageLocalMetadata.MailingListUrl.to_string()) ? "{0} Mailing List: {1}".format_with(Environment.NewLine, packageLocalMetadata.MailingListUrl.to_string()) : string.Empty, packageLocalMetadata != null && packageLocalMetadata.BugTrackerUrl != null && !string.IsNullOrWhiteSpace(packageLocalMetadata.BugTrackerUrl.to_string()) ? "{0} Issues: {1}".format_with(Environment.NewLine, packageLocalMetadata.BugTrackerUrl.to_string()) : string.Empty, - package.Summary != null && !string.IsNullOrWhiteSpace(package.Summary.to_string()) ? "{0} Summary: {1}".format_with(Environment.NewLine, package.Summary.escape_curly_braces().to_string()) : string.Empty, + package.Summary != null && !string.IsNullOrWhiteSpace(package.Summary.to_string()) ? "\r\n Summary: {0}".format_with(package.Summary.escape_curly_braces().to_string()) : string.Empty, package.Description.escape_curly_braces().Replace("\n ", "\n").Replace("\n", "\n "), packageLocalMetadata != null && packageLocalMetadata.ReleaseNotes != null && !string.IsNullOrWhiteSpace(packageLocalMetadata.ReleaseNotes.to_string()) ? "{0} Release Notes: {1}".format_with(Environment.NewLine, packageLocalMetadata.ReleaseNotes.escape_curly_braces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty )); From 0e7b3697075a0b3363bc8bfa0a7de870afad7041 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Tue, 20 Dec 2022 11:47:40 -0600 Subject: [PATCH 4/4] (#508) Enable tests with relative path sources --- .../scenarios/InfoScenarios.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chocolatey.tests.integration/scenarios/InfoScenarios.cs b/src/chocolatey.tests.integration/scenarios/InfoScenarios.cs index 8f73b4abdc..36ff05e5ec 100644 --- a/src/chocolatey.tests.integration/scenarios/InfoScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/InfoScenarios.cs @@ -10,6 +10,7 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.configuration; using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.commands; + using chocolatey.infrastructure.platforms; using chocolatey.infrastructure.results; using NuGet; @@ -67,7 +68,6 @@ public override void Because() } } - [Broken, Pending("Need to be fixed in either NuGet.Client or before calling code in NuGet.Client")] public class when_searching_for_exact_package_through_command : CommandScenariosBase { public override void Context() @@ -94,7 +94,7 @@ public void should_log_package_information() .ToShortDateString(); MockLogger.Messages.Keys.ShouldContain(LogLevel.Info.to_string()); - MockLogger.Messages[LogLevel.Info.to_string()].ShouldContain(" Title: installpackage | Published: 14.12.2022\r\n Number of Downloads: n/a | Downloads for this version: n/a\r\n Package url\r\n Chocolatey Package Source: n/a\r\n Tags: installpackage admin\r\n Software Site: n/a\r\n Software License: n/a\r\n Summary: __REPLACE__\r\n Description: __REPLACE__\r\n".format_with(lastWriteDate)); + MockLogger.Messages[LogLevel.Info.to_string()].ShouldContain(" Title: installpackage | Published: {0}\r\n Number of Downloads: n/a | Downloads for this version: n/a\r\n Package url\r\n Chocolatey Package Source: n/a\r\n Tags: installpackage admin\r\n Software Site: n/a\r\n Software License: n/a\r\n Summary: __REPLACE__\r\n Description: __REPLACE__\r\n".format_with(lastWriteDate)); } [Fact] @@ -105,7 +105,6 @@ public void should_log_package_count_as_warning() } } - [Broken, Pending("Need to be fixed in either NuGet.Client or before calling code in NuGet.Client")] public class when_searching_for_exact_package_with_dot_relative_path_source : when_searching_for_exact_package_through_command { public override void Context() @@ -143,7 +142,7 @@ public override void Because() .ToShortDateString(); MockLogger.Messages.Keys.ShouldContain(LogLevel.Info.to_string()); - MockLogger.Messages[LogLevel.Info.to_string()].ShouldContain(" Title: installpackage | Published: 14.12.2022\r\n Number of Downloads: n/a | Downloads for this version: n/a\r\n Package url\r\n Chocolatey Package Source: n/a\r\n Tags: installpackage admin\r\n Software Site: n/a\r\n Software License: n/a\r\n Summary: __REPLACE__\r\n Description: __REPLACE__\r\n".format_with(lastWriteDate)); + MockLogger.Messages[LogLevel.Info.to_string()].ShouldContain(" Title: installpackage | Published: {0}\r\n Number of Downloads: n/a | Downloads for this version: n/a\r\n Package url\r\n Chocolatey Package Source: n/a\r\n Tags: installpackage admin\r\n Software Site: n/a\r\n Software License: n/a\r\n Summary: __REPLACE__\r\n Description: __REPLACE__\r\n".format_with(lastWriteDate)); } [Fact] @@ -154,7 +153,6 @@ public override void Because() } } - [Broken, Pending("Need to be fixed in either NuGet.Client or before calling code in NuGet.Client")] public class when_searching_for_exact_package_with_verbose_output : ScenariosBase { public override void Context() @@ -193,7 +191,9 @@ public void should_report_expected_name() [Fact] public void should_set_source_to_expected_value() { - Results[0].Source.ShouldEqual("PackageOutput"); + Results[0].Source.ShouldEqual( + ((Platform.get_platform() == PlatformType.Windows ? "file:///" : "file://") + Path.Combine(Environment.CurrentDirectory, "PackageOutput")) + .Replace("\\","/")); } [Fact]