public void TestNearestFrameworkAny(string version, string targetFramework) { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage("TestFrameworkAny", version, targetFramework, GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, true, null).ToList(); NugetHelper.CheckPackagesConsistency(packages, true); }
public void CompileTimeReferencesInstallOnDependency(string id, string version, string framework) { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage(id, version, framework, "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, true, null).ToList(); NugetHelper.CheckPackagesConsistency(packages); }
public void ConsistencyCheck() { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage("Package A", "1.0.0", "net5", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("Package A", "2.0.0", "net5", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); Assert.Throws <Exceptions.MultiplePackagesFoundException>(() => NugetHelper.CheckPackagesConsistency(packages)); packages.Clear(); packages.Add(new NugetPackage("TestLib1", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("TestLib2", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, false, null).ToList(); //Should assert due to the missing dependency package Assert.Throws <Exceptions.DependencyNotFoundException>(() => NugetHelper.CheckPackagesConsistency(packages)); packages.Clear(); packages.Add(new NugetPackage("TestLib1", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("TestLib2", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("CoreLib", "0.0.1", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("CoreLib", "0.0.2", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, false, null).ToList(); //Should assert due to the different versions of the CoreLib checked as dependencies in the TestLib1 package Assert.Throws <Exceptions.MultipleDependenciesFoundException>(() => NugetHelper.CheckPackagesConsistency(packages)); packages.Clear(); packages.Add(new NugetPackage("TestLib1", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("TestLib2", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, true, null).ToList(); //Should assert due to the different versions of the CoreLib package Assert.Throws <Exceptions.MultipleDependenciesFoundException>(() => NugetHelper.CheckPackagesConsistency(packages)); packages.Clear(); packages.Add(new NugetPackage("TestLib2", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("CoreLib", "0.0.1", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, false, null).ToList(); //Should assert due to the unsupprted version of the CoreLib package Assert.Throws <Exceptions.InvalidDependencyFoundException>(() => NugetHelper.CheckPackagesConsistency(packages)); packages.Clear(); packages.Add(new NugetPackage("TestLib2", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("CoreLib", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, false, null).ToList(); //Although the Lib2 is build against the CoreLib;0.0.2 this test should pass. //This because Lib2 was built with version dependency CoreLib>=0.0.2 NugetHelper.CheckPackagesConsistency(packages); //With the flag set to true, this thest should now fail, because the exact min version 0.0.2 is missing Assert.Throws <Exceptions.InvalidMinVersionDependencyFoundExceptio>(() => NugetHelper.CheckPackagesConsistency(packages, true)); packages.Clear(); packages.Add(new NugetPackage("TestLib2", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath(), false)); packages.Add(new NugetPackage("CoreLib", "1.0.0", "netstandard2.0", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, false, null).ToList(); //Although the Lib2 is build against the CoreLib;0.0.2 this test should pass. //This because hte packge TestLib2 is instantiated with the parameter dependencyForceMinVersion set to false. NugetHelper.CheckPackagesConsistency(packages, true); }
public void CompileTimeReferencesInstallOnPackage() { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage("Microsoft.CSharp", "4.0.1", "netstandard1.0", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetCompileTimeAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, true, null).ToList(); NugetHelper.CheckPackagesConsistency(packages); packages.Clear(); }
public void VersionConsistencyCheckOnPackageOnDependency() { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage("TestVersionConflict", "1.0.0", "net45", GetLocalTestRepository(), null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("System.Management.Automation.dll", "10.0.10586.0", "net40", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, true, null).ToList(); NugetHelper.CheckPackagesConsistency(packages, true); }
public void VersionConsistencyCheckOnPackageOnPackage() { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage("CommonServiceLocator", "1.3", "portable-net4+sl5+netcore45+wpa81+wp8", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages.Add(new NugetPackage("Unity", "4.0.1", "net45", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, true, null).ToList(); NugetHelper.CheckPackagesConsistency(packages, true); }
public void InstallPackageRecursively(string id, string version, string target, string source) { var p = new NugetPackage(id, version, target, source, null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath()); var installed = NugetHelper.InstallPackages(new[] { p }, true, null).ToList(); Assert.AreEqual(4, installed.Count(), "Invalid number of installed packages"); NugetHelper.CheckPackagesConsistency(installed); }
public void CompileTimeReferencesCheck() { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage("Newtonsoft.Json", "9.0.1", "netstandard1.0", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, false, null).ToList(); //Should fail because at least the dependency to Microsoft.CSharp is missing. Assert.Throws <Exceptions.DependencyNotFoundException>(() => NugetHelper.CheckPackagesConsistency(packages)); //Should not fail because the dependency check is inhibited. NugetHelper.CheckPackagesConsistency(packages, false, true); }
public void EnsureImplementationAssembliesWhenAvailableOnDependency() { var packages = new List <NugetPackage>(); packages.Add(new NugetPackage("System.Resources.Extensions", "5.0.0", "net461", "https://api.nuget.org/v3/index.json", null, NugetPackageType.DotNetImplementationAssembly, GetNugetCachePath())); packages = NugetHelper.InstallPackages(packages, true, null).ToList(); Assert.IsTrue(packages.Any(x => x.Id == "System.Memory")); Assert.IsTrue(packages.Any(x => x.Id == "System.Buffers")); Assert.IsTrue(packages.Any(x => x.Id == "System.Numerics.Vectors")); Assert.IsTrue(packages.Any(x => x.Id == "System.Runtime.CompilerServices.Unsafe")); Assert.IsTrue(packages.Where(x => x.Id == "System.Numerics.Vectors").First().PackageType == NugetPackageType.DotNetImplementationAssembly); Assert.IsTrue(packages.Where(x => x.Id == "System.Runtime.CompilerServices.Unsafe").First().PackageType == NugetPackageType.DotNetImplementationAssembly); NugetHelper.CheckPackagesConsistency(packages); }