Beispiel #1
0
        public static NuGetProject GetNuGetProject(EnvDTE.Project project, ISolutionManager solutionManager)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Debug.Assert(project != null);
            Debug.Assert(solutionManager != null);

            var nuGetProject = solutionManager.GetNuGetProject(project.Name);

            if (nuGetProject == null)
            {
                nuGetProject = solutionManager.GetNuGetProject(project.UniqueName);
            }
            return(nuGetProject);
        }
Beispiel #2
0
        /// <summary>
        /// Finds the NuGetProject from a DTE project
        /// </summary>
        public static async Task <NuGetProject> GetProjectAsync(ISolutionManager solutionManager, Project project, VSAPIProjectContext projectContext = null)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (solutionManager == null)
            {
                throw new ArgumentNullException("solution");
            }

            var projectSafeName = await EnvDTEProjectUtility.GetCustomUniqueNameAsync(project);

            NuGetProject nuGetProject = solutionManager.GetNuGetProject(projectSafeName);

            var settings = ServiceLocator.GetInstance <Configuration.ISettings>();

            // if the project does not exist in the solution (this is true for new templates) create it manually
            if (nuGetProject == null)
            {
                VSNuGetProjectFactory factory =
                    new VSNuGetProjectFactory(() => PackagesFolderPathUtility.GetPackagesFolderPath(solutionManager, settings));
                nuGetProject = factory.CreateNuGetProject(project, projectContext);
            }

            return(nuGetProject);
        }
Beispiel #3
0
 /// <summary>
 /// Get the default NuGet Project
 /// </summary>
 /// <param name="projectName"></param>
 protected void GetNuGetProject(string projectName = null)
 {
     if (string.IsNullOrEmpty(projectName))
     {
         Project = _solutionManager.DefaultNuGetProject;
         if (_solutionManager.IsSolutionOpen && Project == null)
         {
             ErrorHandler.WriteProjectNotFoundError("Default", terminating: true);
         }
     }
     else
     {
         Project = _solutionManager.GetNuGetProject(projectName);
         if (_solutionManager.IsSolutionOpen && Project == null)
         {
             ErrorHandler.WriteProjectNotFoundError(projectName, terminating: true);
         }
     }
 }
Beispiel #4
0
        private static IMSBuildProjectSystem GetMSBuildNuGetProjectSystem(ISolutionManager solutionManager, IVsProjectAdapter vsProjectAdapter)
        {
            var nuGetProject = solutionManager.GetNuGetProject(vsProjectAdapter.ProjectName);

            if (nuGetProject != null)
            {
                var msBuildNuGetProject = nuGetProject as MSBuildNuGetProject;
                if (msBuildNuGetProject != null)
                {
                    return(msBuildNuGetProject.ProjectSystem);
                }
            }
            return(null);
        }
Beispiel #5
0
        private static IMSBuildNuGetProjectSystem GetMSBuildNuGetProjectSystem(ISolutionManager solutionManager, EnvDTEProject envDTEProject)
        {
            var nuGetProject = solutionManager.GetNuGetProject(envDTEProject.Name);

            if (nuGetProject != null)
            {
                var msBuildNuGetProject = nuGetProject as MSBuildNuGetProject;
                if (msBuildNuGetProject != null)
                {
                    return(msBuildNuGetProject.MSBuildNuGetProjectSystem);
                }
            }
            return(null);
        }
        /// <summary>
        /// Finds the NuGetProject from a DTE project
        /// </summary>
        public static NuGetProject GetProject(ISolutionManager solutionManager, Project project, VSAPIProjectContext projectContext=null)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException("solution");
            }

            var projectSafeName = EnvDTEProjectUtility.GetCustomUniqueName(project);
            NuGetProject nuGetProject = solutionManager.GetNuGetProject(projectSafeName);

            var settings = ServiceLocator.GetInstance<ISettings>();

            // if the project does not exist in the solution (this is true for new templates) create it manually
            if (nuGetProject == null)
            {
                VSNuGetProjectFactory factory = new VSNuGetProjectFactory(() => PackagesFolderPathUtility.GetPackagesFolderPath(solutionManager, settings));
                nuGetProject = factory.CreateNuGetProject(project, projectContext);
            }

            return nuGetProject;
        }
Beispiel #7
0
        /// <summary>
        /// Finds the NuGetProject from a DTE project
        /// </summary>
        public static NuGetProject GetProject(ISolutionManager solutionManager, Project project, VSAPIProjectContext projectContext = null)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException("solution");
            }

            var          projectSafeName = EnvDTEProjectUtility.GetCustomUniqueName(project);
            NuGetProject nuGetProject    = solutionManager.GetNuGetProject(projectSafeName);

            var settings = ServiceLocator.GetInstance <ISettings>();

            // if the project does not exist in the solution (this is true for new templates) create it manually
            if (nuGetProject == null)
            {
                VSNuGetProjectFactory factory = new VSNuGetProjectFactory(() => PackagesFolderPathUtility.GetPackagesFolderPath(solutionManager, settings));
                nuGetProject = factory.CreateNuGetProject(project, projectContext);
            }

            return(nuGetProject);
        }