From 5be7b431c8971642a07ae97de9db5dfc8b2b209b Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Fri, 17 Jun 2022 17:40:20 -0500 Subject: [PATCH] Rip the heart out of the nuget code to get this to compile --- src/chocolatey/chocolatey.csproj | 12 +- .../commands/ChocolateyPinCommand.cs | 11 +- .../domain/ChocolateyPackageInformation.cs | 3 + .../ChocolateyClientCertificateProvider.cs | 72 ----- .../nuget/ChocolateyLocalPackageRepository.cs | 84 ------ .../ChocolateyNugetCredentialProvider.cs | 184 ------------ .../nuget/ChocolateyPackagePathResolver.cs | 73 ----- .../nuget/NuGetFileSystemExtensions.cs | 52 ---- .../infrastructure.app/nuget/NugetCommon.cs | 31 +- .../infrastructure.app/nuget/NugetList.cs | 269 ------------------ .../infrastructure.app/nuget/NugetPack.cs | 2 +- .../registration/ContainerBinding.cs | 2 +- .../services/AutomaticUninstallerService.cs | 3 + .../ChocolateyPackageInformationService.cs | 4 +- .../services/ChocolateyPackageService.cs | 4 +- .../IChocolateyPackageInformationService.cs | 1 + .../services/IPowershellService.cs | 1 + .../services/NugetService.cs | 82 +++--- .../services/PowershellService.cs | 10 +- .../services/TemplateService.cs | 12 +- .../cryptography/DefaultEncryptionUtility.cs | 2 +- .../infrastructure/mockups/IPackage.cs | 84 ++++++ .../infrastructure/mockups/IPackageManager.cs | 72 +++++ .../mockups/IPackageRepository.cs | 35 +++ .../mockups/PackageOperationEventArgs.cs | 37 +++ .../mockups/PhysicalFileSystem.cs} | 27 +- .../infrastructure/results/PackageResult.cs | 5 +- 27 files changed, 342 insertions(+), 832 deletions(-) delete mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs delete mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs delete mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs delete mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs delete mode 100644 src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs delete mode 100644 src/chocolatey/infrastructure.app/nuget/NugetList.cs create mode 100644 src/chocolatey/infrastructure/mockups/IPackage.cs create mode 100644 src/chocolatey/infrastructure/mockups/IPackageManager.cs create mode 100644 src/chocolatey/infrastructure/mockups/IPackageRepository.cs create mode 100644 src/chocolatey/infrastructure/mockups/PackageOperationEventArgs.cs rename src/chocolatey/{infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs => infrastructure/mockups/PhysicalFileSystem.cs} (60%) diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index 72b119cfdc..21e1807bcb 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -171,6 +171,10 @@ + + + + @@ -205,6 +209,7 @@ + @@ -240,8 +245,6 @@ - - @@ -277,15 +280,10 @@ - - - - - diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs index 8a40ef9c4f..1972e09b6f 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs @@ -27,6 +27,7 @@ namespace chocolatey.infrastructure.app.commands using infrastructure.commands; using infrastructure.configuration; using logging; + using mockups; using nuget; using NuGet.Common; using NuGet.Versioning; @@ -147,7 +148,7 @@ public virtual void noop(ChocolateyConfiguration configuration) public virtual void run(ChocolateyConfiguration configuration) { - var packageManager = NugetCommon.GetPackageManager(configuration, _nugetLogger, + /*var packageManager = NugetCommon.GetPackageManager(configuration, _nugetLogger, new PackageDownloader(), installSuccessAction: null, uninstallSuccessAction: null, @@ -161,9 +162,9 @@ public virtual void run(ChocolateyConfiguration configuration) case PinCommandType.remove: set_pin(packageManager, configuration); break; - } + }*/ } - + /* public virtual void list_pins(IPackageManager packageManager, ChocolateyConfiguration config) { var input = config.Input; @@ -189,7 +190,7 @@ public virtual void set_pin(IPackageManager packageManager, ChocolateyConfigurat var addingAPin = config.PinCommand.Command == PinCommandType.add; this.Log().Info("Trying to {0} a pin for {1}".format_with(config.PinCommand.Command.to_string(), config.PinCommand.Name)); var versionUnspecified = string.IsNullOrWhiteSpace(config.Version); - SemanticVersion semanticVersion = versionUnspecified ? null : new SemanticVersion(config.Version); + SemanticVersion semanticVersion = versionUnspecified ? null : new SemanticVersion(SemanticVersion.Parse(config.Version)); IPackage installedPackage = packageManager.LocalRepository.FindPackage(config.PinCommand.Name, semanticVersion); if (installedPackage == null) { @@ -222,7 +223,7 @@ public virtual void set_pin(IPackageManager packageManager, ChocolateyConfigurat this.Log().Warn(NO_CHANGE_MESSAGE); } } - + */ public virtual bool may_require_admin_access() { var config = Config.get_configuration_settings(); diff --git a/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs b/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs index 48de84c50f..9b51b9da3a 100644 --- a/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs +++ b/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs @@ -16,7 +16,10 @@ namespace chocolatey.infrastructure.app.domain { + using mockups; using NuGet; + using NuGet.Versioning; + using results; public sealed class ChocolateyPackageInformation { diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs deleted file mode 100644 index b72187f006..0000000000 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc -// Copyright © 2011 - 2017 RealDimensions Software, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace chocolatey.infrastructure.app.nuget -{ - using configuration; - using NuGet; - using System; - using System.Linq; - using System.Net; - using System.Security.Cryptography.X509Certificates; - - class ChocolateyClientCertificateProvider : IClientCertificateProvider - { - ChocolateyConfiguration _configuration; - - public ChocolateyClientCertificateProvider(ChocolateyConfiguration configuration) - { - if (configuration == null) - throw new ArgumentNullException("configuration"); - _configuration = configuration; - } - - public X509Certificate GetCertificate(Uri uri) - { - if (uri.OriginalString.StartsWith(_configuration.Sources.TrimEnd('/').ToLower(),StringComparison.InvariantCultureIgnoreCase)) - { - if (!string.IsNullOrWhiteSpace(_configuration.SourceCommand.Certificate)) - { - this.Log().Debug("Using passed in certificate"); - - return new X509Certificate2(_configuration.SourceCommand.Certificate, _configuration.SourceCommand.CertificatePassword); - } - } - - return _configuration.MachineSources.Where(s => - { - var sourceUri = s.Key.TrimEnd('/').ToLower(); - return uri.OriginalString.ToLower().StartsWith(sourceUri) - && !string.IsNullOrWhiteSpace(s.Certificate); - }) - .Select(s => - { - this.Log().Debug("Using machine source certificate"); - try { - var decrypted = string.IsNullOrEmpty(s.EncryptedCertificatePassword) - ? string.Empty - : NugetEncryptionUtility.DecryptString(s.EncryptedCertificatePassword); - return new X509Certificate2(s.Certificate, decrypted); - } catch(Exception x) - { - this.Log().Error("Unable to load the certificate: {0}", x); - return null; - } - }) - .FirstOrDefault(); - } - } -} diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs deleted file mode 100644 index 71e5ec6d84..0000000000 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc -// Copyright © 2011 - 2017 RealDimensions Software, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace chocolatey.infrastructure.app.nuget -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Runtime.Versioning; - using System.Threading; - using NuGet; - - // ReSharper disable InconsistentNaming - - public class ChocolateyLocalPackageRepository : LocalPackageRepository - { - public ChocolateyLocalPackageRepository(string physicalPath) - : base(physicalPath) - { - } - - public ChocolateyLocalPackageRepository(string physicalPath, bool enableCaching) - : base(physicalPath, enableCaching) - { - } - - public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) - : base(pathResolver, fileSystem) - { - } - - public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching) - : base(pathResolver, fileSystem, enableCaching) - { - } - - public override void AddPackage(IPackage package) - { - string packageFilePath = GetPackageFilePath(package); - FileSystem.AddFileWithCheck(packageFilePath, package.GetStream); - // allow the file to finish being written - Thread.Sleep(200); - if (PackageSaveMode.HasFlag(PackageSaveModes.Nuspec)) - { - // don't trust the package metadata to be complete - extract from the downloaded nupkg - var zipPackage = new OptimizedZipPackage(FileSystem, packageFilePath); - string manifestFilePath = GetManifestFilePath(package.Id, package.Version); - Manifest manifest = Manifest.Create(zipPackage); - manifest.Metadata.ReferenceSets = Enumerable.ToList(Enumerable.Select, ManifestReferenceSet>(Enumerable.GroupBy(package.AssemblyReferences, (Func)(f => f.TargetFramework)), (Func, ManifestReferenceSet>)(g => new ManifestReferenceSet() - { - TargetFramework = g.Key == (FrameworkName)null ? (string)null : VersionUtility.GetFrameworkString(g.Key), - References = Enumerable.ToList(Enumerable.Select((IEnumerable)g, (Func)(p => new ManifestReference() - { - File = p.Name - }))) - }))); - FileSystem.AddFileWithCheck(manifestFilePath, manifest.Save); - } - } - - private string GetManifestFilePath(string packageId, SemanticVersion version) - { - string packageDirectory = PathResolver.GetPackageDirectory(packageId, version); - string path2 = packageDirectory + Constants.ManifestExtension; - return Path.Combine(packageDirectory, path2); - } - } - - // ReSharper restore InconsistentNaming -} \ No newline at end of file diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs deleted file mode 100644 index 06fdd72dd0..0000000000 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc -// Copyright © 2011 - 2017 RealDimensions Software, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace chocolatey.infrastructure.app.nuget -{ - using System; - using System.Linq; - using System.Net; - using System.Text.RegularExpressions; - using commandline; - using NuGet; - using configuration; - using logging; - - // ReSharper disable InconsistentNaming - - public sealed class ChocolateyNugetCredentialProvider : ICredentialProvider - { - private readonly ChocolateyConfiguration _config; - - private const string INVALID_URL = "http://somewhere123zzaafasd.invalid"; - - public ChocolateyNugetCredentialProvider(ChocolateyConfiguration config) - { - _config = config; - } - - public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying) - { - if (uri == null) - { - throw new ArgumentNullException("uri"); - } - - if (retrying) - { - this.Log().Warn("Invalid credentials specified."); - } - - var configSourceUri = new Uri(INVALID_URL); - - this.Log().Debug(ChocolateyLoggers.Verbose, "Attempting to gather credentials for '{0}'".format_with(uri.OriginalString)); - try - { - // the source to validate against is typically passed in - var firstSpecifiedSource = _config.Sources.to_string().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault().to_string(); - if (!string.IsNullOrWhiteSpace(firstSpecifiedSource)) - { - configSourceUri = new Uri(firstSpecifiedSource); - } - } - catch (Exception ex) - { - this.Log().Warn("Cannot determine uri from specified source:{0} {1}".format_with(Environment.NewLine, ex.Message)); - } - - // did the user pass credentials and a source? - if (_config.Sources.TrimEnd('/').is_equal_to(uri.OriginalString.TrimEnd('/')) || configSourceUri.Host.is_equal_to(uri.Host)) - { - if (!string.IsNullOrWhiteSpace(_config.SourceCommand.Username) && !string.IsNullOrWhiteSpace(_config.SourceCommand.Password)) - { - this.Log().Debug("Using passed in credentials"); - - return new NetworkCredential(_config.SourceCommand.Username, _config.SourceCommand.Password); - } - } - - // credentials were not explicit - // discover based on closest match in sources - var candidateSources = _config.MachineSources.Where( - s => - { - var sourceUrl = s.Key.TrimEnd('/'); - - try - { - var sourceUri = new Uri(sourceUrl); - return sourceUri.Host.is_equal_to(uri.Host) - && !string.IsNullOrWhiteSpace(s.Username) - && !string.IsNullOrWhiteSpace(s.EncryptedPassword); - } - catch (Exception) - { - this.Log().Error("Source '{0}' is not a valid Uri".format_with(sourceUrl)); - } - - return false; - }).ToList(); - - MachineSourceConfiguration source = null; - - - if (candidateSources.Count == 1) - { - // only one match, use it - source = candidateSources.FirstOrDefault(); - } - else if (candidateSources.Count > 1) - { - // find the source that is the closest match - foreach (var candidateSource in candidateSources.or_empty_list_if_null()) - { - var candidateRegEx = new Regex(Regex.Escape(candidateSource.Key.TrimEnd('/')),RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (candidateRegEx.IsMatch(uri.OriginalString.TrimEnd('/'))) - { - this.Log().Debug("Source selected will be '{0}'".format_with(candidateSource.Key.TrimEnd('/'))); - source = candidateSource; - break; - } - } - - if (source == null && !retrying) - { - // use the first source. If it fails, fall back to grabbing credentials from the user - var candidateSource = candidateSources.First(); - this.Log().Debug("Evaluated {0} candidate sources but was unable to find a match, using {1}".format_with(candidateSources.Count, candidateSource.Key.TrimEnd('/'))); - source = candidateSource; - } - } - - if (source == null) - { - this.Log().Debug("Asking user for credentials for '{0}'".format_with(uri.OriginalString)); - return get_credentials_from_user(uri, proxy, credentialType); - } - else - { - this.Log().Debug("Using saved credentials"); - } - - return new NetworkCredential(source.Username, NugetEncryptionUtility.DecryptString(source.EncryptedPassword)); - } - - public ICredentials get_credentials_from_user(Uri uri, IWebProxy proxy, CredentialType credentialType) - { - if (!_config.Information.IsInteractive) - { - // https://blogs.msdn.microsoft.com/buckh/2004/07/28/authentication-in-web-services-with-httpwebrequest/ - //return credentialType == CredentialType.ProxyCredentials ? CredentialCache.DefaultCredentials : CredentialCache.DefaultNetworkCredentials; - return CredentialCache.DefaultCredentials; - } - - string message = credentialType == CredentialType.ProxyCredentials ? - "Please provide proxy credentials:" : - "Please provide credentials for: {0}".format_with(uri.OriginalString); - this.Log().Info(ChocolateyLoggers.Important, message); - - Console.Write("User name: "); - string username = Console.ReadLine(); - Console.Write("Password: "); - var password = InteractivePrompt.get_password(_config.PromptForConfirmation); - - if (string.IsNullOrWhiteSpace(password)) - { - this.Log().Warn("No password specified, this will probably error."); - //return CredentialCache.DefaultNetworkCredentials; - } - - var credentials = new NetworkCredential - { - UserName = username, - Password = password, - //SecurePassword = password.to_secure_string(), - }; - - return credentials; - } - } - - // ReSharper restore InconsistentNaming -} \ No newline at end of file diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs deleted file mode 100644 index a6f4b3d49d..0000000000 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc -// Copyright © 2011 - 2017 RealDimensions Software, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace chocolatey.infrastructure.app.nuget -{ - using System.IO; - using NuGet; - - // ReSharper disable InconsistentNaming - - public sealed class ChocolateyPackagePathResolver : DefaultPackagePathResolver - { - private readonly IFileSystem _nugetFileSystem; - public bool UseSideBySidePaths { get; set; } - - public ChocolateyPackagePathResolver(IFileSystem nugetFileSystem, bool useSideBySidePaths) - : base(nugetFileSystem, useSideBySidePaths) - { - _nugetFileSystem = nugetFileSystem; - UseSideBySidePaths = useSideBySidePaths; - } - - public override string GetInstallPath(IPackage package) - { - var packageVersionPath = Path.Combine(_nugetFileSystem.Root, GetPackageDirectory(package.Id,package.Version,useVersionInPath:true)); - if (_nugetFileSystem.DirectoryExists(packageVersionPath)) return packageVersionPath; - - - return Path.Combine(_nugetFileSystem.Root, GetPackageDirectory(package.Id, package.Version)); - } - - public override string GetPackageDirectory(string packageId, SemanticVersion version) - { - return GetPackageDirectory(packageId, version, UseSideBySidePaths); - } - - public string GetPackageDirectory(string packageId, SemanticVersion version, bool useVersionInPath) - { - string directory = packageId; - if (useVersionInPath) - { - directory += "." + version.to_string(); - } - - return directory; - } - - public override string GetPackageFileName(string packageId, SemanticVersion version) - { - string fileNameBase = packageId; - if (UseSideBySidePaths) - { - fileNameBase += "." + version.to_string(); - } - return fileNameBase + Constants.PackageExtension; - } - } - - // ReSharper restore InconsistentNaming -} \ No newline at end of file diff --git a/src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs b/src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs deleted file mode 100644 index 6d169c0be7..0000000000 --- a/src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc -// Copyright © 2011 - 2017 RealDimensions Software, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace chocolatey.infrastructure.app.nuget -{ - using System; - using System.Collections.Generic; - using System.IO; - using NuGet; - - // ReSharper disable InconsistentNaming - - public static class NuGetFileSystemExtensions - { - public static void AddFiles(this IFileSystem fileSystem, IEnumerable files, string rootDir, bool preserveFilePath) - { - foreach (IPackageFile file in files) - { - string path = Path.Combine(rootDir, preserveFilePath ? file.Path : Path.GetFileName(file.Path)); - fileSystem.AddFileWithCheck(path, file.GetStream); - } - } - - internal static void AddFileWithCheck(this IFileSystem fileSystem, string path, Func streamFactory) - { - using (Stream stream = streamFactory()) - { - fileSystem.AddFile(path, stream); - } - } - - internal static void AddFileWithCheck(this IFileSystem fileSystem, string path, Action write) - { - fileSystem.AddFile(path, write); - } - } - - // ReSharper restore InconsistentNaming -} diff --git a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs index ed4f4aff1e..fab859d3b5 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs @@ -28,6 +28,7 @@ namespace chocolatey.infrastructure.app.nuget using configuration; using filesystem; using logging; + using mockups; using NuGet.Common; using NuGet.Configuration; using NuGet.Packaging; @@ -52,23 +53,9 @@ private static IConsole Console get { return _console.Value; } } - public static IFileSystem GetNuGetFileSystem(ChocolateyConfiguration configuration, ILogger nugetLogger) - { - return new ChocolateyPhysicalFileSystem(ApplicationParameters.PackagesLocation) { Logger = nugetLogger }; - } - - public static IPackagePathResolver GetPathResolver(ChocolateyConfiguration configuration, IFileSystem nugetPackagesFileSystem) - { - return new ChocolateyPackagePathResolver(nugetPackagesFileSystem, configuration.AllowMultipleVersions); - } - - public static IPackageRepository GetLocalRepository(IPackagePathResolver pathResolver, IFileSystem nugetPackagesFileSystem, ILogger nugetLogger) - { - return new ChocolateyLocalPackageRepository(pathResolver, nugetPackagesFileSystem) { Logger = nugetLogger, PackageSaveMode = PackageSaveModes.Nupkg | PackageSaveModes.Nuspec }; - } - - public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader) + public static void GetRemoteRepository(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader) { + /* if (configuration.Features.ShowDownloadProgress) { packageDownloader.ProgressAvailable += (sender, e) => @@ -172,18 +159,18 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con ResolveDependenciesVertically = true }; - return repository; + return repository; */ } // keep this here for the licensed edition for now - public static IPackageManager GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, Action installSuccessAction, Action uninstallSuccessAction, bool addUninstallHandler) + public static void GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, Action installSuccessAction, Action uninstallSuccessAction, bool addUninstallHandler) { - return GetPackageManager(configuration, nugetLogger, new PackageDownloader(), installSuccessAction, uninstallSuccessAction, addUninstallHandler); + // return GetPackageManager(configuration, nugetLogger, new PackageDownloader(), installSuccessAction, uninstallSuccessAction, addUninstallHandler); } - public static IPackageManager GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader, Action installSuccessAction, Action uninstallSuccessAction, bool addUninstallHandler) + public static void GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader, Action installSuccessAction, Action uninstallSuccessAction, bool addUninstallHandler) { - IFileSystem nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger); + /* IFileSystem nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger); IPackagePathResolver pathResolver = GetPathResolver(configuration, nugetPackagesFileSystem); var packageManager = new PackageManager(GetRemoteRepository(configuration, nugetLogger, packageDownloader), pathResolver, nugetPackagesFileSystem, GetLocalRepository(pathResolver, nugetPackagesFileSystem, nugetLogger)) { @@ -245,7 +232,7 @@ public static IPackageManager GetPackageManager(ChocolateyConfiguration configur }; } - return packageManager; + return packageManager; */ } } diff --git a/src/chocolatey/infrastructure.app/nuget/NugetList.cs b/src/chocolatey/infrastructure.app/nuget/NugetList.cs deleted file mode 100644 index 5cf6241370..0000000000 --- a/src/chocolatey/infrastructure.app/nuget/NugetList.cs +++ /dev/null @@ -1,269 +0,0 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc -// Copyright © 2011 - 2017 RealDimensions Software, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace chocolatey.infrastructure.app.nuget -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - - using NuGet; - using configuration; - - // ReSharper disable InconsistentNaming - - public static class NugetList - { - public static IEnumerable GetPackages(ChocolateyConfiguration configuration, ILogger nugetLogger) - { - return execute_package_search(configuration, nugetLogger); - } - - public static int GetCount(ChocolateyConfiguration configuration, ILogger nugetLogger) - { - return execute_package_search(configuration, nugetLogger).Count(); - } - - private static IQueryable execute_package_search(ChocolateyConfiguration configuration, ILogger nugetLogger) - { - var packageRepository = NugetCommon.GetRemoteRepository(configuration, nugetLogger, new PackageDownloader()); - var searchTermLower = configuration.Input.to_lower(); - - // Whether or not the package is remote determines two things: - // 1. Does the repository have a notion of "listed"? - // 2. Does it support prerelease in a straight-forward way? - // Choco previously dealt with this by taking the path of least resistance and manually filtering out and sort unwanted packages - // This result in blocking operations that didn't let service based repositories, like OData, take care of heavy lifting on the server. - bool isServiceBased; - var aggregateRepo = packageRepository as AggregateRepository; - if (aggregateRepo != null) - { - isServiceBased = aggregateRepo.Repositories.All(repo => repo is IServiceBasedRepository); - } - else - { - isServiceBased = packageRepository is IServiceBasedRepository; - } - - SemanticVersion version = !string.IsNullOrWhiteSpace(configuration.Version) ? new SemanticVersion(configuration.Version) : null; - IQueryable results; - - if (!configuration.ListCommand.Exact) - { - results = packageRepository.Search(searchTermLower, configuration.Prerelease); - } - else - { - if (configuration.AllVersions) - { - // convert from a search to getting packages by id. - // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() - results = packageRepository.GetPackages().Where(p => p.Id.ToLower() == searchTermLower) - .AsEnumerable() - .Where(p => configuration.Prerelease || p.IsReleaseVersion()) - .AsQueryable(); - } - else - { - var exactPackage = find_package(searchTermLower, version, configuration, packageRepository); - - if (exactPackage == null) return new List().AsQueryable(); - - return new List() - { - exactPackage - }.AsQueryable(); - } - } - - if (configuration.ListCommand.Page.HasValue) - { - results = results.Skip(configuration.ListCommand.PageSize * configuration.ListCommand.Page.Value).Take(configuration.ListCommand.PageSize); - } - - if (configuration.ListCommand.ByIdOnly) - { - results = isServiceBased ? - results.Where(p => p.Id.ToLower().Contains(searchTermLower)) - : results.Where(p => p.Id.contains(searchTermLower, StringComparison.OrdinalIgnoreCase)); - } - - if (configuration.ListCommand.ByTagOnly) - { - results = isServiceBased - ? results.Where(p => p.Tags.Contains(searchTermLower)) - : results.Where(p => p.Tags.contains(searchTermLower, StringComparison.InvariantCultureIgnoreCase)); - } - - if (configuration.ListCommand.IdStartsWith) - { - results = isServiceBased ? - results.Where(p => p.Id.ToLower().StartsWith(searchTermLower)) - : results.Where(p => p.Id.StartsWith(searchTermLower, StringComparison.OrdinalIgnoreCase)); - } - - if (configuration.ListCommand.ApprovedOnly) - { - results = results.Where(p => p.IsApproved); - } - - if (configuration.ListCommand.DownloadCacheAvailable) - { - results = results.Where(p => p.IsDownloadCacheAvailable); - } - - if (configuration.ListCommand.NotBroken) - { - results = results.Where(p => (p.IsDownloadCacheAvailable && configuration.Information.IsLicensedVersion) || p.PackageTestResultStatus != "Failing"); - } - - if (configuration.AllVersions || !string.IsNullOrWhiteSpace(configuration.Version)) - { - if (isServiceBased) - { - return results.OrderBy(p => p.Id).ThenByDescending(p => p.Version); - } - else - { - return results.Where(PackageExtensions.IsListed).OrderBy(p => p.Id).ThenByDescending(p => p.Version).AsQueryable(); - } - } - - if (configuration.Prerelease && packageRepository.SupportsPrereleasePackages) - { - results = results.Where(p => p.IsAbsoluteLatestVersion); - } - else - { - results = results.Where(p => p.IsLatestVersion); - } - - if (!isServiceBased) - { - results = - results - .Where(PackageExtensions.IsListed) - .Where(p => configuration.Prerelease || p.IsReleaseVersion()) - .distinct_last(PackageEqualityComparer.Id, PackageComparer.Version) - .AsQueryable(); - } - - results = configuration.ListCommand.OrderByPopularity ? - results.OrderByDescending(p => p.DownloadCount).ThenBy(p => p.Id) - : results; - - return results; - } - - /// - /// Searches for packages that are available based on name and other options - /// - /// Name of package to search for - /// Optional version to search for - /// Chocolatey configuration used to help supply the search parameters - /// Repository (aggregate for multiple) to search in - /// One result or nothing - public static IPackage find_package(string packageName, SemanticVersion version, ChocolateyConfiguration config, IPackageRepository repository) - { - // use old method when newer method causes issues - if (!config.Features.UsePackageRepositoryOptimizations) return repository.FindPackage(packageName, version, config.Prerelease, allowUnlisted: false); - - packageName = packageName.to_string().ToLower(CultureInfo.CurrentCulture); - // find the package based on version using older method - if (version != null) return repository.FindPackage(packageName, version, config.Prerelease, allowUnlisted: false); - - // we should always be using an aggregate repository - var aggregateRepository = repository as AggregateRepository; - if (aggregateRepository != null) - { - var packageResults = new List(); - - foreach (var packageRepository in aggregateRepository.Repositories.or_empty_list_if_null()) - { - try - { - "chocolatey".Log().Debug("Using '" + packageRepository.Source + "'."); - "chocolatey".Log().Debug("- Supports prereleases? '" + packageRepository.SupportsPrereleasePackages + "'."); - "chocolatey".Log().Debug("- Is ServiceBased? '" + (packageRepository is IServiceBasedRepository) + "'."); - - // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() - IQueryable combinedResults = packageRepository.GetPackages().Where(x => x.Id.ToLower() == packageName); - - if (config.Prerelease && packageRepository.SupportsPrereleasePackages) - { - combinedResults = combinedResults.Where(p => p.IsAbsoluteLatestVersion); - } - else - { - combinedResults = combinedResults.Where(p => p.IsLatestVersion); - } - - if (!(packageRepository is IServiceBasedRepository)) - { - combinedResults = combinedResults - .Where(PackageExtensions.IsListed) - .Where(p => config.Prerelease || p.IsReleaseVersion()) - .distinct_last(PackageEqualityComparer.Id, PackageComparer.Version) - .AsQueryable(); - } - - var packageRepositoryResults = combinedResults.ToList(); - if (packageRepositoryResults.Count() != 0) - { - "chocolatey".Log().Debug("Package '{0}' found on source '{1}'".format_with(packageName, packageRepository.Source)); - packageResults.AddRange(packageRepositoryResults); - } - } - catch (Exception e) - { - "chocolatey".Log().Warn("Error retrieving packages from source '{0}':{1} {2}".format_with(packageRepository.Source, Environment.NewLine, e.Message)); - } - } - - // get only one result, should be the latest - similar to TryFindLatestPackageById - return packageResults.OrderByDescending(x => x.Version).FirstOrDefault(); - } - - // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() - IQueryable results = repository.GetPackages().Where(x => x.Id.ToLower() == packageName); - - if (config.Prerelease && repository.SupportsPrereleasePackages) - { - results = results.Where(p => p.IsAbsoluteLatestVersion); - } - else - { - results = results.Where(p => p.IsLatestVersion); - } - - if (!(repository is IServiceBasedRepository)) - { - results = results - .Where(PackageExtensions.IsListed) - .Where(p => config.Prerelease || p.IsReleaseVersion()) - .distinct_last(PackageEqualityComparer.Id, PackageComparer.Version) - .AsQueryable(); - } - - // get only one result, should be the latest - similar to TryFindLatestPackageById - return results.ToList().OrderByDescending(x => x.Version).FirstOrDefault(); - } - - } - - // ReSharper restore InconsistentNaming -} \ No newline at end of file diff --git a/src/chocolatey/infrastructure.app/nuget/NugetPack.cs b/src/chocolatey/infrastructure.app/nuget/NugetPack.cs index f0aa9cd358..0338bd9c6f 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetPack.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetPack.cs @@ -25,7 +25,7 @@ namespace chocolatey.infrastructure.app.nuget using NuGet.Common; using NuGet.Configuration; using NuGet.Packaging; - + // ReSharper disable InconsistentNaming public sealed class NugetPack diff --git a/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs b/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs index c612f2072d..c6bbb01faa 100644 --- a/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs +++ b/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs @@ -61,7 +61,7 @@ public void RegisterComponents(Container container) //nuget container.Register(Lifestyle.Singleton); container.Register(Lifestyle.Singleton); - container.Register(Lifestyle.Singleton); + //container.Register(Lifestyle.Singleton); container.Register(Lifestyle.Singleton); container.Register(Lifestyle.Singleton); container.Register(Lifestyle.Singleton); diff --git a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs index 50544c22f7..c46110ed31 100644 --- a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs +++ b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs @@ -71,6 +71,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) } } + /* var pkgInfo = _packageInfoService.get_package_information(packageResult.Package); if (pkgInfo.RegistrySnapshot == null) { @@ -91,6 +92,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) this.Log().Info(" Skipping auto uninstaller - No package in package information."); return; } + this.Log().Info(" Running auto uninstaller..."); if (WaitForCleanup) @@ -104,6 +106,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) var packageCacheLocation = _fileSystem.combine_paths(_fileSystem.get_full_path(config.CacheLocation), package.Id, package.Version.to_string()); remove(key, config, packageResult, packageCacheLocation); } + */ } public void remove(RegistryApplicationKey key, ChocolateyConfiguration config, PackageResult packageResult, string packageCacheLocation) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs index d9b220fd46..269dc3efbd 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs @@ -23,7 +23,9 @@ namespace chocolatey.infrastructure.app.services using NuGet; using domain; using infrastructure.configuration; + using mockups; using NuGet.Versioning; + using results; using tolerance; using IFileSystem = filesystem.IFileSystem; @@ -149,7 +151,7 @@ has errored attempting to read it. This file will be renamed to FaultTolerance.try_catch_with_logging_exception( () => { - packageInformation.VersionOverride = new SemanticVersion(_fileSystem.read_file(versionOverrideFile).trim_safe()); + packageInformation.VersionOverride = new SemanticVersion(SemanticVersion.Parse(_fileSystem.read_file(versionOverrideFile).trim_safe())); }, "Unable to read version override file", throwError: false, diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 8ee3274d08..67e8d559a7 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -31,6 +31,7 @@ namespace chocolatey.infrastructure.app.services using infrastructure.events; using infrastructure.services; using logging; + using mockups; using NuGet; using nuget; using platforms; @@ -506,6 +507,7 @@ private void create_ignore_files_for_executables(string installLocation, bool is protected virtual ChocolateyPackageInformation get_package_information(PackageResult packageResult, ChocolateyConfiguration config) { var pkgInfo = _packageInfoService.get_package_information(packageResult.Package); + if (config.AllowMultipleVersions) { pkgInfo.IsSideBySide = true; @@ -1046,7 +1048,7 @@ public virtual void handle_package_uninstall(PackageResult packageResult, Chocol private void uninstall_cleanup(ChocolateyConfiguration config, PackageResult packageResult) { - if (config.Features.RemovePackageInformationOnUninstall) _packageInfoService.remove_package_information(packageResult.Package); + //if (config.Features.RemovePackageInformationOnUninstall) _packageInfoService.remove_package_information(packageResult.Package); ensure_bad_package_path_is_clean(config, packageResult); remove_rollback_if_exists(packageResult); diff --git a/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs b/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs index d09004e9f6..d1ccdeb427 100644 --- a/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs +++ b/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs @@ -17,6 +17,7 @@ namespace chocolatey.infrastructure.app.services { using domain; + using mockups; using NuGet; public interface IChocolateyPackageInformationService diff --git a/src/chocolatey/infrastructure.app/services/IPowershellService.cs b/src/chocolatey/infrastructure.app/services/IPowershellService.cs index 7729643c02..e4c8b9d326 100644 --- a/src/chocolatey/infrastructure.app/services/IPowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/IPowershellService.cs @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.app.services using System; using System.Management.Automation.Runspaces; using configuration; + using mockups; using NuGet; using results; diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 7d6672265c..7fab59b79b 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -38,6 +38,7 @@ namespace chocolatey.infrastructure.app.services using Environment = System.Environment; using IFileSystem = filesystem.IFileSystem; using chocolatey.infrastructure.app.utility; + using mockups; using NuGet.Common; using NuGet.Configuration; using NuGet.PackageManagement; @@ -52,7 +53,7 @@ public class NugetService : INugetService private readonly ILogger _nugetLogger; private readonly IChocolateyPackageInformationService _packageInfoService; private readonly IFilesService _filesService; - private readonly IPackageDownloader _packageDownloader; + //private readonly PackageDownloader _packageDownloader; private readonly Lazy datetime_initializer = new Lazy(() => new DateTime()); private IDateTime DateTime @@ -68,13 +69,12 @@ private IDateTime DateTime /// Package information service /// The files service /// The downloader used to download packages - public NugetService(IFileSystem fileSystem, ILogger nugetLogger, IChocolateyPackageInformationService packageInfoService, IFilesService filesService, IPackageDownloader packageDownloader) + public NugetService(IFileSystem fileSystem, ILogger nugetLogger, IChocolateyPackageInformationService packageInfoService, IFilesService filesService) { _fileSystem = fileSystem; _nugetLogger = nugetLogger; _packageInfoService = packageInfoService; _filesService = filesService; - _packageDownloader = packageDownloader; } public SourceType SourceType @@ -89,6 +89,7 @@ public void ensure_source_app_installed(ChocolateyConfiguration config, Action

list_run(ChocolateyConfiguration config) { + return new PackageResult[0]; int count = 0; var sources = config.Sources; @@ -129,7 +131,7 @@ public virtual IEnumerable list_run(ChocolateyConfiguration confi config.Prerelease = true; config.ListCommand.IncludeVersionOverrides = true; } - + /* 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)) @@ -222,7 +224,7 @@ Package url yield return new PackageResult(package, null, config.Sources); } - + */ if (config.RegularOutput) this.Log().Debug(ChocolateyLoggers.Verbose, () => "--- End of List ---"); if (config.RegularOutput && !config.QuietOutput) { @@ -288,7 +290,7 @@ public virtual void pack_run(ChocolateyConfiguration config) properties["version"] = config.Version; } - + // Initialize the property provider based on what was passed in using the properties flag var propertyProvider = new DictionaryPropertyProvider(properties); @@ -324,13 +326,13 @@ public virtual void pack_run(ChocolateyConfiguration config) //{ // AnalyzePackage(package); //} - - this.Log().Info(config.QuietOutput ? ChocolateyLoggers.LogFileOnly : ChocolateyLoggers.Important, () => "Successfully created package '{0}'".format_with(outputPath)); + + this.Log().Info(config.QuietOutput ? ChocolateyLoggers.LogFileOnly : ChocolateyLoggers.Important, () => "Successfully created package '{0}'".format_with(outputPath)); } public void push_noop(ChocolateyConfiguration config) { - string nupkgFilePath = validate_and_return_package_file(config, Constants.PackageExtension); + string nupkgFilePath = validate_and_return_package_file(config, NuGetConstants.PackageExtension); this.Log().Info(() => "Would have attempted to push '{0}' to source '{1}'.".format_with(_fileSystem.get_file_name(nupkgFilePath), config.Sources)); } @@ -397,21 +399,21 @@ public virtual ConcurrentDictionary install_run(Chocolate //todo: #23 handle all - SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(config.Version) : null; + SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(SemanticVersion.Parse(config.Version)) : null; if (config.Force) config.AllowDowngrade = true; IList packageNames = config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().ToList(); if (packageNames.Count == 1) { var packageName = packageNames.DefaultIfEmpty(string.Empty).FirstOrDefault(); - if (packageName.EndsWith(Constants.PackageExtension) || packageName.EndsWith(Constants.ManifestExtension)) + if (packageName.EndsWith(NuGetConstants.PackageExtension) || packageName.EndsWith(PackagingConstants.ManifestExtension)) { this.Log().Debug("Updating source and package name to handle *.nupkg or *.nuspec file."); packageNames.Clear(); config.Sources = _fileSystem.get_directory_name(_fileSystem.get_full_path(packageName)); - if (packageName.EndsWith(Constants.ManifestExtension)) + if (packageName.EndsWith(PackagingConstants.ManifestExtension)) { packageNames.Add(_fileSystem.get_file_name_without_extension(packageName)); @@ -422,20 +424,21 @@ public virtual ConcurrentDictionary install_run(Chocolate } else { + /* var packageFile = new OptimizedZipPackage(_fileSystem.get_full_path(packageName)); version = packageFile.Version; - packageNames.Add(packageFile.Id); + packageNames.Add(packageFile.Id); */ } } } // this is when someone points the source directly at a nupkg // e.g. -source c:\somelocation\somewhere\packagename.nupkg - if (config.Sources.to_string().EndsWith(Constants.PackageExtension)) + if (config.Sources.to_string().EndsWith(NuGetConstants.PackageExtension)) { config.Sources = _fileSystem.get_directory_name(_fileSystem.get_full_path(config.Sources)); } - + /* var packageManager = NugetCommon.GetPackageManager( config, _nugetLogger, _packageDownloader, installSuccessAction: (e) => @@ -449,7 +452,7 @@ public virtual ConcurrentDictionary install_run(Chocolate }, uninstallSuccessAction: null, addUninstallHandler: true); - + var originalConfig = config.deep_copy(); foreach (string packageName in packageNames.or_empty_list_if_null()) @@ -491,7 +494,7 @@ public virtual ConcurrentDictionary install_run(Chocolate this.Log().Error(ChocolateyLoggers.Important, logMessage); continue; } - + /* IPackage availablePackage = NugetList.find_package(packageName, version, config, packageManager.SourceRepository); if (availablePackage == null) @@ -568,7 +571,7 @@ Version was specified as '{0}'. It is possible that version if (continueAction != null) continueAction.Invoke(errorResult); } } - + */ return packageInstalls; } @@ -609,10 +612,11 @@ public ConcurrentDictionary upgrade_run(ChocolateyConfigu public virtual ConcurrentDictionary upgrade_run(ChocolateyConfiguration config, Action continueAction, bool performAction, Action beforeUpgradeAction = null) { + _fileSystem.create_directory_if_not_exists(ApplicationParameters.PackagesLocation); var packageInstalls = new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase); - - SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(config.Version) : null; + /* + SemanticVersion version = !string.IsNullOrWhiteSpace(config.Version) ? new SemanticVersion(SemanticVersion.Parse(config.Version)) : null; if (config.Force) config.AllowDowngrade = true; var packageManager = NugetCommon.GetPackageManager( @@ -713,7 +717,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate // this is a prerelease - opt in for newer prereleases. config.Prerelease = true; } - + /* IPackage availablePackage = NugetList.find_package(packageName, version, config, packageManager.SourceRepository); config.Prerelease = originalPrerelease; @@ -747,7 +751,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate continue; } - + if (pkgInfo != null && pkgInfo.IsSideBySide) { //todo: #103 get smarter about realizing multiple versions have been installed before and allowing that @@ -774,7 +778,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate continue; } - + if (installedPackage.Version == availablePackage.Version) { string logMessage = "{0} v{1} is the latest version available based on your source(s).".format_with(installedPackage.Id, installedPackage.Version); @@ -891,12 +895,13 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate } } } - +*/ return packageInstalls; } public virtual ConcurrentDictionary get_outdated(ChocolateyConfiguration config) { + /* var packageManager = NugetCommon.GetPackageManager( config, _nugetLogger, @@ -906,13 +911,15 @@ public virtual ConcurrentDictionary get_outdated(Chocolat addUninstallHandler: false); var repository = packageManager.SourceRepository; - var outdatedPackages = new ConcurrentDictionary(); + */ + var outdatedPackages = new ConcurrentDictionary(); + /* set_package_names_if_all_is_specified(config, () => { config.IgnoreDependencies = true; }); var packageNames = config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().ToList(); var originalConfig = config.deep_copy(); - + /* foreach (var packageName in packageNames) { // reset config each time through @@ -939,7 +946,7 @@ public virtual ConcurrentDictionary get_outdated(Chocolat // this is a prerelease - opt in for newer prereleases. config.Prerelease = true; } - + SemanticVersion version = null; var latestPackage = NugetList.find_package(packageName, null, config, packageManager.SourceRepository); @@ -963,9 +970,9 @@ public virtual ConcurrentDictionary get_outdated(Chocolat string logMessage = "You have {0} v{1} installed. Version {2} is available based on your source(s).{3} Source(s): \"{4}\"".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, Environment.NewLine, config.Sources); packageResult.Messages.Add(new ResultMessage(ResultType.Note, logMessage)); - this.Log().Info("{0}|{1}|{2}|{3}".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, isPinned.to_string().to_lower())); + this.Log().Info("{0}|{1}|{2}|{3}".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, isPinned.to_string().to_lower())); } - + */ return outdatedPackages; } @@ -1023,6 +1030,7 @@ protected virtual ChocolateyConfiguration set_package_config_for_upgrade(Chocola private string get_install_directory(ChocolateyConfiguration config, IPackage installedPackage) { + /* var pathResolver = NugetCommon.GetPathResolver(config, NugetCommon.GetNuGetFileSystem(config, _nugetLogger)); var installDirectory = pathResolver.GetInstallPath(installedPackage); if (!_fileSystem.directory_exists(installDirectory)) @@ -1037,7 +1045,8 @@ private string get_install_directory(ChocolateyConfiguration config, IPackage in if (!_fileSystem.directory_exists(installDirectory)) return null; } - return installDirectory; + return installDirectory; */ + return "asdf"; } public virtual void ensure_package_files_have_compatible_attributes(ChocolateyConfiguration config, IPackage installedPackage, ChocolateyPackageInformation pkgInfo) @@ -1051,7 +1060,7 @@ public virtual void ensure_package_files_have_compatible_attributes(ChocolateyCo public virtual void rename_legacy_package_version(ChocolateyConfiguration config, IPackage installedPackage, ChocolateyPackageInformation pkgInfo) { if (pkgInfo != null && pkgInfo.IsSideBySide) return; - + /* var installDirectory = _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, installedPackage.Id); if (!_fileSystem.directory_exists(installDirectory)) { @@ -1065,6 +1074,7 @@ public virtual void rename_legacy_package_version(ChocolateyConfiguration config "Error during old package rename"); } } + */ } public virtual void backup_existing_version(ChocolateyConfiguration config, IPackage installedPackage, ChocolateyPackageInformation packageInfo) @@ -1264,8 +1274,8 @@ public ConcurrentDictionary uninstall_run(ChocolateyConfi public virtual ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, bool performAction, Action beforeUninstallAction = null) { var packageUninstalls = new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase); - - SemanticVersion version = config.Version != null ? new SemanticVersion(config.Version) : null; + /* + SemanticVersion version = config.Version != null ? new SemanticVersion(SemanticVersion.Parse(config.Version)) : null; var packageManager = NugetCommon.GetPackageManager(config, _nugetLogger, _packageDownloader, installSuccessAction: null, uninstallSuccessAction: (e) => @@ -1392,7 +1402,7 @@ public virtual ConcurrentDictionary uninstall_run(Chocola } else { - var semanticVersion = new SemanticVersion(config.Version); + var semanticVersion = new SemanticVersion(SemanticVersion.Parse(config.Version)); installedPackageVersions = packageManager.LocalRepository.FindPackagesById(packageName).Where((p) => p.Version.Equals(semanticVersion)).ToList(); } @@ -1510,7 +1520,7 @@ public virtual ConcurrentDictionary uninstall_run(Chocola } } } - + */ return packageUninstalls; } diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs index 25511564e9..d35efd3448 100644 --- a/src/chocolatey/infrastructure.app/services/PowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs @@ -34,6 +34,7 @@ namespace chocolatey.infrastructure.app.services using infrastructure.commands; using infrastructure.registration; using logging; + using mockups; using NuGet; using powershell; using results; @@ -196,7 +197,7 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack { var failure = false; var package = packageResult.Package; - prepare_powershell_environment(package, configuration, packageDirectory); + //prepare_powershell_environment(package, configuration, packageDirectory); this.Log().Debug(ChocolateyLoggers.Important, "Contents of '{0}':".format_with(chocoPowerShellScript)); string chocoPowerShellScriptContents = _fileSystem.read_file(chocoPowerShellScript); @@ -379,8 +380,8 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura Environment.SetEnvironmentVariable("packageTitle", package.Title); Environment.SetEnvironmentVariable("chocolateyPackageVersion", package.Version.to_string()); Environment.SetEnvironmentVariable("packageVersion", package.Version.to_string()); - Environment.SetEnvironmentVariable("chocolateyPackageVersionPrerelease", package.Version.SpecialVersion.to_string()); - Environment.SetEnvironmentVariable("chocolateyPackageVersionPackageRelease", package.Version.PackageReleaseVersion.to_string()); + //Environment.SetEnvironmentVariable("chocolateyPackageVersionPrerelease", package.Version.SpecialVersion.to_string()); + //Environment.SetEnvironmentVariable("chocolateyPackageVersionPackageRelease", package.Version.PackageReleaseVersion.to_string()); Environment.SetEnvironmentVariable("chocolateyPackageFolder", packageDirectory); Environment.SetEnvironmentVariable("packageFolder", packageDirectory); @@ -464,7 +465,7 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura if (package.IsDownloadCacheAvailable) { Environment.SetEnvironmentVariable("DownloadCacheAvailable", "true"); - + /* foreach (var downloadCache in package.DownloadCache.or_empty_list_if_null()) { var urlKey = CryptoHashProvider.hash_value(downloadCache.OriginalUrl, CryptoHashProviderType.Sha256).Replace("=", string.Empty); @@ -472,6 +473,7 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura Environment.SetEnvironmentVariable("CacheChecksum_{0}".format_with(urlKey), downloadCache.Checksum); Environment.SetEnvironmentVariable("CacheChecksumType_{0}".format_with(urlKey), "sha512"); } + */ } SecurityProtocol.set_protocol(configuration, provideWarning:false); diff --git a/src/chocolatey/infrastructure.app/services/TemplateService.cs b/src/chocolatey/infrastructure.app/services/TemplateService.cs index 5961c88664..93834938e9 100644 --- a/src/chocolatey/infrastructure.app/services/TemplateService.cs +++ b/src/chocolatey/infrastructure.app/services/TemplateService.cs @@ -212,11 +212,13 @@ public void list_noop(ChocolateyConfiguration configuration) public void list(ChocolateyConfiguration configuration) { + + /* var packageManager = NugetCommon.GetPackageManager(configuration, _nugetLogger, new PackageDownloader(), installSuccessAction: null, uninstallSuccessAction: null, - addUninstallHandler: false); + addUninstallHandler: false); */ var templateDirList = _fileSystem.get_directories(ApplicationParameters.TemplatesLocation).ToList(); var isBuiltInTemplateOverriden = templateDirList.Contains(_fileSystem.combine_paths(ApplicationParameters.TemplatesLocation, _builtInTemplateOverrideName)); @@ -229,7 +231,7 @@ public void list(ChocolateyConfiguration configuration) foreach (var templateDir in templateDirList) { configuration.TemplateCommand.Name = _fileSystem.get_file_name(templateDir); - list_custom_template_info(configuration, packageManager); + //list_custom_template_info(configuration, packageManager); } this.Log().Info(configuration.RegularOutput ? "{0} Custom templates found at {1}{2}".format_with(templateDirList.Count(), ApplicationParameters.TemplatesLocation, Environment.NewLine) : string.Empty); @@ -245,7 +247,7 @@ public void list(ChocolateyConfiguration configuration) { if (templateDirList.Contains(_fileSystem.combine_paths(ApplicationParameters.TemplatesLocation, configuration.TemplateCommand.Name))) { - list_custom_template_info(configuration, packageManager); + //list_custom_template_info(configuration, packageManager); if (configuration.TemplateCommand.Name == _builtInTemplateName || configuration.TemplateCommand.Name == _builtInTemplateOverrideName) { list_built_in_template_info(configuration, isBuiltInTemplateOverriden, isBuiltInOrDefaultTemplateDefault); @@ -265,7 +267,7 @@ public void list(ChocolateyConfiguration configuration) } } } - + /* protected void list_custom_template_info(ChocolateyConfiguration configuration, IPackageManager packageManager) { var pkg = packageManager.LocalRepository.FindPackage("{0}.template".format_with(configuration.TemplateCommand.Name)); @@ -311,7 +313,7 @@ protected void list_custom_template_info(ChocolateyConfiguration configuration, { this.Log().Info("{0}|{1}".format_with(configuration.TemplateCommand.Name, pkgVersion)); } - } + } */ protected void list_built_in_template_info(ChocolateyConfiguration configuration, bool isOverridden, bool isDefault) { diff --git a/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs b/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs index e37c9934ae..71c8286c3e 100644 --- a/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs +++ b/src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs @@ -87,7 +87,7 @@ public string generate_unique_token(string caseInsensitiveKey) { // SHA256 is case sensitive; given that our key is case insensitive, we upper case it var pathBytes = Encoding.UTF8.GetBytes(caseInsensitiveKey.ToUpperInvariant()); - var hashProvider = new NuGet.CryptoHashProvider("SHA256"); + var hashProvider = new NuGet.Common.CryptoHashProvider("SHA256"); return Convert.ToBase64String(hashProvider.CalculateHash(pathBytes)).ToUpperInvariant(); } diff --git a/src/chocolatey/infrastructure/mockups/IPackage.cs b/src/chocolatey/infrastructure/mockups/IPackage.cs new file mode 100644 index 0000000000..8aeba03998 --- /dev/null +++ b/src/chocolatey/infrastructure/mockups/IPackage.cs @@ -0,0 +1,84 @@ +// Copyright © 2017 - 2021 Chocolatey Software, Inc +// Copyright © 2011 - 2017 RealDimensions Software, LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace chocolatey.infrastructure.mockups +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.IO; + using System.Runtime.Versioning; + using filesystem; + using NuGet.Packaging; + using NuGet.Versioning; + + public interface IPackage : IPackageMetadata + { + bool IsAbsoluteLatestVersion { get; } + + bool IsLatestVersion { get; } + + bool Listed { get; } + + DateTimeOffset? Published { get; } + + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This might be expensive")] + IEnumerable GetFiles(); + + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This might be expensive")] + IEnumerable GetSupportedFrameworks(); + + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This might be expensive")] + Stream GetStream(); + + void ExtractContents(IFileSystem fileSystem, string extractPath); + + void OverrideOriginalVersion(SemanticVersion version); + + Uri ProjectSourceUrl { get; } + Uri PackageSourceUrl { get; } + Uri DocsUrl { get; } + Uri WikiUrl { get; } + Uri MailingListUrl { get; } + Uri BugTrackerUrl { get; } + IEnumerable Replaces { get; } + IEnumerable Provides { get; } + IEnumerable Conflicts { get; } + + string SoftwareDisplayName { get; } + string SoftwareDisplayVersion { get; } + + string PackageHash { get; } + string PackageHashAlgorithm { get; } + long PackageSize { get; } + int VersionDownloadCount { get; } + + bool IsApproved { get; } + string PackageStatus { get; } + string PackageSubmittedStatus { get; } + string PackageTestResultStatus { get; } + DateTime? PackageTestResultStatusDate { get; } + string PackageValidationResultStatus { get; } + DateTime? PackageValidationResultDate { get; } + DateTime? PackageCleanupResultDate { get; } + DateTime? PackageReviewedDate { get; } + DateTime? PackageApprovedDate { get; } + string PackageReviewer { get; } + + bool IsDownloadCacheAvailable { get; } + DateTime? DownloadCacheDate { get; } + } +} \ No newline at end of file diff --git a/src/chocolatey/infrastructure/mockups/IPackageManager.cs b/src/chocolatey/infrastructure/mockups/IPackageManager.cs new file mode 100644 index 0000000000..1f5e78b19c --- /dev/null +++ b/src/chocolatey/infrastructure/mockups/IPackageManager.cs @@ -0,0 +1,72 @@ +// Copyright © 2017 - 2021 Chocolatey Software, Inc +// Copyright © 2011 - 2017 RealDimensions Software, LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace chocolatey.infrastructure.mockups +{ + using filesystem; + using NuGet.Common; + using NuGet.Versioning; + + public interface IPackageManager + { + IFileSystem FileSystem { get; set; } + + IPackageRepository LocalRepository { get; } + + ILogger Logger { get; set; } + + bool WhatIf { get; set; } + + IPackageRepository SourceRepository { get; } + + + void InstallPackage(IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions); + + void InstallPackage( + IPackage package, + bool ignoreDependencies, + bool allowPrereleaseVersions, + bool ignoreWalkInfo); + + void InstallPackage( + string packageId, + SemanticVersion version, + bool ignoreDependencies, + bool allowPrereleaseVersions); + + void UpdatePackage(IPackage newPackage, bool updateDependencies, bool allowPrereleaseVersions); + + void UpdatePackage( + string packageId, + SemanticVersion version, + bool updateDependencies, + bool allowPrereleaseVersions); + + void UpdatePackage( + string packageId, + string versionSpec, + bool updateDependencies, + bool allowPrereleaseVersions); + + void UninstallPackage(IPackage package, bool forceRemove, bool removeDependencies); + + void UninstallPackage( + string packageId, + SemanticVersion version, + bool forceRemove, + bool removeDependencies); + } +} \ No newline at end of file diff --git a/src/chocolatey/infrastructure/mockups/IPackageRepository.cs b/src/chocolatey/infrastructure/mockups/IPackageRepository.cs new file mode 100644 index 0000000000..cc223ed7e7 --- /dev/null +++ b/src/chocolatey/infrastructure/mockups/IPackageRepository.cs @@ -0,0 +1,35 @@ +// Copyright © 2017 - 2021 Chocolatey Software, Inc +// Copyright © 2011 - 2017 RealDimensions Software, LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace chocolatey.infrastructure.mockups +{ + using System.Diagnostics.CodeAnalysis; + using System.Linq; + + public interface IPackageRepository + { + string Source { get; } + + bool SupportsPrereleasePackages { get; } + + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This call might be expensive")] + IQueryable GetPackages(); + + void AddPackage(IPackage package); + + void RemovePackage(IPackage package); + } +} \ No newline at end of file diff --git a/src/chocolatey/infrastructure/mockups/PackageOperationEventArgs.cs b/src/chocolatey/infrastructure/mockups/PackageOperationEventArgs.cs new file mode 100644 index 0000000000..125d0bbf34 --- /dev/null +++ b/src/chocolatey/infrastructure/mockups/PackageOperationEventArgs.cs @@ -0,0 +1,37 @@ +// Copyright © 2017 - 2021 Chocolatey Software, Inc +// Copyright © 2011 - 2017 RealDimensions Software, LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace chocolatey.infrastructure.mockups +{ + using System.ComponentModel; + using filesystem; + + public class PackageOperationEventArgs : CancelEventArgs + { + public PackageOperationEventArgs(IPackage package, IFileSystem fileSystem, string installPath) + { + this.Package = package; + this.InstallPath = installPath; + this.FileSystem = fileSystem; + } + + public string InstallPath { get; private set; } + + public IPackage Package { get; private set; } + + public IFileSystem FileSystem { get; private set; } + } +} \ No newline at end of file diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs b/src/chocolatey/infrastructure/mockups/PhysicalFileSystem.cs similarity index 60% rename from src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs rename to src/chocolatey/infrastructure/mockups/PhysicalFileSystem.cs index 908011508c..b9db4515fb 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs +++ b/src/chocolatey/infrastructure/mockups/PhysicalFileSystem.cs @@ -14,25 +14,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.nuget +namespace chocolatey.infrastructure.mockups { + using System; using System.Collections.Generic; - using NuGet; + using NuGet.Packaging; - // ReSharper disable InconsistentNaming - - public class ChocolateyPhysicalFileSystem : PhysicalFileSystem + public class PhysicalFileSystem { - public ChocolateyPhysicalFileSystem(string root) - : base(root) + private readonly string _root; + + public PhysicalFileSystem(string root) { + if (String.IsNullOrEmpty(root)) + { + throw new ArgumentException("thing"); + } + _root = root; } - - public override void AddFiles(IEnumerable files, string rootDir) + public virtual void AddFiles(IEnumerable files, string rootDir) { - this.AddFiles(files, rootDir, preserveFilePath: true); } } - - // ReSharper restore InconsistentNaming -} +} \ No newline at end of file diff --git a/src/chocolatey/infrastructure/results/PackageResult.cs b/src/chocolatey/infrastructure/results/PackageResult.cs index 5c5a35c2a3..6ece4a2b61 100644 --- a/src/chocolatey/infrastructure/results/PackageResult.cs +++ b/src/chocolatey/infrastructure/results/PackageResult.cs @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.results using System; using System.Collections.Generic; using System.Linq; + using mockups; using NuGet.Packaging; ///

@@ -63,7 +64,8 @@ public PackageResult(IPackage package, string installLocation, string source = n } } - + Source = sources.FirstOrDefault(uri => uri.IsFile || uri.IsUnc).to_string(); + /* TODO, fix this var rp = Package as DataServicePackage; if (rp != null && rp.DownloadUrl != null) { @@ -78,6 +80,7 @@ public PackageResult(IPackage package, string installLocation, string source = n { Source = sources.FirstOrDefault(uri => uri.IsFile || uri.IsUnc).to_string(); } + */ } public PackageResult(string name, string version, string installLocation, string source = null)