public void SaveProject(NuGetProject nuGetProject) { ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var safeName = GetNuGetProjectSafeName(nuGetProject); EnvDTEProjectUtility.Save(GetDTEProject(safeName)); }); }
public virtual void RemoveImport(string targetFullPath) { if (String.IsNullOrEmpty(targetFullPath)) { throw new ArgumentNullException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "targetPath"); } string relativeTargetPath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(EnvDTEProjectUtility.GetFullPath(EnvDTEProject)), targetFullPath); EnvDTEProjectUtility.RemoveImportStatement(EnvDTEProject, relativeTargetPath); EnvDTEProjectUtility.Save(EnvDTEProject); // notify the project system of the change UpdateImportStamp(EnvDTEProject); }
public virtual void AddImport(string targetFullPath, ImportLocation location) { if (String.IsNullOrEmpty(targetFullPath)) { throw new ArgumentNullException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "targetPath"); } NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); string relativeTargetPath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(ProjectFullPath), targetFullPath); EnvDTEProjectUtility.AddImportStatement(EnvDTEProject, relativeTargetPath, location); EnvDTEProjectUtility.Save(EnvDTEProject); // notify the project system of the change UpdateImportStamp(EnvDTEProject); }); }
public override void RemoveImport(string targetPath) { if (String.IsNullOrEmpty(targetPath)) { throw new ArgumentNullException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "targetPath"); } var root = EnvDTEProjectUtility.GetFullPath(EnvDTEProject); // For VS 2012 or above, the operation has to be done inside the Writer lock string relativeTargetPath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(root), targetPath); if (VSVersionHelper.IsVisualStudio2012) { EnvDTEProjectUtility.DoWorkInWriterLock(EnvDTEProject, buildProject => MicrosoftBuildEvaluationProjectUtility.RemoveImportStatement(buildProject, relativeTargetPath)); EnvDTEProjectUtility.Save(EnvDTEProject); } else { RemoveImportStatementForVS2013(relativeTargetPath); } }