Пример #1
0
 public void SaveProject(NuGetProject nuGetProject)
 {
     ThreadHelper.JoinableTaskFactory.Run(async delegate
     {
         await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
         var safeName = GetNuGetProjectSafeName(nuGetProject);
         EnvDTEProjectUtility.Save(GetDTEProject(safeName));
     });
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
            });
        }
Пример #4
0
        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);
            }
        }