コード例 #1
0
        IPackageAction CreateUninstallPackageAction(PackageReferenceNode packageReferenceNode)
        {
            var solutionManager = PackageManagementServices.Workspace.GetSolutionManager(packageReferenceNode.Project.ParentSolution);

            if (packageReferenceNode.NeedsRestoreBeforeUninstall())
            {
                return(new RestoreAndUninstallNuGetPackageAction(solutionManager, packageReferenceNode.Project)
                {
                    PackageId = packageReferenceNode.Id,
                    Version = packageReferenceNode.Version
                });
            }

            return(new UninstallNuGetPackageAction(solutionManager, packageReferenceNode.Project)
            {
                PackageId = packageReferenceNode.Id
            });
        }