本文整理汇总了C#中NuGet.VisualStudio.VsPackageManager.InstallPackage方法的典型用法代码示例。如果您正苦于以下问题:C# VsPackageManager.InstallPackage方法的具体用法?C# VsPackageManager.InstallPackage怎么用?C# VsPackageManager.InstallPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NuGet.VisualStudio.VsPackageManager
的用法示例。
在下文中一共展示了VsPackageManager.InstallPackage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallPackageWithOperationsExecuteAllOperations
public void InstallPackageWithOperationsExecuteAllOperations()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, projectSystem, localRepository, new Mock<IRecentPackageRepository>().Object);
var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" }, dependencies: new PackageDependency[] { new PackageDependency("bar") });
sourceRepository.AddPackage(package);
var package2 = PackageUtility.CreatePackage("bar", "2.0", new[] { "world" });
sourceRepository.AddPackage(package2);
var package3 = PackageUtility.CreatePackage("awesome", "1.0", new[] { "candy" });
localRepository.AddPackage(package3);
var operations = new PackageOperation[] {
new PackageOperation(package, PackageAction.Install),
new PackageOperation(package2, PackageAction.Install),
new PackageOperation(package3, PackageAction.Uninstall)
};
// Act
packageManager.InstallPackage(projectManager, package, operations, ignoreDependencies: false, logger: NullLogger.Instance);
// Assert
Assert.IsTrue(packageManager.LocalRepository.Exists(package));
Assert.IsTrue(packageManager.LocalRepository.Exists(package2));
Assert.IsTrue(!packageManager.LocalRepository.Exists(package3));
Assert.IsTrue(projectManager.LocalRepository.Exists(package));
Assert.IsTrue(projectManager.LocalRepository.Exists(package2));
}
示例2: InstallPackageInstallsIntoProjectAndPackageManager
public void InstallPackageInstallsIntoProjectAndPackageManager()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, projectSystem, localRepository, new Mock<IRecentPackageRepository>().Object);
var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });
sourceRepository.AddPackage(package);
// Act
packageManager.InstallPackage(projectManager, "foo", new Version("1.0"), ignoreDependencies: false, logger: NullLogger.Instance);
// Assert
Assert.IsTrue(packageManager.LocalRepository.Exists(package));
Assert.IsTrue(projectManager.LocalRepository.Exists(package));
}
示例3: InstallPackageInstallsIndirectPrereleaseDependency
public void InstallPackageInstallsIndirectPrereleaseDependency()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, projectSystem, localRepository, new Mock<IRecentPackageRepository>().Object, new Mock<VsPackageInstallerEvents>().Object);
var package = PackageUtility.CreatePackage("foo", "1.0.0", dependencies: new[] { new PackageDependency("bar") });
sourceRepository.AddPackage(package);
var versionSpec = VersionUtility.ParseVersionSpec("[0.6, 1.0)");
var package2 = PackageUtility.CreatePackage("bar", "2.0.0", dependencies: new[] { new PackageDependency("qux", versionSpec) });
sourceRepository.AddPackage(package2);
var package3A = PackageUtility.CreatePackage("qux", "1.0-alpha");
var package3B = PackageUtility.CreatePackage("qux", "1.0-beta");
var package3 = PackageUtility.CreatePackage("qux", "1.0");
localRepository.AddPackage(package3);
localRepository.AddPackage(package3A);
localRepository.AddPackage(package3B);
// Act
packageManager.InstallPackage(package, ignoreDependencies: false, allowPrereleaseVersions: true);
// Assert
Assert.True(packageManager.LocalRepository.Exists(package));
Assert.True(packageManager.LocalRepository.Exists(package2));
Assert.True(packageManager.LocalRepository.Exists(package3B));
}
示例4: UpdatePackageUpdatesToTheHighestPackageIfPrereleaseFlagIsSetToTrue
public void UpdatePackageUpdatesToTheHighestPackageIfPrereleaseFlagIsSetToTrue()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, projectSystem, localRepository, new Mock<IRecentPackageRepository>().Object, new Mock<VsPackageInstallerEvents>().Object);
var package3_10A = PackageUtility.CreatePackage("qux", "1.0-alpha");
var package3_11B = PackageUtility.CreatePackage("qux", "1.1-alpha");
var package3_10 = PackageUtility.CreatePackage("qux", "1.0");
var package3_09 = PackageUtility.CreatePackage("qux", "0.9");
localRepository.AddPackage(package3_10);
localRepository.AddPackage(package3_10A);
localRepository.AddPackage(package3_11B);
localRepository.AddPackage(package3_09);
// Act
packageManager.InstallPackage(package3_09, ignoreDependencies: false, allowPrereleaseVersions: true);
Assert.True(packageManager.LocalRepository.Exists(package3_09));
packageManager.UpdatePackage("qux", updateDependencies: true, allowPrereleaseVersions: true);
// Assert
Assert.True(packageManager.LocalRepository.Exists(package3_11B));
}
示例5: InstallPackageDoesNotInstallPackageWithIndirectDependencyThatIsPrerelease
public void InstallPackageDoesNotInstallPackageWithIndirectDependencyThatIsPrerelease()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, projectSystem, localRepository, new Mock<IRecentPackageRepository>().Object, new Mock<VsPackageInstallerEvents>().Object);
var package = PackageUtility.CreatePackage("foo", "1.0.0", dependencies: new[] { new PackageDependency("bar") });
sourceRepository.AddPackage(package);
var versionSpec = VersionUtility.ParseVersionSpec("[0.6, 1.0)");
var package2 = PackageUtility.CreatePackage("bar", "2.0.0", dependencies: new[] { new PackageDependency("qux", versionSpec) });
sourceRepository.AddPackage(package2);
var package3A = PackageUtility.CreatePackage("qux", "1.0-alpha");
var package3B = PackageUtility.CreatePackage("qux", "1.0-beta");
var package3 = PackageUtility.CreatePackage("qux", "1.0");
sourceRepository.AddPackage(package3);
sourceRepository.AddPackage(package3A);
sourceRepository.AddPackage(package3B);
// Act and Assert
ExceptionAssert.Throws<InvalidOperationException>(() => packageManager.InstallPackage(package, ignoreDependencies: false, allowPrereleaseVersions: false),
"Unable to resolve dependency 'qux (≥ 0.6 && < 1.0)'.");
}