public override void RemoveFile(string path) { if (string.IsNullOrEmpty(path)) { return; } string folderPath = Path.GetDirectoryName(path); string fullPath = FileSystemUtility.GetFullPath(ProjectFullPath, path); bool succeeded; succeeded = VCProjectHelper.RemoveFileFromProject(EnvDTEProject.Object, fullPath, folderPath); if (succeeded) { // The RemoveFileFromProject() method only removes file from project. // We want to delete it from disk too. FileSystemUtility.DeleteFileAndParentDirectoriesIfEmpty(ProjectFullPath, path, NuGetProjectContext); if (!String.IsNullOrEmpty(folderPath)) { NuGetProjectContext.Log(ProjectManagement.MessageLevel.Debug, Strings.Debug_RemovedFileFromFolder, Path.GetFileName(path), folderPath); } else { NuGetProjectContext.Log(ProjectManagement.MessageLevel.Debug, Strings.Debug_RemovedFile, Path.GetFileName(path)); } } }
public override void RemoveFile(string path) { if (string.IsNullOrEmpty(path)) { return; } var folderPath = Path.GetDirectoryName(path); var fullPath = FileSystemUtility.GetFullPath(ProjectFullPath, path); bool succeeded; #pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread // Since the C++ project system now uses CPS, it no longer needs to be on the UI thread. object projectObject = VsProjectAdapter.Project.Object; #pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread succeeded = VCProjectHelper.RemoveFileFromProject(projectObject, fullPath, folderPath); if (succeeded) { // The RemoveFileFromProject() method only removes file from project. // We want to delete it from disk too. FileSystemUtility.DeleteFileAndParentDirectoriesIfEmpty(ProjectFullPath, path, NuGetProjectContext); if (!string.IsNullOrEmpty(folderPath)) { NuGetProjectContext.Log(ProjectManagement.MessageLevel.Debug, Strings.Debug_RemovedFileFromFolder, Path.GetFileName(path), folderPath); } else { NuGetProjectContext.Log(ProjectManagement.MessageLevel.Debug, Strings.Debug_RemovedFile, Path.GetFileName(path)); } } }