public Task <int> ExecuteCommand(PackageReferenceArgs packageReferenceArgs, MSBuildAPIUtility msBuild)
        {
            packageReferenceArgs.Logger.LogInformation(string.Format(CultureInfo.CurrentCulture,
                                                                     Strings.Info_RemovePkgRemovingReference,
                                                                     packageReferenceArgs.PackageDependency.Id,
                                                                     packageReferenceArgs.ProjectPath));

            // Remove reference from the project
            var result = msBuild.RemovePackageReference(packageReferenceArgs.ProjectPath,
                                                        packageReferenceArgs.PackageDependency);

            return(Task.FromResult(result));
        }
Exemplo n.º 2
0
        public Task <int> ExecuteCommand(PackageReferenceArgs packageReferenceArgs, MSBuildAPIUtility msBuild)
        {
            packageReferenceArgs.Logger.LogInformation(string.Format(CultureInfo.CurrentCulture,
                                                                     Strings.Info_RemovePkgRemovingReference,
                                                                     packageReferenceArgs.PackageDependency.Id,
                                                                     packageReferenceArgs.ProjectPath));

            var libraryDependency = new LibraryDependency
            {
                LibraryRange = new LibraryRange(
                    name: packageReferenceArgs.PackageDependency.Id,
                    versionRange: packageReferenceArgs.PackageDependency.VersionRange,
                    typeConstraint: LibraryDependencyTarget.Package)
            };

            // Remove reference from the project
            var result = msBuild.RemovePackageReference(packageReferenceArgs.ProjectPath, libraryDependency);

            return(Task.FromResult(result));
        }
        public Task <int> ExecuteCommand(PackageReferenceArgs packageReferenceArgs, MSBuildAPIUtility msBuild)
        {
            packageReferenceArgs.Logger.LogInformation(string.Format(CultureInfo.CurrentCulture,
                                                                     Strings.Info_RemovePkgRemovingReference,
                                                                     packageReferenceArgs.PackageId,
                                                                     packageReferenceArgs.ProjectPath));

            //Setup the Credential Service - This allows the msbuild sdk resolver to auth if needed.
            DefaultCredentialServiceUtility.SetupDefaultCredentialService(packageReferenceArgs.Logger, !packageReferenceArgs.Interactive);

            var libraryDependency = new LibraryDependency
            {
                LibraryRange = new LibraryRange(
                    name: packageReferenceArgs.PackageId,
                    versionRange: VersionRange.All,
                    typeConstraint: LibraryDependencyTarget.Package)
            };

            // Remove reference from the project
            var result = msBuild.RemovePackageReference(packageReferenceArgs.ProjectPath, libraryDependency);

            return(Task.FromResult(result));
        }