public override void RemovePackage(IPackage package) { string manifestFilePath = GetManifestFilePath(package.Id, package.Version); if (FileSystem.FileExists(manifestFilePath)) { // delete .nuspec file FileSystem.DeleteFileSafe(manifestFilePath); } // Delete the package file string packageFilePath = GetPackageFilePath(package); FileSystem.DeleteFileSafe(packageFilePath); // Delete the package directory if any FileSystem.DeleteDirectorySafe(PathResolver.GetPackageDirectory(package), recursive: false); // If this is the last package delete the package directory if (!FileSystem.GetFilesSafe(String.Empty).Any() && !FileSystem.GetDirectoriesSafe(String.Empty).Any()) { FileSystem.DeleteDirectorySafe(String.Empty, recursive: false); } }
private string GetManifestFilePath(string packageId, SemanticVersion version) { string packageDirectory = PathResolver.GetPackageDirectory(packageId, version); string manifestFileName = packageDirectory + Constants.ManifestExtension; return(Path.Combine(packageDirectory, manifestFileName)); }
protected virtual void ExecuteUninstall(IPackage package) { string packageDirectory = PathResolver.GetPackageDirectory(package); PackageOperationEventArgs args = CreateOperation(package); OnUninstalling(args); if (args.Cancel) { return; } OnRemoveFiles(args); // Only remove nupkg and nuspec if the package directory is otherwise empty. // The DeleteOnRestartManager will use the nupkg to determine whether files are left in the package directory // directory because files were added or modified as opposed to locked. if (!FileSystem.GetDirectoriesSafe(packageDirectory).Any() && FileSystem.GetFilesSafe(packageDirectory).All(f => PackageUtility.IsPackageFile(f) || PackageUtility.IsManifest(f))) { LocalRepository.RemovePackage(package); } Logger.Log(MessageLevel.Info, NuGetResources.Log_SuccessfullyUninstalledPackage, package.GetFullName()); OnUninstalled(args); }
private void ExpandFiles(IPackage package) { var batchProcessor = FileSystem as IBatchProcessor <string>; try { var files = package.GetFiles().ToList(); if (batchProcessor != null) { // Notify the batch processor that the files are being added. This is to allow source controlled file systems // to manage previously uninstalled files. batchProcessor.BeginProcessing(files.Select(p => p.Path), PackageAction.Install); } string packageDirectory = PathResolver.GetPackageDirectory(package); // Add files FileSystem.AddFiles(files, packageDirectory); ExpandSatellitePackageFiles(package); } finally { if (batchProcessor != null) { batchProcessor.EndProcessing(); } } }
private void RemoveFiles(IPackage package) { string packageDirectory = PathResolver.GetPackageDirectory(package); // Remove resource files FileSystem.DeleteFiles(package.GetFiles(), packageDirectory); }
private void ExpandFiles(IPackage package) { string packageDirectory = PathResolver.GetPackageDirectory(package); // Add files files FileSystem.AddFiles(package.GetFiles(), packageDirectory); }
protected void ExpandSatellitePackageFiles(IPackage package) { // If this is a Satellite Package, then copy the satellite files into the related runtime package folder too IPackage runtimePackage; if (PackageHelper.IsSatellitePackage(package, LocalRepository, targetFramework: null, runtimePackage: out runtimePackage)) { var satelliteFiles = package.GetSatelliteFiles(); var runtimePath = PathResolver.GetPackageDirectory(runtimePackage); FileSystem.AddFiles(satelliteFiles, runtimePath); } }
public override IPackage FindPackage(string packageId, SemanticVersion version) { if (version != null) { string packagePath = GetManifestFilePath(packageId, version); if (FileSystem.FileExists(packagePath)) { string packageDirectory = PathResolver.GetPackageDirectory(packageId, version); return(new UnzippedPackage(FileSystem, packageDirectory)); } } // if we didn't find the .nuspec file, search for .nupkg file return(base.FindPackage(packageId, version)); }
public override void RemovePackage(IPackage package) { // Delete the package file string packageFilePath = GetPackageFilePath(package); FileSystem.DeleteFileSafe(packageFilePath); // Delete the package directory if any FileSystem.DeleteDirectorySafe(PathResolver.GetPackageDirectory(package), recursive: false); // If this is the last package delete the package directory if (!FileSystem.GetFilesSafe(String.Empty).Any() && !FileSystem.GetDirectoriesSafe(String.Empty).Any()) { FileSystem.DeleteDirectorySafe(String.Empty, recursive: false); } }
private void RemoveFiles(IPackage package) { string packageDirectory = PathResolver.GetPackageDirectory(package); // Remove resource files FileSystem.DeleteFiles(package.GetFiles(), packageDirectory); // If this is a Satellite Package, then remove the files from the related runtime package folder too IPackage runtimePackage; if (PackageUtility.IsSatellitePackage(package, LocalRepository, targetFramework: null, runtimePackage: out runtimePackage)) { var satelliteFiles = package.GetSatelliteFiles(); var runtimePath = PathResolver.GetPackageDirectory(runtimePackage); FileSystem.DeleteFiles(satelliteFiles, runtimePath); } }
private void RemoveFiles(IPackage package) { string packageDirectory = PathResolver.GetPackageDirectory(package); // If this is a Satellite Package, then remove the files from the related runtime package folder too IPackage runtimePackage; if (PackageHelper.IsSatellitePackage(package, LocalRepository, targetFramework: null, runtimePackage: out runtimePackage)) { var satelliteFiles = package.GetSatelliteFiles(); var runtimePath = PathResolver.GetPackageDirectory(runtimePackage); FileSystem.DeleteFiles(satelliteFiles, runtimePath); } // Remove package files // IMPORTANT: This has to be done AFTER removing satellite files from runtime package, // because starting from 2.1, we read satellite files directly from package files, instead of .nupkg FileSystem.DeleteFiles(package.GetFiles(), packageDirectory); }
public override void RemovePackage(IPackage package) { // IMPORTANT (bug #3114) Even though we delete the entire package's directory, // we still need to explicitly delete the .nuspec and .nupkg files in order to // undo pending TFS add operations, if any. string manifestFilePath = GetManifestFilePath(package.Id, package.Version); if (FileSystem.FileExists(manifestFilePath)) { // delete .nuspec file FileSystem.DeleteFileSafe(manifestFilePath); } string packageFilePath = GetPackageFilePath(package); if (FileSystem.FileExists(packageFilePath)) { // Delete the .nupkg file FileSystem.DeleteFileSafe(packageFilePath); } // Now delete the entire package's directory, just in case some files are left behind FileSystem.DeleteDirectorySafe(PathResolver.GetPackageDirectory(package), recursive: true); // If this is the last package delete the 'packages' directory if (!FileSystem.GetFilesSafe(String.Empty).Any() && !FileSystem.GetDirectoriesSafe(String.Empty).Any()) { FileSystem.DeleteDirectorySafe(String.Empty, recursive: false); } if (_packageReferenceFile != null) { _packageReferenceFile.DeleteEntry(package.Id, package.Version); } }
private void ExpandFiles(IPackage package) { var batchProcessor = FileSystem as IBatchProcessor <string>; try { var files = package.GetFiles().ToList(); if (batchProcessor != null) { // Notify the batch processor that the files are being added. This is to allow source controlled file systems // to manage previously uninstalled files. batchProcessor.BeginProcessing(files.Select(p => p.Path), PackageAction.Install); } string packageDirectory = PathResolver.GetPackageDirectory(package); // Add files FileSystem.AddFiles(files, packageDirectory); // If this is a Satellite Package, then copy the satellite files into the related runtime package folder too IPackage runtimePackage; if (PackageHelper.IsSatellitePackage(package, LocalRepository, targetFramework: null, runtimePackage: out runtimePackage)) { var satelliteFiles = package.GetSatelliteFiles(); var runtimePath = PathResolver.GetPackageDirectory(runtimePackage); FileSystem.AddFiles(satelliteFiles, runtimePath); } } finally { if (batchProcessor != null) { batchProcessor.EndProcessing(); } } }
protected virtual string GetPackageFilePath(string id, SemanticVersion version) { return(Path.Combine(PathResolver.GetPackageDirectory(id, version), PathResolver.GetPackageFileName(id, version))); }
protected virtual string GetPackageFilePath(IPackage package) { return(Path.Combine(PathResolver.GetPackageDirectory(package), PathResolver.GetPackageFileName(package))); }