From 1ee1229c4281f2fcfcd5b99d011572e725552ede Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Thu, 16 Jun 2022 13:32:14 -0500 Subject: [PATCH 1/4] (#508) Rip out NuGet.Core Remove NuGet.Core dll and project references to it. --- src/chocolatey.console/chocolatey.console.csproj | 4 ---- .../chocolatey.tests.integration.csproj | 4 ---- .../scenarios/InstallScenarios.cs | 1 - src/chocolatey.tests.integration/scenarios/ListScenarios.cs | 1 - src/chocolatey.tests.integration/scenarios/PinScenarios.cs | 1 - .../scenarios/UninstallScenarios.cs | 1 - .../scenarios/UpgradeScenarios.cs | 1 - src/chocolatey.tests/chocolatey.tests.csproj | 4 ---- .../infrastructure.app/commands/ChocolateyPinCommandSpecs.cs | 1 - .../infrastructure.app/nuget/NugetCommonSpecs.cs | 1 - .../services/AutomaticUninstallerServiceSpecs.cs | 1 - .../services/ChocolateyPackageServiceSpecs.cs | 1 - .../infrastructure.app/services/NugetServiceSpecs.cs | 1 - src/chocolatey/chocolatey.csproj | 4 ---- .../infrastructure.app/commands/ChocolateyPinCommand.cs | 1 - .../infrastructure.app/domain/ChocolateyPackageInformation.cs | 1 - .../nuget/ChocolateyClientCertificateProvider.cs | 1 - .../nuget/ChocolateyLocalPackageRepository.cs | 1 - .../nuget/ChocolateyNugetCredentialProvider.cs | 1 - .../infrastructure.app/nuget/ChocolateyNugetLogger.cs | 1 - .../infrastructure.app/nuget/ChocolateyPackagePathResolver.cs | 1 - .../infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs | 1 - .../infrastructure.app/nuget/DictionaryPropertyProvider.cs | 1 - .../infrastructure.app/nuget/NuGetFileSystemExtensions.cs | 1 - src/chocolatey/infrastructure.app/nuget/NugetCommon.cs | 1 - src/chocolatey/infrastructure.app/nuget/NugetList.cs | 2 -- src/chocolatey/infrastructure.app/nuget/NugetPack.cs | 1 - src/chocolatey/infrastructure.app/nuget/NugetPush.cs | 1 - .../registration/ChocolateyRegistrationModule.cs | 1 - .../infrastructure.app/registration/ContainerBinding.cs | 1 - .../registration/SimpleInjectorContainerRegistrator.cs | 1 - .../services/ChocolateyPackageInformationService.cs | 1 - .../infrastructure.app/services/ChocolateyPackageService.cs | 1 - .../services/IChocolateyPackageInformationService.cs | 1 - .../infrastructure.app/services/IPowershellService.cs | 1 - src/chocolatey/infrastructure.app/services/NugetService.cs | 1 - .../infrastructure.app/services/PowershellService.cs | 1 - src/chocolatey/infrastructure.app/services/TemplateService.cs | 1 - src/chocolatey/infrastructure/results/PackageResult.cs | 1 - 39 files changed, 52 deletions(-) diff --git a/src/chocolatey.console/chocolatey.console.csproj b/src/chocolatey.console/chocolatey.console.csproj index fcefdcc500..247276ade9 100644 --- a/src/chocolatey.console/chocolatey.console.csproj +++ b/src/chocolatey.console/chocolatey.console.csproj @@ -157,10 +157,6 @@ ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll - - False - ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll - ..\packages\SimpleInjector.2.8.3\lib\net45\SimpleInjector.dll diff --git a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj index b3493c386e..64edb0d117 100644 --- a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj +++ b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj @@ -78,10 +78,6 @@ ..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll - - False - ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll - ..\packages\NUnit.3.13.3\lib\net40\nunit.framework.dll diff --git a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs index 9889aecd15..f91faa28ba 100644 --- a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs @@ -26,7 +26,6 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; - using NuGet; using NUnit.Framework; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; diff --git a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs index 4cb749e00d..fa7850e617 100644 --- a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs @@ -23,7 +23,6 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.configuration; using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.results; - using NuGet; using NUnit.Framework; using Should; diff --git a/src/chocolatey.tests.integration/scenarios/PinScenarios.cs b/src/chocolatey.tests.integration/scenarios/PinScenarios.cs index 4dfc339120..3758028bbb 100644 --- a/src/chocolatey.tests.integration/scenarios/PinScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/PinScenarios.cs @@ -26,7 +26,6 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.domain; using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; - using NuGet; using NUnit.Framework; diff --git a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs index 0707905fd4..ffc37548f6 100644 --- a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs @@ -26,7 +26,6 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.commands; using chocolatey.infrastructure.filesystem; using chocolatey.infrastructure.results; - using NuGet; using NUnit.Framework; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; diff --git a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs index 7048d7d0bf..1b8da55e95 100644 --- a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs @@ -28,7 +28,6 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.filesystem; using chocolatey.infrastructure.results; - using NuGet; using NUnit.Framework; using Should; diff --git a/src/chocolatey.tests/chocolatey.tests.csproj b/src/chocolatey.tests/chocolatey.tests.csproj index 7ae3ba348f..e92c90f5ee 100644 --- a/src/chocolatey.tests/chocolatey.tests.csproj +++ b/src/chocolatey.tests/chocolatey.tests.csproj @@ -77,10 +77,6 @@ ..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll - - False - ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll - ..\packages\NUnit.3.13.3\lib\net40\nunit.framework.dll diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs index 303785a46b..f57e7a71b9 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs @@ -28,7 +28,6 @@ namespace chocolatey.tests.infrastructure.app.commands using chocolatey.infrastructure.commandline; using chocolatey.infrastructure.results; using Moq; - using NuGet; using Should; public class ChocolateyPinCommandSpecs diff --git a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs index 03d31f27c2..d749d8ef39 100644 --- a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs @@ -21,7 +21,6 @@ namespace chocolatey.tests.infrastructure.app.nuget using chocolatey.infrastructure.app.configuration; using chocolatey.infrastructure.app.nuget; using Moq; - using NuGet; using Should; public class NugetCommonSpecs diff --git a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs index 0b12f36c2c..38aeb2d3db 100644 --- a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs @@ -31,7 +31,6 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; using Moq; - using NuGet; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; public class AutomaticUninstallerServiceSpecs diff --git a/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs index 43317e0198..3a5070d86b 100644 --- a/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs @@ -26,7 +26,6 @@ using chocolatey.infrastructure.results; using chocolatey.infrastructure.services; using Moq; -using NuGet; using NUnit.Framework; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; diff --git a/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs index a68b6d17b2..b96acbb26f 100644 --- a/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs @@ -24,7 +24,6 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.app.domain; using chocolatey.infrastructure.app.services; using Moq; - using NuGet; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index 2205a8f27b..9167794d71 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -93,10 +93,6 @@ False ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll - - False - ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll - ..\..\lib\Rhino.Licensing.1.4.1\lib\net40\Rhino.Licensing.dll diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs index 53851701a0..56c96e186e 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs @@ -19,7 +19,6 @@ namespace chocolatey.infrastructure.app.commands using System; using System.Collections.Generic; using System.Linq; - using NuGet; using attributes; using commandline; using configuration; diff --git a/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs b/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs index 9066d004a4..6795a16056 100644 --- a/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs +++ b/src/chocolatey/infrastructure.app/domain/ChocolateyPackageInformation.cs @@ -17,7 +17,6 @@ namespace chocolatey.infrastructure.app.domain { using System; - using NuGet; public sealed class ChocolateyPackageInformation { diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs index 365a93ee52..8486a18b0d 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs +++ b/src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs @@ -17,7 +17,6 @@ namespace chocolatey.infrastructure.app.nuget { using configuration; - using NuGet; using System; using System.Linq; using System.Net; diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs index 6525b1a091..d9e65dd7fb 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs +++ b/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs @@ -22,7 +22,6 @@ namespace chocolatey.infrastructure.app.nuget using System.Linq; using System.Runtime.Versioning; using System.Threading; - using NuGet; // ReSharper disable InconsistentNaming diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs index 610f680223..54efd9fe2c 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs +++ b/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetCredentialProvider.cs @@ -21,7 +21,6 @@ namespace chocolatey.infrastructure.app.nuget using System.Net; using System.Text.RegularExpressions; using commandline; - using NuGet; using configuration; using logging; diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetLogger.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetLogger.cs index fb2b125cf0..2ad906a47a 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetLogger.cs +++ b/src/chocolatey/infrastructure.app/nuget/ChocolateyNugetLogger.cs @@ -17,7 +17,6 @@ namespace chocolatey.infrastructure.app.nuget { using logging; - using NuGet; // ReSharper disable InconsistentNaming diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs index f612861b9e..0c8b96f3f2 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs +++ b/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs @@ -18,7 +18,6 @@ namespace chocolatey.infrastructure.app.nuget { using System; using System.IO; - using NuGet; // ReSharper disable InconsistentNaming diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs index 866462ebae..a68d97d20a 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs +++ b/src/chocolatey/infrastructure.app/nuget/ChocolateyPhysicalFileSystem.cs @@ -17,7 +17,6 @@ namespace chocolatey.infrastructure.app.nuget { using System.Collections.Generic; - using NuGet; // ReSharper disable InconsistentNaming diff --git a/src/chocolatey/infrastructure.app/nuget/DictionaryPropertyProvider.cs b/src/chocolatey/infrastructure.app/nuget/DictionaryPropertyProvider.cs index 02a06a0b89..38070d7dc6 100644 --- a/src/chocolatey/infrastructure.app/nuget/DictionaryPropertyProvider.cs +++ b/src/chocolatey/infrastructure.app/nuget/DictionaryPropertyProvider.cs @@ -17,7 +17,6 @@ namespace chocolatey.infrastructure.app.nuget { using System.Collections.Generic; - using NuGet; // ReSharper disable InconsistentNaming diff --git a/src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs b/src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs index 41923eb668..e6811f9807 100644 --- a/src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs +++ b/src/chocolatey/infrastructure.app/nuget/NuGetFileSystemExtensions.cs @@ -19,7 +19,6 @@ namespace chocolatey.infrastructure.app.nuget using System; using System.Collections.Generic; using System.IO; - using NuGet; // ReSharper disable InconsistentNaming diff --git a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs index 169265df00..48606ef73c 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs @@ -24,7 +24,6 @@ namespace chocolatey.infrastructure.app.nuget using System.Text; using adapters; using infrastructure.configuration; - using NuGet; using configuration; using logging; using Console = adapters.Console; diff --git a/src/chocolatey/infrastructure.app/nuget/NugetList.cs b/src/chocolatey/infrastructure.app/nuget/NugetList.cs index ee55cc7b1b..12d8e9aa75 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetList.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetList.cs @@ -20,8 +20,6 @@ namespace chocolatey.infrastructure.app.nuget using System.Collections.Generic; using System.Globalization; using System.Linq; - - using NuGet; using configuration; // ReSharper disable InconsistentNaming diff --git a/src/chocolatey/infrastructure.app/nuget/NugetPack.cs b/src/chocolatey/infrastructure.app/nuget/NugetPack.cs index 71a5c5bfae..fa2ef76e54 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetPack.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetPack.cs @@ -20,7 +20,6 @@ namespace chocolatey.infrastructure.app.nuget using System.Collections.Generic; using System.IO; using System.Linq; - using NuGet; using IFileSystem = filesystem.IFileSystem; using chocolatey.infrastructure.platforms; diff --git a/src/chocolatey/infrastructure.app/nuget/NugetPush.cs b/src/chocolatey/infrastructure.app/nuget/NugetPush.cs index bee8cd6f4d..7a00d3f02f 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetPush.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetPush.cs @@ -18,7 +18,6 @@ namespace chocolatey.infrastructure.app.nuget { using System; using System.IO; - using NuGet; using configuration; using logging; diff --git a/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs b/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs index 8436e7e31f..1af322fc2d 100644 --- a/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs +++ b/src/chocolatey/infrastructure.app/registration/ChocolateyRegistrationModule.cs @@ -26,7 +26,6 @@ namespace chocolatey.infrastructure.app.registration using chocolatey.infrastructure.services; using chocolatey.infrastructure.tasks; using chocolatey.infrastructure.validations; - using NuGet; using CryptoHashProvider = cryptography.CryptoHashProvider; using IFileSystem = filesystem.IFileSystem; using IHashProvider = cryptography.IHashProvider; diff --git a/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs b/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs index b9396e5e40..c3e0344127 100644 --- a/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs +++ b/src/chocolatey/infrastructure.app/registration/ContainerBinding.cs @@ -28,7 +28,6 @@ namespace chocolatey.infrastructure.app.registration using chocolatey.infrastructure.logging; using chocolatey.infrastructure.services; using infrastructure.configuration; - using NuGet; using SimpleInjector; using Assembly = adapters.Assembly; diff --git a/src/chocolatey/infrastructure.app/registration/SimpleInjectorContainerRegistrator.cs b/src/chocolatey/infrastructure.app/registration/SimpleInjectorContainerRegistrator.cs index cd83cea5fa..50badf178b 100644 --- a/src/chocolatey/infrastructure.app/registration/SimpleInjectorContainerRegistrator.cs +++ b/src/chocolatey/infrastructure.app/registration/SimpleInjectorContainerRegistrator.cs @@ -26,7 +26,6 @@ namespace chocolatey.infrastructure.app.registration using infrastructure.commands; using infrastructure.events; using infrastructure.services; - using NuGet; using SimpleInjector; using Assembly = adapters.Assembly; diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs index 9971e24fea..c297e35caf 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs @@ -21,7 +21,6 @@ namespace chocolatey.infrastructure.app.services using System.IO; using System.Text; using configuration; - using NuGet; using domain; using infrastructure.configuration; using tolerance; diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 09ae129488..a969ac5fa3 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -31,7 +31,6 @@ namespace chocolatey.infrastructure.app.services using infrastructure.services; using logging; using nuget; - using NuGet; using platforms; using results; using tolerance; diff --git a/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs b/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs index d09004e9f6..5c5b1c65f9 100644 --- a/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs +++ b/src/chocolatey/infrastructure.app/services/IChocolateyPackageInformationService.cs @@ -17,7 +17,6 @@ namespace chocolatey.infrastructure.app.services { using domain; - using NuGet; public interface IChocolateyPackageInformationService { diff --git a/src/chocolatey/infrastructure.app/services/IPowershellService.cs b/src/chocolatey/infrastructure.app/services/IPowershellService.cs index 097cb278e0..0b21ed3270 100644 --- a/src/chocolatey/infrastructure.app/services/IPowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/IPowershellService.cs @@ -20,7 +20,6 @@ namespace chocolatey.infrastructure.app.services using System.Collections.Generic; using System.Management.Automation.Runspaces; using configuration; - using NuGet; using results; public interface IPowershellService diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 651cd84e68..e909d46e2b 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -30,7 +30,6 @@ namespace chocolatey.infrastructure.app.services using guards; using logging; using nuget; - using NuGet; using platforms; using results; using tolerance; diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs index 6f1be64f55..2b274aba18 100644 --- a/src/chocolatey/infrastructure.app/services/PowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs @@ -31,7 +31,6 @@ namespace chocolatey.infrastructure.app.services using infrastructure.commands; using infrastructure.registration; using logging; - using NuGet; using powershell; using results; using utility; diff --git a/src/chocolatey/infrastructure.app/services/TemplateService.cs b/src/chocolatey/infrastructure.app/services/TemplateService.cs index 9e6d2355d2..cac651efe6 100644 --- a/src/chocolatey/infrastructure.app/services/TemplateService.cs +++ b/src/chocolatey/infrastructure.app/services/TemplateService.cs @@ -27,7 +27,6 @@ namespace chocolatey.infrastructure.app.services using logging; using templates; using tokens; - using NuGet; using nuget; using IFileSystem = filesystem.IFileSystem; diff --git a/src/chocolatey/infrastructure/results/PackageResult.cs b/src/chocolatey/infrastructure/results/PackageResult.cs index 7c7066c037..2743e3ab44 100644 --- a/src/chocolatey/infrastructure/results/PackageResult.cs +++ b/src/chocolatey/infrastructure/results/PackageResult.cs @@ -19,7 +19,6 @@ namespace chocolatey.infrastructure.results using System; using System.Collections.Generic; using System.Linq; - using NuGet; /// /// Outcome of package installation From 8b7f355f4fafc08e8c3b02d898bc7843b8535656 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Mon, 27 Jun 2022 17:53:23 -0500 Subject: [PATCH 2/4] (#508) Uplift To NuGet.Client (#508) Update using references to new NuGet libraries (#508) Update Constants references for new libraries update constants (#508) ChocolateyNugetLogger update to nuget logger changes (#508) Update method of getting remote repository This allows getting the remote repositories and remote resources from the config, with authentication and client certificates attached as available. (#508) Get Push working (#508) Get pack compiling This gets pack working, if the package is using the NuGet compatible schema without the added Chocolatey specific elements (#508) Switch nupkg reading to PackageArchiveReader As OptimizedZipPackage is no longer available Switch to using my forked libraries Switch package result to use IPackageMetadata/IPackageServerMetadata Fix Pin, Template and Export commands Get List working Misc fixes Get Outdated, Install, Upgrade and Uninstall compiling Try initial manual package installation routine Remove Pending from Install Scenarios and tweak tests Fixes a couple of tests that have different behavior with newer NuGet Fixes a couple of tests that were pending, and were not written correctly Add better exception handling during setup to TinySpec ChocolateyPackageMetadata handle .nuspecs Fixes for List Make sure results are not duplicated, and that ordering is correct Add Identity to packageresult ChocolateyPackagePathResolver fix for side by side and use to get install location temp add debug asset to ensure metadata available NuGetCommon add more methods and tweak GetPackageDependencies This adds methods to get the local/installed package repository, to get dependencies for installed packages, and fixes GetPackageDependencies to get dependencys with ranges Switch to PackageMetadataResource to get all package versions Port over install improvements from parallel install branch misc cleanups Switch package service actions to include configuration Upgrade command work Switch depender to parent Add in package page to list verbose output Work on upgrade/uninstall Upgrade to nuget 6.4.0.4 Upgrade and Uninstall get passing tests Upgrade NuGet SDK build Update path resolver to specify correct manifest name upgrade nuget library version again Add tests for side by side nuspec and nupkg file names This adds tests to ensure that the manifest and package files are correctly named, that is with the version in the filenames if side by side, and without the version if not side by side. Remove now unused nugetpackagemanager related code Update my added integration tests Fixes and adds a test to the switch side by side to normal install scenario. Tweak install package resolution for side by side and add a test Update messages in some pester tests --- build.ps1 | 2 +- .../chocolatey.console.csproj | 4 +- src/chocolatey.console/packages.config | 2 +- .../chocolatey.tests.integration.csproj | 31 +- .../packages.config | 9 +- .../scenarios/InstallScenarios.cs | 660 +++++++--- .../scenarios/ListScenarios.cs | 33 +- .../scenarios/PinScenarios.cs | 5 +- .../scenarios/UninstallScenarios.cs | 13 +- .../scenarios/UpgradeScenarios.cs | 370 ++++-- src/chocolatey.tests/chocolatey.tests.csproj | 31 +- .../commands/ChocolateyPinCommandSpecs.cs | 36 +- .../nuget/NugetCommonSpecs.cs | 11 +- .../AutomaticUninstallerServiceSpecs.cs | 22 +- .../services/ChocolateyPackageServiceSpecs.cs | 14 +- .../services/NugetServiceSpecs.cs | 10 +- .../services/TemplateServiceSpecs.cs | 6 +- src/chocolatey.tests/packages.config | 9 +- src/chocolatey/chocolatey.csproj | 62 +- .../commands/ChocolateyExportCommand.cs | 4 +- .../commands/ChocolateyPinCommand.cs | 46 +- .../domain/ChocolateyPackageInformation.cs | 9 +- .../domain/ChocolateyPackageMetadata.cs | 212 +++ .../ChocolateyClientCertificateProvider.cs | 71 - .../nuget/ChocolateyLocalPackageRepository.cs | 10 +- .../nuget/ChocolateyNuGetProjectContext.cs | 133 ++ .../nuget/ChocolateyNuGetSettings.cs | 59 + .../ChocolateyNugetCredentialProvider.cs | 32 +- .../nuget/ChocolateyNugetLogger.cs | 140 +- .../nuget/ChocolateyPackagePathResolver.cs | 66 +- .../nuget/ChocolateyPhysicalFileSystem.cs | 3 +- .../nuget/ChocolateySourceCacheContext.cs | 84 ++ .../nuget/DictionaryPropertyProvider.cs | 4 +- .../nuget/NuGetFileSystemExtensions.cs | 9 +- .../infrastructure.app/nuget/NugetCommon.cs | 324 ++++- .../infrastructure.app/nuget/NugetList.cs | 285 +++- .../infrastructure.app/nuget/NugetPack.cs | 10 +- .../infrastructure.app/nuget/NugetPush.cs | 41 +- .../ChocolateyRegistrationModule.cs | 5 +- .../registration/ContainerBinding.cs | 8 +- .../SimpleInjectorContainerRegistrator.cs | 1 + .../services/AutomaticUninstallerService.cs | 7 +- .../ChocolateyPackageInformationService.cs | 9 +- .../services/ChocolateyPackageService.cs | 50 +- .../services/CygwinService.cs | 14 +- .../IChocolateyPackageInformationService.cs | 5 +- .../services/IPowershellService.cs | 4 +- .../services/ISourceRunner.cs | 14 +- .../services/NugetService.cs | 1170 ++++++++++++----- .../services/PowershellService.cs | 33 +- .../services/PythonService.cs | 14 +- .../services/RubyGemsService.cs | 14 +- .../services/TemplateService.cs | 31 +- .../services/WebPiService.cs | 14 +- .../services/WindowsFeatureService.cs | 14 +- .../cryptography/DefaultEncryptionUtility.cs | 2 +- .../infrastructure/results/PackageResult.cs | 61 +- src/chocolatey/packages.config | 17 +- .../commands/choco-info.Tests.ps1 | 2 +- .../commands/choco-install.Tests.ps1 | 12 +- .../commands/choco-list.Tests.ps1 | 4 +- .../commands/choco-pack.Tests.ps1 | 6 +- 62 files changed, 3260 insertions(+), 1123 deletions(-) create mode 100644 src/chocolatey/infrastructure.app/domain/ChocolateyPackageMetadata.cs delete mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateyClientCertificateProvider.cs create mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateyNuGetProjectContext.cs create mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateyNuGetSettings.cs create mode 100644 src/chocolatey/infrastructure.app/nuget/ChocolateySourceCacheContext.cs diff --git a/build.ps1 b/build.ps1 index 674e6d1868..adfb2811aa 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,4 @@ -########################################################################## +########################################################################## # This is the Cake bootstrapper script for PowerShell. # This file was downloaded from https://github.com/cake-build/resources # Feel free to change this file to fit your needs. diff --git a/src/chocolatey.console/chocolatey.console.csproj b/src/chocolatey.console/chocolatey.console.csproj index 247276ade9..a1d575ee1d 100644 --- a/src/chocolatey.console/chocolatey.console.csproj +++ b/src/chocolatey.console/chocolatey.console.csproj @@ -154,8 +154,8 @@ ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll + + ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll ..\packages\SimpleInjector.2.8.3\lib\net45\SimpleInjector.dll diff --git a/src/chocolatey.console/packages.config b/src/chocolatey.console/packages.config index 84c493cc67..be3de666cc 100644 --- a/src/chocolatey.console/packages.config +++ b/src/chocolatey.console/packages.config @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj index 64edb0d117..6fdcae3a80 100644 --- a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj +++ b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj @@ -72,12 +72,33 @@ ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll + + ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll ..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Chocolatey.NuGet.Common.3.0.0-alpha-20221121-42\lib\net472\NuGet.Common.dll + + + ..\packages\Chocolatey.NuGet.Configuration.3.0.0-alpha-20221121-42\lib\net472\NuGet.Configuration.dll + + + ..\packages\NuGet.Frameworks.3.0.0-alpha-20221121-42\lib\net472\NuGet.Frameworks.dll + + + ..\packages\Chocolatey.NuGet.Packaging.3.0.0-alpha-20221121-42\lib\net472\NuGet.Packaging.dll + + + ..\packages\Chocolatey.NuGet.Protocol.3.0.0-alpha-20221121-42\lib\net472\NuGet.Protocol.dll + + + ..\packages\Chocolatey.NuGet.Versioning.3.0.0-alpha-20221121-42\lib\net472\NuGet.Versioning.dll + ..\packages\NUnit.3.13.3\lib\net40\nunit.framework.dll @@ -90,6 +111,10 @@ + + + + ..\packages\Rx-Core.2.1.30214.0\lib\Net40\System.Reactive.Core.dll @@ -99,6 +124,8 @@ ..\packages\Rx-Linq.2.1.30214.0\lib\Net40\System.Reactive.Linq.dll + + diff --git a/src/chocolatey.tests.integration/packages.config b/src/chocolatey.tests.integration/packages.config index 9c0e7e0c0a..0cad6ce81e 100644 --- a/src/chocolatey.tests.integration/packages.config +++ b/src/chocolatey.tests.integration/packages.config @@ -1,8 +1,15 @@  + + + + + - + + + diff --git a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs index f91faa28ba..0d8fad2a7b 100644 --- a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs @@ -26,6 +26,8 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; + using NuGet.Configuration; + using NuGet.Packaging; using NUnit.Framework; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; @@ -45,8 +47,8 @@ public override void Context() Configuration = Scenario.install(); Scenario.reset(Configuration); Configuration.PackageNames = Configuration.Input = "installpackage"; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "badpackage.1*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "badpackage.1*" + NuGetConstants.PackageExtension); Service = NUnitSetup.Container.GetInstance(); @@ -176,9 +178,11 @@ public void should_install_the_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -345,10 +349,10 @@ public override void Context() base.Context(); var packagesConfig = "{0}{1}context{1}testing.packages.config".format_with(Scenario.get_top_level(), Path.DirectorySeparatorChar); Configuration.PackageNames = Configuration.Input = packagesConfig; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "upgradepackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "upgradepackage*" + NuGetConstants.PackageExtension); } public override void Because() @@ -508,9 +512,11 @@ public void should_still_have_a_package_in_the_lib_directory() [Fact] public void should_still_have_the_expected_version_of_the_package_installed() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -591,9 +597,11 @@ public void should_install_the_package_in_the_lib_directory() [Fact] public void should_install_the_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -683,9 +691,11 @@ public override void Because() [Fact] public void should_restore_the_backup_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -780,9 +790,11 @@ public void should_reinstall_the_package_in_the_lib_directory() [Fact] public void should_reinstall_the_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -877,13 +889,14 @@ public void should_have_a_package_installed_in_the_lib_directory() [Fact] public void should_still_have_the_package_installed_with_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] - [Pending("Force install with file locked leaves inconsistent state - GH-114")] public void should_delete_the_rollback() { var packageDir = Path.Combine(Scenario.get_top_level(), "lib-bkp", Configuration.PackageNames); @@ -904,7 +917,6 @@ public void should_contain_a_message_that_it_was_unable_to_reinstall_successfull } [Fact] - [Pending("Force install with file locked leaves inconsistent state - GH-114")] public void should_not_have_a_successful_package_result() { packageResult.Success.ShouldBeFalse(); @@ -917,7 +929,6 @@ public void should_have_inconclusive_package_result() } [Fact] - [Pending("Force install with file locked leaves inconsistent state - GH-114")] public void should_not_have_warning_package_result() { packageResult.Warning.ShouldBeFalse(); @@ -1205,7 +1216,7 @@ public override void Context() Configuration.PackageNames = Configuration.Input = "nonterminatingerror"; Configuration.Features.FailOnStandardError = false; //the default - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); } public override void Because() @@ -1231,9 +1242,11 @@ public void should_install_the_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.Input, Configuration.Input + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.Input, Configuration.Input + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1273,9 +1286,9 @@ public void config_should_match_package_result_name() } [Fact] - public void should_have_a_version_of_one_dot_zero() + public void should_have_a_version_of_one_dot_zero_dot_zero() { - packageResult.Version.ShouldEqual("1.0"); + packageResult.Version.ShouldEqual("1.0.0"); } } @@ -1291,7 +1304,7 @@ public override void Context() Configuration.PackageNames = Configuration.Input = "nonterminatingerror"; Configuration.Features.FailOnStandardError = true; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); } public override void Because() @@ -1407,6 +1420,50 @@ public void should_install_a_package_in_the_lib_directory() DirectoryAssert.Exists(packageDir); } + [Fact] + public void should_put_version_in_nupkg_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + ".1.0.0" + NuGetConstants.PackageExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_put_version_in_nuspec_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + ".1.0.0" + NuGetConstants.ManifestExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_not_have_nupkg_without_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + NuGetConstants.PackageExtension)); + + FileAssert.DoesNotExist(packageFile); + } + + [Fact] + public void should_not_have_nuspec_without_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + NuGetConstants.ManifestExtension)); + + FileAssert.DoesNotExist(packageFile); + } + [Fact] public void should_contain_a_warning_message_that_it_installed_successfully() { @@ -1498,6 +1555,50 @@ public void should_install_a_package_in_the_lib_directory() DirectoryAssert.Exists(packageDir); } + [Fact] + public void should_put_version_in_nupkg_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + ".1.0.0" + NuGetConstants.PackageExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_put_version_in_nuspec_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + ".1.0.0" + NuGetConstants.ManifestExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_not_have_nupkg_without_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + NuGetConstants.PackageExtension)); + + FileAssert.DoesNotExist(packageFile); + } + + [Fact] + public void should_not_have_nuspec_without_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.0.0"), + (Configuration.PackageNames + NuGetConstants.ManifestExtension)); + + FileAssert.DoesNotExist(packageFile); + } + [Fact] public void should_contain_a_warning_message_that_it_installed_successfully() { @@ -1541,6 +1642,128 @@ public void should_have_a_version_of_one_dot_zero_dot_zero() } } + public class when_installing_an_older_version_side_by_side_with_a_newer_version : ScenariosBase + { + private PackageResult packageResult; + + public override void Context() + { + base.Context(); + Configuration.PackageNames = Configuration.Input = "isdependency"; + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); + Scenario.install_package(Configuration, "isdependency", "2.0.0"); + Configuration.AllowMultipleVersions = true; + Configuration.Version = "1.1.0"; + } + + public override void Because() + { + Results = Service.install_run(Configuration); + packageResult = Results.FirstOrDefault().Value; + } + + [Fact] + public void should_install_where_install_location_reports() + { + DirectoryAssert.Exists(packageResult.InstallLocation); + } + + [Fact] + public void should_install_a_package_in_the_lib_directory() + { + var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames) + ".1.1.0"; + + DirectoryAssert.Exists(packageDir); + } + + [Fact] + public void should_put_version_in_nupkg_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.1.0"), + (Configuration.PackageNames + ".1.1.0" + NuGetConstants.PackageExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_put_version_in_nuspec_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.1.0"), + (Configuration.PackageNames + ".1.1.0" + NuGetConstants.ManifestExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_not_have_nupkg_without_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.1.0"), + (Configuration.PackageNames + NuGetConstants.PackageExtension)); + + FileAssert.DoesNotExist(packageFile); + } + + [Fact] + public void should_not_have_nuspec_without_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + (Configuration.PackageNames + ".1.1.0"), + (Configuration.PackageNames + NuGetConstants.ManifestExtension)); + + FileAssert.DoesNotExist(packageFile); + } + + [Fact] + public void should_contain_a_warning_message_that_it_installed_successfully() + { + bool installedSuccessfully = false; + foreach (var message in MockLogger.MessagesFor(LogLevel.Warn).or_empty_list_if_null()) + { + if (message.Contains("1/1")) installedSuccessfully = true; + } + + installedSuccessfully.ShouldBeTrue(); + } + + [Fact] + public void should_have_a_successful_package_result() + { + packageResult.Success.ShouldBeTrue(); + } + + [Fact] + public void should_not_have_inconclusive_package_result() + { + packageResult.Inconclusive.ShouldBeFalse(); + } + + [Fact] + public void should_not_have_warning_package_result() + { + packageResult.Warning.ShouldBeFalse(); + } + + [Fact] + public void config_should_match_package_result_name() + { + packageResult.Name.ShouldEqual(Configuration.PackageNames); + } + + [Fact] + public void should_have_a_version_of_one_dot_one_dot_zero() + { + packageResult.Version.ShouldEqual("1.1.0"); + } + } + + public class when_switching_a_side_by_side_package_to_a_normal_package : ScenariosBase { private PackageResult packageResult; @@ -1574,6 +1797,58 @@ public void should_install_a_package_in_the_lib_directory() DirectoryAssert.Exists(packageDir); } + [Fact] + public void should_remove_version_directory_in_the_lib_directory() + { + var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames + ".1.0.0"); + + DirectoryAssert.DoesNotExist(packageDir); + } + + [Fact] + public void should_not_put_version_in_nupkg_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + Configuration.PackageNames, + (Configuration.PackageNames + NuGetConstants.PackageExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_not_put_version_in_nuspec_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + Configuration.PackageNames, + (Configuration.PackageNames + NuGetConstants.ManifestExtension)); + + FileAssert.Exists(packageFile); + } + + [Fact] + public void should_not_have_nupkg_with_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + Configuration.PackageNames, + (Configuration.PackageNames + ".1.0.0" + NuGetConstants.PackageExtension)); + + FileAssert.DoesNotExist(packageFile); + } + + [Fact] + public void should_not_have_nuspec_with_version_in_filename() + { + var packageFile = Path.Combine( + Scenario.get_top_level(), "lib", + Configuration.PackageNames, + (Configuration.PackageNames + ".1.0.0" + NuGetConstants.ManifestExtension)); + + FileAssert.DoesNotExist(packageFile); + } + [Fact] public void should_contain_a_warning_message_that_it_installed_successfully() { @@ -1623,9 +1898,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); } public override void Because() @@ -1662,8 +1937,10 @@ public void should_install_the_dependency_in_the_lib_directory() public void should_install_the_expected_version_of_the_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1722,11 +1999,11 @@ public override void Context() base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); - Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension); Configuration.Force = true; } @@ -1755,9 +2032,11 @@ public void should_install_a_package_in_the_lib_directory() [Fact] public void should_reinstall_the_exact_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1772,8 +2051,10 @@ public void should_still_have_the_dependency_in_the_lib_directory() public void should_not_upgrade_the_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1832,11 +2113,11 @@ public override void Context() base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); - Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension); Configuration.Force = true; Configuration.ForceDependencies = true; } @@ -1866,9 +2147,11 @@ public void should_install_a_package_in_the_lib_directory() [Fact] public void should_reinstall_the_exact_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1883,16 +2166,20 @@ public void should_install_the_dependency_in_the_lib_directory() public void should_reinstall_the_floating_dependency_with_the_latest_version_that_satisfies_the_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] public void should_reinstall_the_exact_same_version_of_the_exact_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1942,11 +2229,11 @@ public override void Context() base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); - Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension); Configuration.Force = true; Configuration.IgnoreDependencies = true; } @@ -1976,9 +2263,11 @@ public void should_install_a_package_in_the_lib_directory() [Fact] public void should_reinstall_the_exact_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1993,16 +2282,20 @@ public void should_install_the_dependency_in_the_lib_directory() public void should_not_touch_the_floating_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] public void should_not_touch_the_exact_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2052,11 +2345,11 @@ public override void Context() base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); - Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension); Configuration.Force = true; Configuration.ForceDependencies = true; Configuration.IgnoreDependencies = true; @@ -2087,9 +2380,11 @@ public void should_install_a_package_in_the_lib_directory() [Fact] public void should_reinstall_the_exact_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2152,7 +2447,7 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + NuGetConstants.PackageExtension); } public override void Because() @@ -2262,7 +2557,7 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + NuGetConstants.PackageExtension); Configuration.IgnoreDependencies = true; } @@ -2289,9 +2584,11 @@ public void should_install_a_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] @@ -2345,10 +2642,10 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.1.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.1.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); } @@ -2377,9 +2674,11 @@ public void should_install_a_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.6.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.6.0.0"); + } } [Fact] @@ -2394,8 +2693,10 @@ public void should_install_the_dependency_in_the_lib_directory() public void should_upgrade_the_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -2444,9 +2745,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); } @@ -2509,9 +2810,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Configuration.IgnoreDependencies = true; } @@ -2541,9 +2842,11 @@ public void should_install_a_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.6.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.6.0.0"); + } } [Fact] @@ -2592,9 +2895,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Configuration.Force = true; Configuration.ForceDependencies = true; @@ -2617,8 +2920,10 @@ public void should_not_install_a_package_in_the_lib_directory() public void should_not_upgrade_the_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2705,10 +3010,10 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "conflictingdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.1.0.1*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.1.0.1*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); } @@ -2739,8 +3044,10 @@ public void should_install_a_package_in_the_lib_directory() public void should_upgrade_the_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.1.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.1.0"); + } } [Fact] @@ -2789,10 +3096,10 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "conflictingdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); } @@ -2803,17 +3110,15 @@ public override void Because() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_install_the_conflicting_package() { foreach (var packageResult in Results) { - DirectoryAssert.Exists(packageResult.Value.InstallLocation); + DirectoryAssert.DoesNotExist(packageResult.Value.InstallLocation); } } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_install_the_conflicting_package_in_the_lib_directory() { var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames); @@ -2822,25 +3127,26 @@ public void should_not_install_the_conflicting_package_in_the_lib_directory() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_upgrade_the_minimum_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_contain_a_message_that_it_was_unable_to_install_any_packages() { bool expectedMessage = false; @@ -2853,7 +3159,6 @@ public void should_contain_a_message_that_it_was_unable_to_install_any_packages( } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_have_a_successful_package_result() { foreach (var packageResult in Results) @@ -2863,7 +3168,6 @@ public void should_not_have_a_successful_package_result() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_have_inconclusive_package_result() { foreach (var packageResult in Results) @@ -2873,7 +3177,6 @@ public void should_not_have_inconclusive_package_result() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_have_warning_package_result() { foreach (var packageResult in Results) @@ -2883,7 +3186,6 @@ public void should_not_have_warning_package_result() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_have_an_error_package_result() { bool errorFound = false; @@ -2909,10 +3211,10 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "conflictingdependency", "2.1.0"); } @@ -2929,7 +3231,6 @@ public override void Because() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_install_the_conflicting_package_in_the_lib_directory() { var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames); @@ -2938,16 +3239,16 @@ public void should_not_install_the_conflicting_package_in_the_lib_directory() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] - public void should_not_upgrade_the_exact_version_dependency() + public void should_not_downgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0"); + } } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_contain_a_message_that_it_was_unable_to_install_any_packages() { bool expectedMessage = false; @@ -2960,7 +3261,6 @@ public void should_contain_a_message_that_it_was_unable_to_install_any_packages( } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_have_a_successful_package_result() { foreach (var packageResult in Results) @@ -2970,7 +3270,6 @@ public void should_not_have_a_successful_package_result() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_have_inconclusive_package_result() { foreach (var packageResult in Results) @@ -2980,7 +3279,6 @@ public void should_not_have_inconclusive_package_result() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_not_have_warning_package_result() { foreach (var packageResult in Results) @@ -2990,7 +3288,6 @@ public void should_not_have_warning_package_result() } [Fact] - [Pending("NuGet does not deal with version conflicts - GH-116")] public void should_have_an_error_package_result() { bool errorFound = false; @@ -3016,9 +3313,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "toplevelhasexactversiondependency"; - Scenario.add_packages_to_source_location(Configuration, "toplevelhasexactversiondependency*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "childdependencywithlooserversiondependency*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "toplevelhasexactversiondependency*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "childdependencywithlooserversiondependency*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); } public override void Because() @@ -3034,7 +3331,6 @@ public override void Because() */ [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_install_where_install_location_reports() { foreach (var packageResult in Results) @@ -3044,7 +3340,6 @@ public void should_install_where_install_location_reports() } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_install_a_package_in_the_lib_directory() { var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames); @@ -3053,7 +3348,6 @@ public void should_install_a_package_in_the_lib_directory() } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_install_the_dependency_in_the_lib_directory() { var packageDir = Path.Combine(Scenario.get_top_level(), "lib", "childdependencywithlooserversiondependency"); @@ -3062,25 +3356,26 @@ public void should_install_the_dependency_in_the_lib_directory() } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_install_the_expected_version_of_the_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "childdependencywithlooserversiondependency", "childdependencywithlooserversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_install_the_expected_version_of_the_constrained_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_contain_a_message_that_everything_installed_successfully() { bool expectedMessage = false; @@ -3093,7 +3388,6 @@ public void should_contain_a_message_that_everything_installed_successfully() } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_have_a_successful_package_result() { foreach (var packageResult in Results) @@ -3103,7 +3397,6 @@ public void should_have_a_successful_package_result() } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_not_have_inconclusive_package_result() { foreach (var packageResult in Results) @@ -3113,7 +3406,6 @@ public void should_not_have_inconclusive_package_result() } [Fact] - [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] public void should_not_have_warning_package_result() { foreach (var packageResult in Results) @@ -3156,9 +3448,11 @@ public void should_install_the_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "installpackage", "installpackage" + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "installpackage", "installpackage" + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -3320,7 +3614,7 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "upgradepackage"; - Scenario.add_packages_to_source_location(Configuration, "upgradepackage.1.0.0*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "upgradepackage.1.0.0*" + NuGetConstants.PackageExtension); _xmlFilePath = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "tools", "console.exe.config"); } @@ -3336,9 +3630,11 @@ public override void Because() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -3428,7 +3724,7 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "scriptpackage.hook"; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + NuGetConstants.PackageExtension); } private PackageResult _packageResult; @@ -3450,9 +3746,11 @@ public void should_install_the_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -3533,7 +3831,7 @@ public class when_installing_a_package_happy_path_with_hook_scripts : ScenariosB public override void Context() { base.Context(); - Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0"); Configuration.PackageNames = Configuration.Input = "installpackage"; } @@ -3561,9 +3859,11 @@ public void should_install_the_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -3786,10 +4086,10 @@ public class when_installing_a_portable_package_happy_path_with_hook_scripts : S public override void Context() { base.Context(); - Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0"); Configuration.PackageNames = Configuration.Input = "portablepackage"; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); } public override void Because() @@ -3815,9 +4115,11 @@ public void should_install_the_package_in_the_lib_directory() [Fact] public void should_install_the_expected_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] diff --git a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs index fa7850e617..6bdc38c039 100644 --- a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs @@ -23,6 +23,7 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.configuration; using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.results; + using NuGet.Configuration; using NUnit.Framework; using Should; @@ -39,8 +40,8 @@ public override void Context() { Configuration = Scenario.list(); Scenario.reset(Configuration); - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "installpackage*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "installpackage", "1.0.0"); Scenario.install_package(Configuration, "upgradepackage", "1.0.0"); @@ -437,7 +438,7 @@ public override void Context() { Configuration = Scenario.list(); Scenario.reset(Configuration); - Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension); Service = NUnitSetup.Container.GetInstance(); Configuration.ListCommand.Exact = true; @@ -496,7 +497,7 @@ public override void Context() { Configuration = Scenario.list(); Scenario.reset(Configuration); - Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension); Service = NUnitSetup.Container.GetInstance(); Configuration.ListCommand.Exact = true; @@ -551,7 +552,7 @@ public override void Context() { Configuration = Scenario.list(); Scenario.reset(Configuration); - Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension); Service = NUnitSetup.Container.GetInstance(); Configuration.ListCommand.Exact = true; @@ -580,15 +581,15 @@ public void should_find_two_results() [Fact] public void should_find_only_packages_with_exact_id() { - Results[0].Package.Id.ShouldEqual("exactpackage"); - Results[1].Package.Id.ShouldEqual("exactpackage"); + Results[0].PackageMetadata.Id.ShouldEqual("exactpackage"); + Results[1].PackageMetadata.Id.ShouldEqual("exactpackage"); } [Fact] public void should_find_all_non_prerelease_versions_in_descending_order() { - Results[0].Package.Version.ToNormalizedString().ShouldEqual("1.0.0"); - Results[1].Package.Version.ToNormalizedString().ShouldEqual("0.9.0"); + Results[0].PackageMetadata.Version.ToNormalizedString().ShouldEqual("1.0.0"); + Results[1].PackageMetadata.Version.ToNormalizedString().ShouldEqual("0.9.0"); } } @@ -598,7 +599,7 @@ public override void Context() { Configuration = Scenario.list(); Scenario.reset(Configuration); - Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension); Service = NUnitSetup.Container.GetInstance(); Configuration.ListCommand.Exact = true; @@ -628,17 +629,17 @@ public void should_find_three_results() [Fact] public void should_find_only_packages_with_exact_id() { - Results[0].Package.Id.ShouldEqual("exactpackage"); - Results[1].Package.Id.ShouldEqual("exactpackage"); - Results[2].Package.Id.ShouldEqual("exactpackage"); + Results[0].PackageMetadata.Id.ShouldEqual("exactpackage"); + Results[1].PackageMetadata.Id.ShouldEqual("exactpackage"); + Results[2].PackageMetadata.Id.ShouldEqual("exactpackage"); } [Fact] public void should_find_all_versions_in_descending_order() { - Results[0].Package.Version.ToNormalizedString().ShouldEqual("1.0.0"); - Results[1].Package.Version.ToNormalizedString().ShouldEqual("1.0.0-beta1"); - Results[2].Package.Version.ToNormalizedString().ShouldEqual("0.9.0"); + Results[0].PackageMetadata.Version.ToNormalizedString().ShouldEqual("1.0.0"); + Results[1].PackageMetadata.Version.ToNormalizedString().ShouldEqual("1.0.0-beta1"); + Results[2].PackageMetadata.Version.ToNormalizedString().ShouldEqual("0.9.0"); } } } diff --git a/src/chocolatey.tests.integration/scenarios/PinScenarios.cs b/src/chocolatey.tests.integration/scenarios/PinScenarios.cs index 3758028bbb..7c17f7a6f6 100644 --- a/src/chocolatey.tests.integration/scenarios/PinScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/PinScenarios.cs @@ -29,6 +29,7 @@ namespace chocolatey.tests.integration.scenarios using NUnit.Framework; + using NuGet.Configuration; using Should; public class PinScenarios @@ -44,8 +45,8 @@ public override void Context() { Configuration = Scenario.pin(); Scenario.reset(Configuration); - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "installpackage*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "installpackage", "1.0.0"); Scenario.install_package(Configuration, "upgradepackage", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); diff --git a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs index ffc37548f6..6f06c336d4 100644 --- a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs @@ -26,6 +26,7 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.commands; using chocolatey.infrastructure.filesystem; using chocolatey.infrastructure.results; + using NuGet.Configuration; using NUnit.Framework; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; @@ -45,9 +46,9 @@ public override void Context() Configuration = Scenario.uninstall(); Scenario.reset(Configuration); Configuration.PackageNames = Configuration.Input = "installpackage"; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "installpackage", "1.0.0"); - Scenario.add_packages_to_source_location(Configuration, "badpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "badpackage*" + NuGetConstants.PackageExtension); Configuration.SkipPackageInstallProvider = true; Scenario.install_package(Configuration, "badpackage", "1.0"); Configuration.SkipPackageInstallProvider = false; @@ -989,8 +990,8 @@ public void should_not_remove_package_from_the_lib_directory() [Fact] public void should_still_have_the_package_file_in_the_directory() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - File.Exists(packageFile).ShouldBeTrue(); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + FileAssert.Exists(packageFile); } [Fact] @@ -1079,7 +1080,7 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "scriptpackage.hook"; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + NuGetConstants.PackageExtension); Service.install_run(Configuration); } @@ -1157,7 +1158,7 @@ public class when_uninstalling_a_package_happy_path_with_hooks : ScenariosBase public override void Context() { base.Context(); - Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0"); } diff --git a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs index 1b8da55e95..10e41abcff 100644 --- a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs @@ -28,6 +28,8 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.filesystem; using chocolatey.infrastructure.results; + using NuGet.Configuration; + using NuGet.Packaging; using NUnit.Framework; using Should; @@ -45,9 +47,9 @@ public override void Context() Configuration = Scenario.upgrade(); Scenario.reset(Configuration); Configuration.PackageNames = Configuration.Input = "upgradepackage"; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "badpackage*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "installpackage*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "badpackage*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "installpackage", "1.0.0"); Scenario.install_package(Configuration, "upgradepackage", "1.0.0"); Configuration.SkipPackageInstallProvider = true; @@ -241,9 +243,11 @@ public void should_contain_newer_version_in_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -399,9 +403,11 @@ public void should_not_remove_the_package_from_the_lib_directory() [Fact] public void should_be_the_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -478,10 +484,12 @@ public void should_contain_newer_version_in_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.1.0"); - package.Version.to_string().ShouldEqual("1.1.1-beta2"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0"); + packageReader.NuspecReader.GetVersion().OriginalVersion.to_string().ShouldEqual("1.1.1-beta2"); + } } [Fact] @@ -629,10 +637,12 @@ public void should_contain_newer_version_in_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.1.0"); - package.Version.to_string().ShouldEqual("1.1.1-beta2"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0"); + packageReader.NuspecReader.GetVersion().OriginalVersion.to_string().ShouldEqual("1.1.1-beta2"); + } } [Fact] @@ -791,9 +801,11 @@ public void should_not_remove_the_package_from_the_lib_directory() [Fact] public void should_be_the_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.1.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0"); + } } [Fact] @@ -884,9 +896,11 @@ public void should_not_remove_the_package_from_the_lib_directory() [Fact] public void should_be_the_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.1.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0"); + } } [Fact] @@ -947,9 +961,11 @@ public void should_upgrade_a_package_in_the_lib_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -1082,9 +1098,11 @@ public void should_not_remove_the_package_from_the_lib_directory() [Fact] public void should_be_the_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1172,9 +1190,11 @@ public void should_not_remove_the_package_from_the_lib_directory() [Fact] public void should_be_the_same_version_of_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1261,9 +1281,11 @@ public void should_upgrade_a_package_in_the_lib_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -1370,9 +1392,11 @@ public void should_upgrade_a_package_in_the_lib_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -1490,9 +1514,11 @@ public void should_contain_old_version_in_directory() [Fact] public void should_not_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1574,9 +1600,11 @@ public void should_contain_newer_version_in_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -1652,9 +1680,11 @@ public void should_contain_newer_version_in_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -1979,9 +2009,11 @@ public void should_not_remove_package_from_the_lib_directory() [Fact] public void should_not_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -1995,9 +2027,11 @@ public void should_put_the_package_in_the_lib_bad_directory() [Fact] public void should_have_the_erroring_upgraded_package_in_the_lib_bad_directory() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib-bad", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib-bad", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0"); + } } [Fact] @@ -2075,9 +2109,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); } @@ -2091,24 +2125,30 @@ public override void Because() public void should_upgrade_the_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] public void should_upgrade_the_minimum_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] public void should_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0"); + } } [Fact] @@ -2157,9 +2197,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); } @@ -2173,24 +2213,30 @@ public override void Because() public void should_not_upgrade_the_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] public void should_not_upgrade_the_minimum_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] public void should_not_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2277,9 +2323,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "hasdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); Configuration.IgnoreDependencies = true; @@ -2294,24 +2340,30 @@ public override void Because() public void should_upgrade_the_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] public void should_not_upgrade_the_minimum_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] public void should_not_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2360,9 +2412,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "isdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); } @@ -2376,24 +2428,30 @@ public override void Because() public void should_upgrade_the_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] public void should_not_upgrade_the_parent_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] public void should_not_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2442,9 +2500,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "isdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Configuration.AllowMultipleVersions = true; Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); @@ -2474,8 +2532,10 @@ public override void Because() public void should_upgrade_the_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -2496,8 +2556,10 @@ public void should_replace_the_legacy_folder_version_of_the_package_with_a_lib_p public void should_not_upgrade_the_parent_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency.1.0.0", "hasdependency.1.0.0.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2518,8 +2580,10 @@ public void should_leave_the_parent_package_as_legacy_folder() public void should_not_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency.1.0.0", "isexactversiondependency.1.0.0.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0"); + } } [Fact] @@ -2582,9 +2646,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "isdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); } @@ -2598,24 +2662,30 @@ public override void Because() public void should_upgrade_the_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] - public void should_upgrade_the_parent_package_to_lowest_version_that_meets_new_dependency_version() + public void should_upgrade_the_parent_package_to_highest_version_that_meets_new_dependency_version() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.1.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] public void should_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.1.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0"); + } } [Fact] @@ -2664,9 +2734,9 @@ public override void Context() { base.Context(); Configuration.PackageNames = Configuration.Input = "isdependency"; - Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); - Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension); Configuration.AllowMultipleVersions = true; Scenario.install_package(Configuration, "isdependency", "1.0.0"); Scenario.install_package(Configuration, "hasdependency", "1.0.0"); @@ -2688,8 +2758,10 @@ public override void Because() public void should_upgrade_the_package() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.1.0.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] @@ -2707,11 +2779,13 @@ public void should_replace_the_legacy_folder_version_of_the_package_with_a_lib_p } [Fact] - public void should_upgrade_the_parent_package_to_lowest_version_that_meets_new_dependency_version() + public void should_upgrade_the_parent_package_to_highest_version_that_meets_new_dependency_version() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.1.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0"); + } } [Fact] @@ -2722,7 +2796,7 @@ public void should_replace_the_legacy_folder_version_of_the_parent_package_with_ } [Fact] - [Pending("Legacy packages are left when implicit - GH-117")] + //[Pending("Legacy packages are left when implicit - GH-117")] public void should_remove_the_legacy_folder_version_of_the_parent_package() { var packageDir = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency.1.0.0"); @@ -2733,8 +2807,10 @@ public void should_remove_the_legacy_folder_version_of_the_parent_package() public void should_upgrade_the_exact_version_dependency() { var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.0.1.0"); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0"); + } } [Fact] @@ -2745,7 +2821,7 @@ public void should_replace_the_legacy_folder_version_of_the_exact_version_packag } [Fact] - [Pending("Legacy packages are left when implicit - GH-117")] + //[Pending("Legacy packages are left when implicit - GH-117")] public void should_remove_the_legacy_folder_version_of_the_exact_version_package() { var packageDir = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency.1.0.0"); @@ -2817,9 +2893,11 @@ public override void Because() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -2915,9 +2993,11 @@ public override void Because() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] @@ -3086,9 +3166,11 @@ public void should_upgrade_packages_with_upgrades() [Fact] public void should_upgrade_upgradepackage() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.to_string().ShouldEqual("1.1.1-beta2"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().OriginalVersion.ShouldEqual("1.1.1-beta2"); + } } [Fact] @@ -3136,9 +3218,11 @@ public void should_upgrade_packages_with_upgrades() [Fact] public void should_not_upgrade_upgradepackage() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.to_string().ShouldEqual("1.1.1-beta"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().OriginalVersion.to_string().ShouldEqual("1.1.1-beta"); + } } [Fact] @@ -3186,10 +3270,10 @@ public class when_upgrading_an_existing_hook_package : ScenariosBase public override void Context() { base.Context(); - Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0"); Configuration.PackageNames = Configuration.Input = "scriptpackage.hook"; - Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".2.0.0" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".2.0.0" + NuGetConstants.PackageExtension); } public override void Because() @@ -3223,9 +3307,11 @@ public void should_delete_the_rollback() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("2.0.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0"); + } } [Fact] @@ -3323,7 +3409,7 @@ public class when_upgrading_an_existing_package_happy_path_with_hooks : Scenario public override void Context() { base.Context(); - Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + NuGetConstants.PackageExtension); Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0"); Configuration.PackageNames = Configuration.Input = "upgradepackage"; } @@ -3367,9 +3453,11 @@ public void should_contain_newer_version_in_directory() [Fact] public void should_upgrade_the_package() { - var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension); - var package = new OptimizedZipPackage(packageFile); - package.Version.Version.to_string().ShouldEqual("1.1.0.0"); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); + using (var packageReader = new PackageArchiveReader(packageFile)) + { + packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0"); + } } [Fact] diff --git a/src/chocolatey.tests/chocolatey.tests.csproj b/src/chocolatey.tests/chocolatey.tests.csproj index e92c90f5ee..bd52b6393e 100644 --- a/src/chocolatey.tests/chocolatey.tests.csproj +++ b/src/chocolatey.tests/chocolatey.tests.csproj @@ -71,12 +71,33 @@ ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll + + ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll ..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Chocolatey.NuGet.Common.3.0.0-alpha-20221121-42\lib\net472\NuGet.Common.dll + + + ..\packages\Chocolatey.NuGet.Configuration.3.0.0-alpha-20221121-42\lib\net472\NuGet.Configuration.dll + + + ..\packages\NuGet.Frameworks.3.0.0-alpha-20221121-42\lib\net472\NuGet.Frameworks.dll + + + ..\packages\Chocolatey.NuGet.Packaging.3.0.0-alpha-20221121-42\lib\net472\NuGet.Packaging.dll + + + ..\packages\Chocolatey.NuGet.Protocol.3.0.0-alpha-20221121-42\lib\net472\NuGet.Protocol.dll + + + ..\packages\Chocolatey.NuGet.Versioning.3.0.0-alpha-20221121-42\lib\net472\NuGet.Versioning.dll + ..\packages\NUnit.3.13.3\lib\net40\nunit.framework.dll @@ -89,6 +110,12 @@ + + + + + + diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs index f57e7a71b9..41c47cf571 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs @@ -28,6 +28,9 @@ namespace chocolatey.tests.infrastructure.app.commands using chocolatey.infrastructure.commandline; using chocolatey.infrastructure.results; using Moq; + using NuGet.Common; + using NuGet.Packaging; + using NuGet.Versioning; using Should; public class ChocolateyPinCommandSpecs @@ -40,27 +43,27 @@ public abstract class ChocolateyPinCommandSpecsBase : TinySpec protected Mock nugetLogger = new Mock(); protected Mock nugetService = new Mock(); protected ChocolateyConfiguration configuration = new ChocolateyConfiguration(); - protected Mock package = new Mock(); - protected Mock pinnedPackage = new Mock(); + protected Mock package = new Mock(); + protected Mock pinnedPackage = new Mock(); public override void Context() { - // MockLogger = new MockLogger(); - // Log.InitializeWith(MockLogger); + //MockLogger = new MockLogger(); + //Log.InitializeWith(MockLogger); configuration.Sources = "https://localhost/somewhere/out/there"; command = new ChocolateyPinCommand(packageInfoService.Object, nugetLogger.Object, nugetService.Object); - package = new Mock(); + package = new Mock(); package.Setup(p => p.Id).Returns("regular"); - package.Setup(p => p.Version).Returns(new SemanticVersion("1.2.0")); + package.Setup(p => p.Version).Returns(new NuGetVersion("1.2.0")); packageInfoService.Setup(s => s.get_package_information(package.Object)).Returns( new ChocolateyPackageInformation(package.Object) { IsPinned = false }); - pinnedPackage = new Mock(); + pinnedPackage = new Mock(); pinnedPackage.Setup(p => p.Id).Returns("pinned"); - pinnedPackage.Setup(p => p.Version).Returns(new SemanticVersion("1.1.0")); + pinnedPackage.Setup(p => p.Version).Returns(new NuGetVersion("1.1.0")); packageInfoService.Setup(s => s.get_package_information(pinnedPackage.Object)).Returns( new ChocolateyPackageInformation(pinnedPackage.Object) { @@ -329,7 +332,7 @@ public void should_log_a_message() [Fact] public void should_log_the_message_we_expect() { - var messages = MockLogger.MessagesFor(LogLevel.Info); + var messages = MockLogger.MessagesFor(tests.LogLevel.Info); messages.ShouldNotBeEmpty(); messages.Count.ShouldEqual(1); messages[0].ShouldContain("Pin would have called"); @@ -386,8 +389,6 @@ public void should_log_one_message() public class when_run_is_called : ChocolateyPinCommandSpecsBase { //private Action because; - private readonly Mock packageManager = new Mock(); - private readonly Mock localRepository = new Mock(); public override void Context() { @@ -431,13 +432,13 @@ public void should_set_pin_when_command_is_add() reset(); configuration.PinCommand.Name = "regular"; - packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object); - SemanticVersion semanticVersion = null; + //packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object); + NuGetVersion nugetVersion = null; //nuget woes - localRepository.Setup(r => r.FindPackage(configuration.PinCommand.Name, semanticVersion)).Returns(package.Object); + //localRepository.Setup(r => r.FindPackage(configuration.PinCommand.Name, nugetVersion)).Returns(package.Object); configuration.PinCommand.Command = PinCommandType.add; - command.set_pin(packageManager.Object, configuration); + //command.set_pin(packageManager.Object, configuration); packageInfoService.Verify(s => s.save_package_information(It.IsAny()), Times.Once); } @@ -448,13 +449,14 @@ public void should_remove_pin_when_command_is_remove() { reset(); configuration.PinCommand.Name = "pinned"; - packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object); + // packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object); configuration.PinCommand.Command = PinCommandType.remove; - command.set_pin(packageManager.Object, configuration); + //command.set_pin(packageManager.Object, configuration); packageInfoService.Verify(s => s.save_package_information(It.IsAny()), Times.Once); } } + } } diff --git a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs index d749d8ef39..2453b2c79c 100644 --- a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs @@ -17,10 +17,15 @@ namespace chocolatey.tests.infrastructure.app.nuget { using System; + using System.Collections.Generic; using System.Linq; using chocolatey.infrastructure.app.configuration; using chocolatey.infrastructure.app.nuget; using Moq; + using NuGet.Common; + using NuGet.Packaging; + using NuGet.Protocol; + using NuGet.Protocol.Core.Types; using Should; public class NugetCommonSpecs @@ -31,7 +36,7 @@ private class when_gets_remote_repository : TinySpec private readonly Mock nugetLogger = new Mock(); private readonly Mock packageDownloader = new Mock(); private ChocolateyConfiguration configuration; - private IPackageRepository packageRepository; + private IEnumerable packageRepositories; public override void Context() { @@ -42,7 +47,7 @@ public override void Context() public override void Because() { - because = () => packageRepository = NugetCommon.GetRemoteRepository(configuration, nugetLogger.Object, packageDownloader.Object); + because = () => packageRepositories = NugetCommon.GetRemoteRepositories(configuration, nugetLogger.Object); } [Fact] @@ -53,7 +58,7 @@ public void should_create_repository_when_source_is_null() because(); - ((AggregateRepository)packageRepository).Repositories.Count().ShouldEqual(0); + packageRepositories.Count().ShouldEqual(0); } } } diff --git a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs index 38aeb2d3db..5df8ad9ef3 100644 --- a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs @@ -31,6 +31,8 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; using Moq; + using NuGet.Packaging; + using NuGet.Versioning; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; public class AutomaticUninstallerServiceSpecs @@ -44,7 +46,7 @@ public abstract class AutomaticUninstallerServiceSpecsBase : TinySpec protected Mock registryService = new Mock(); protected Mock commandExecutor = new Mock(); protected ChocolateyConfiguration config = new ChocolateyConfiguration(); - protected Mock package = new Mock(); + protected Mock package = new Mock(); protected ConcurrentDictionary packageResults = new ConcurrentDictionary(); protected PackageResult packageResult; protected ChocolateyPackageInformation packageInformation; @@ -65,7 +67,7 @@ public override void Context() config.PromptForConfirmation = false; config.PackageNames = "regular"; package.Setup(p => p.Id).Returns("regular"); - package.Setup(p => p.Version).Returns(new SemanticVersion("1.2.0")); + package.Setup(p => p.Version).Returns(new NuGetVersion("1.2.0")); packageResult = new PackageResult(package.Object, "c:\\packages\\thispackage"); packageInformation = new ChocolateyPackageInformation(package.Object); registryKeys.Add( @@ -114,7 +116,7 @@ public void should_log_why_it_skips_auto_uninstaller() [Fact] public void should_not_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Never); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Never); } [Fact] @@ -298,7 +300,7 @@ public override void Because() [Fact] public void should_call_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); } [Fact] @@ -453,7 +455,7 @@ public override void Because() [Fact] public void should_call_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); } [Fact] @@ -501,7 +503,7 @@ public override void Because() [Fact] public void should_call_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); } [Fact] @@ -550,7 +552,7 @@ public override void Because() [Fact] public void should_call_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); } [Fact] @@ -600,7 +602,7 @@ public override void Because() [Fact] public void should_call_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); } [Fact] @@ -692,7 +694,7 @@ public override void Because() [Fact] public void should_call_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); } [Fact] @@ -747,7 +749,7 @@ public override void Because() [Fact] public void should_call_get_package_information() { - packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); } [Fact] diff --git a/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs index 3a5070d86b..b100fd7c35 100644 --- a/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs @@ -32,6 +32,8 @@ namespace chocolatey.tests.infrastructure.app.services { + using NuGet.Packaging; + public class ChocolateyPackageServiceSpecs { public abstract class ChocolateyPackageServiceSpecsBase : TinySpec @@ -83,13 +85,13 @@ public override void Context() NormalRunner.Setup(r => r.SourceType).Returns(SourceTypes.NORMAL); FeaturesRunner.Setup(r => r.SourceType).Returns(SourceTypes.WINDOWS_FEATURES); - var package = new Mock(); + var package = new Mock(); var expectedResult = new ConcurrentDictionary(); expectedResult.TryAdd("test-feature", new PackageResult(package.Object, "windowsfeatures", null)); - FeaturesRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>())) + FeaturesRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>())) .Returns(expectedResult); - NormalRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>())) + NormalRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>())) .Returns(new ConcurrentDictionary()); SourceRunners.AddRange(new[] { NormalRunner.Object, FeaturesRunner.Object }); @@ -124,20 +126,20 @@ public void should_return_package_that_should_have_been_installed() [Test] public void should_have_called_runner_for_windows_features_source() { - FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames == "test-feature"), It.IsAny>()), Times.Once); + FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames == "test-feature"), It.IsAny>()), Times.Once); } [Test] public void should_not_have_called_runner_for_windows_features_source_with_other_package_names() { - FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != "test-feature"), It.IsAny>()), Times.Never); + FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != "test-feature"), It.IsAny>()), Times.Never); } [Test] public void should_not_have_called_normal_source_runner_for_non_empty_packages() { // The normal source runners will be called with an argument - NormalRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != string.Empty), It.IsAny>()), Times.Never); + NormalRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != string.Empty), It.IsAny>()), Times.Never); } } } diff --git a/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs index b96acbb26f..0209e21140 100644 --- a/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs @@ -24,6 +24,8 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.app.domain; using chocolatey.infrastructure.app.services; using Moq; + using NuGet.Common; + using NuGet.Packaging; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; @@ -36,7 +38,7 @@ public abstract class NugetServiceSpecsBase : TinySpec protected Mock fileSystem = new Mock(); protected Mock nugetLogger = new Mock(); protected Mock filesService = new Mock(); - protected Mock package = new Mock(); + protected Mock package = new Mock(); protected Mock packageDownloader = new Mock(); public override void Context() @@ -47,7 +49,7 @@ public override void Context() filesService.ResetCalls(); package.ResetCalls(); - service = new NugetService(fileSystem.Object, nugetLogger.Object, packageInfoService.Object, filesService.Object, packageDownloader.Object); + service = new NugetService(fileSystem.Object, nugetLogger.Object, packageInfoService.Object, filesService.Object); } } @@ -305,7 +307,7 @@ public void generated_package_should_be_in_current_directory() because(); - var infos = MockLogger.MessagesFor(LogLevel.Info); + var infos = MockLogger.MessagesFor(tests.LogLevel.Info); infos.Count.ShouldEqual(1); infos[0].ShouldEqual("Chocolatey would have searched for a nuspec file in \"c:\\projects\\chocolatey\" and attempted to compile it."); } @@ -319,7 +321,7 @@ public void generated_package_should_be_in_specified_directory() because(); - var infos = MockLogger.MessagesFor(LogLevel.Info); + var infos = MockLogger.MessagesFor(tests.LogLevel.Info); infos.Count.ShouldEqual(1); infos[0].ShouldEqual("Chocolatey would have searched for a nuspec file in \"c:\\packages\" and attempted to compile it."); } diff --git a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs index 82db549daa..3cdf1d4bab 100644 --- a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs @@ -28,8 +28,10 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.filesystem; using chocolatey.infrastructure.services; using Moq; + using NuGet.Common; using NUnit.Framework; using Should; + using LogLevel = tests.LogLevel; public class TemplateServiceSpecs { @@ -38,13 +40,13 @@ public abstract class TemplateServiceSpecsBase : TinySpec protected TemplateService service; protected Mock fileSystem = new Mock(); protected Mock xmlService = new Mock(); + protected Mock logger = new Mock(); public override void Context() { fileSystem.ResetCalls(); xmlService.ResetCalls(); - - service = new TemplateService(fileSystem.Object, xmlService.Object); + service = new TemplateService(fileSystem.Object, xmlService.Object, logger.Object); } } diff --git a/src/chocolatey.tests/packages.config b/src/chocolatey.tests/packages.config index 0f56db505e..f71ec363b2 100644 --- a/src/chocolatey.tests/packages.config +++ b/src/chocolatey.tests/packages.config @@ -1,8 +1,15 @@  + + + + + - + + + diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index 9167794d71..c1c8a8470d 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -89,9 +89,51 @@ ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - False - ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll + + + ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Chocolatey.NuGet.Commands.3.0.0-alpha-20221121-42\lib\net472\NuGet.Commands.dll + + + ..\packages\Chocolatey.NuGet.Common.3.0.0-alpha-20221121-42\lib\net472\NuGet.Common.dll + + + ..\packages\Chocolatey.NuGet.Configuration.3.0.0-alpha-20221121-42\lib\net472\NuGet.Configuration.dll + + + ..\packages\Chocolatey.Nuget.Credentials.3.0.0-alpha-20221121-42\lib\net472\NuGet.Credentials.dll + + + ..\packages\Chocolatey.NuGet.DependencyResolver.Core.3.0.0-alpha-20221121-42\lib\net472\NuGet.DependencyResolver.Core.dll + + + ..\packages\NuGet.Frameworks.3.0.0-alpha-20221121-42\lib\net472\NuGet.Frameworks.dll + + + ..\packages\Chocolatey.NuGet.LibraryModel.3.0.0-alpha-20221121-42\lib\net472\NuGet.LibraryModel.dll + + + ..\packages\Chocolatey.NuGet.PackageManagement.3.0.0-alpha-20221121-42\lib\net472\NuGet.PackageManagement.dll + + + ..\packages\Chocolatey.NuGet.Packaging.3.0.0-alpha-20221121-42\lib\net472\NuGet.Packaging.dll + + + ..\packages\Chocolatey.NuGet.ProjectModel.3.0.0-alpha-20221121-42\lib\net472\NuGet.ProjectModel.dll + + + ..\packages\Chocolatey.NuGet.Protocol.3.0.0-alpha-20221121-42\lib\net472\NuGet.Protocol.dll + + + ..\packages\Chocolatey.NuGet.Resolver.3.0.0-alpha-20221121-42\lib\net472\NuGet.Resolver.dll + + + ..\packages\Chocolatey.NuGet.Versioning.3.0.0-alpha-20221121-42\lib\net472\NuGet.Versioning.dll ..\..\lib\Rhino.Licensing.1.4.1\lib\net40\Rhino.Licensing.dll @@ -100,13 +142,20 @@ ..\packages\SimpleInjector.2.8.3\lib\net45\SimpleInjector.dll + + + + + False ..\..\lib\PowerShell\System.Management.Automation.dll + + ..\packages\Rx-Core.2.1.30214.0\lib\Net40\System.Reactive.Core.dll @@ -117,6 +166,7 @@ ..\packages\Rx-Linq.2.1.30214.0\lib\Net40\System.Reactive.Linq.dll + @@ -134,6 +184,7 @@ + @@ -146,6 +197,9 @@ + + + @@ -218,7 +272,6 @@ - @@ -414,6 +467,7 @@ +