本文整理汇总了C#中NuGet.VisualStudio.VsPackageManager.UpdatePackage方法的典型用法代码示例。如果您正苦于以下问题:C# VsPackageManager.UpdatePackage方法的具体用法?C# VsPackageManager.UpdatePackage怎么用?C# VsPackageManager.UpdatePackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NuGet.VisualStudio.VsPackageManager
的用法示例。
在下文中一共展示了VsPackageManager.UpdatePackage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdatePackageWithSharedDependency
public void UpdatePackageWithSharedDependency()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var projectRepository = new MockProjectPackageRepository(localRepository.Object);
var sourceRepository = new MockPackageRepository();
var fileSystem = new MockFileSystem();
var pathResolver = new DefaultPackagePathResolver(fileSystem);
// A1 -> B1
// A2 -> B2
// F1 -> G1
// G1 -> B1
var A10 = PackageUtility.CreatePackage("A", "1.0", new[] { "hello" }, dependencies: new[] { new PackageDependency("B", VersionUtility.ParseVersionSpec("1.0")) });
var A20 = PackageUtility.CreatePackage("A", "2.0", new[] { "hello" }, dependencies: new[] { new PackageDependency("B", VersionUtility.ParseVersionSpec("2.0")) });
var B10 = PackageUtility.CreatePackage("B", "1.0", new[] { "hello" });
var B20 = PackageUtility.CreatePackage("B", "2.0", new[] { "hello" });
var F10 = PackageUtility.CreatePackage("F", "1.0", new[] { "hello" }, dependencies: new[] { new PackageDependency("G", VersionUtility.ParseVersionSpec("1.0")) });
var G10 = PackageUtility.CreatePackage("G", "1.0", new[] { "hello" }, dependencies: new[] { new PackageDependency("B", VersionUtility.ParseVersionSpec("1.0")) });
sourceRepository.AddPackage(A10);
sourceRepository.AddPackage(A20);
sourceRepository.AddPackage(B10);
sourceRepository.AddPackage(B20);
sourceRepository.AddPackage(F10);
sourceRepository.AddPackage(G10);
localRepository.Object.AddPackage(A10);
localRepository.Object.AddPackage(A20);
localRepository.Object.AddPackage(B10);
localRepository.Object.AddPackage(B20);
localRepository.Object.AddPackage(F10);
localRepository.Object.AddPackage(G10);
projectRepository.Add(A10);
projectRepository.Add(B10);
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, fileSystem, localRepository.Object, new Mock<IRecentPackageRepository>().Object);
var projectManager = new ProjectManager(localRepository.Object, pathResolver, new MockProjectSystem(), projectRepository);
// Act
packageManager.UpdatePackage(projectManager, "A", version: null, updateDependencies: true, logger: NullLogger.Instance);
// Assert
Assert.IsFalse(packageManager.LocalRepository.Exists(A10));
Assert.IsFalse(packageManager.LocalRepository.Exists(B10));
Assert.IsTrue(packageManager.LocalRepository.Exists(A20));
Assert.IsTrue(packageManager.LocalRepository.Exists(B20));
Assert.IsTrue(packageManager.LocalRepository.Exists(F10));
Assert.IsTrue(packageManager.LocalRepository.Exists(G10));
}
示例2: UpdatePackageWithMultipleSharedDependencies
public void UpdatePackageWithMultipleSharedDependencies()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var projectRepository = new MockProjectPackageRepository(localRepository.Object);
var sourceRepository = new MockPackageRepository();
var fileSystem = new MockFileSystem();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(fileSystem);
// A1 -> B1, C1
// A2 -> B1
var A10 = PackageUtility.CreatePackage("A", "1.0", assemblyReferences: new[] { "A1.dll" }, dependencies: new[] {
new PackageDependency("B", VersionUtility.ParseVersionSpec("1.0")),
new PackageDependency("C", VersionUtility.ParseVersionSpec("1.0")),
});
var A20 = PackageUtility.CreatePackage("A", "2.0", assemblyReferences: new[] { "A2.dll" }, dependencies: new[] {
new PackageDependency("B", VersionUtility.ParseVersionSpec("1.0"))
});
var B10 = PackageUtility.CreatePackage("B", "1.0", assemblyReferences: new[] { "B1.dll" });
var C10 = PackageUtility.CreatePackage("C", "1.0", assemblyReferences: new[] { "C1.dll" });
sourceRepository.AddPackage(A10);
sourceRepository.AddPackage(A20);
sourceRepository.AddPackage(B10);
sourceRepository.AddPackage(C10);
localRepository.Object.AddPackage(A10);
localRepository.Object.AddPackage(A20);
localRepository.Object.AddPackage(B10);
localRepository.Object.AddPackage(C10);
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, fileSystem, localRepository.Object, new Mock<IRecentPackageRepository>().Object);
var projectManager = new ProjectManager(localRepository.Object, pathResolver, projectSystem, projectRepository);
projectManager.AddPackageReference("A", new Version("1.0"));
// Act
packageManager.UpdatePackage(projectManager, "A", version: null, updateDependencies: true, logger: NullLogger.Instance);
// Assert
Assert.IsFalse(packageManager.LocalRepository.Exists(A10));
Assert.IsFalse(projectSystem.ReferenceExists("A1.dll"));
Assert.IsFalse(packageManager.LocalRepository.Exists(C10));
Assert.IsFalse(projectSystem.ReferenceExists("C1.dll"));
Assert.IsTrue(packageManager.LocalRepository.Exists(B10));
Assert.IsTrue(projectSystem.ReferenceExists("B1.dll"));
Assert.IsTrue(packageManager.LocalRepository.Exists(A20));
Assert.IsTrue(projectSystem.ReferenceExists("A2.dll"));
}
示例3: 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));
}
示例4: UpdatePackageRemovesPackageIfPackageIsNotReferenced
public void UpdatePackageRemovesPackageIfPackageIsNotReferenced()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
localRepository.Setup(m => m.IsReferenced("A", new Version("1.0"))).Returns(false);
var projectRepository = new MockProjectPackageRepository(localRepository.Object);
var sourceRepository = new MockPackageRepository();
var fileSystem = new MockFileSystem();
var pathResolver = new DefaultPackagePathResolver(fileSystem);
var A10 = PackageUtility.CreatePackage("A", "1.0", new[] { "hello" });
var A20 = PackageUtility.CreatePackage("A", "2.0", new[] { "hello" });
sourceRepository.AddPackage(A10);
sourceRepository.AddPackage(A20);
localRepository.Object.AddPackage(A10);
localRepository.Object.AddPackage(A20);
projectRepository.Add(A10);
var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, fileSystem, localRepository.Object, new Mock<IRecentPackageRepository>().Object);
var projectManager = new ProjectManager(localRepository.Object, pathResolver, new MockProjectSystem(), projectRepository);
// Act
packageManager.UpdatePackage(projectManager, "A", version: null, updateDependencies: true, logger: NullLogger.Instance);
// Assert
Assert.IsFalse(packageManager.LocalRepository.Exists(A10));
}
示例5: UpdatePackageWithNoProjectsInstallsAtSolutionLevel
public void UpdatePackageWithNoProjectsInstallsAtSolutionLevel()
{
// 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", dependencies: new PackageDependency[] { new PackageDependency("bar") });
sourceRepository.AddPackage(package);
var package2 = PackageUtility.CreatePackage("bar", "2.0");
sourceRepository.AddPackage(package2);
var package3 = PackageUtility.CreatePackage("awesome", "1.0");
localRepository.AddPackage(package3);
var operations = new PackageOperation[] {
new PackageOperation(package, PackageAction.Install),
new PackageOperation(package2, PackageAction.Install),
new PackageOperation(package3, PackageAction.Uninstall)
};
// Act
packageManager.UpdatePackage(Enumerable.Empty<Project>(),
package,
operations,
updateDependencies: true,
allowPrereleaseVersions: false,
logger: NullLogger.Instance,
packageOperationEventListener: null);
// Assert
Assert.True(packageManager.LocalRepository.Exists(package));
Assert.True(packageManager.LocalRepository.Exists(package2));
Assert.True(!packageManager.LocalRepository.Exists(package3));
}