Example #1
0
        /// <summary>
        /// Get default project in the type of <see cref="IVsProjectAdapter"/>, to keep PowerShell scripts backward-compatbility.
        /// </summary>
        /// <returns></returns>
        protected async Task <IVsProjectAdapter> GetDefaultProjectAsync()
        {
            var defaultNuGetProject = await VsSolutionManager.GetDefaultNuGetProjectAsync();

            // Solution may be open without a project in it. Then defaultNuGetProject is null.
            if (defaultNuGetProject != null)
            {
                return(await VsSolutionManager.GetVsProjectAdapterAsync(defaultNuGetProject));
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// Get the default NuGet Project
        /// </summary>
        /// <param name="projectName"></param>
        protected async Task GetNuGetProjectAsync(string projectName = null)
        {
            if (string.IsNullOrEmpty(projectName))
            {
                Project = await VsSolutionManager.GetDefaultNuGetProjectAsync();

                if ((await VsSolutionManager.IsSolutionAvailableAsync()) &&
                    Project == null)
                {
                    ErrorHandler.WriteProjectNotFoundError("Default", terminating: true);
                }
            }
            else
            {
                Project = await VsSolutionManager.GetNuGetProjectAsync(projectName);

                if ((await VsSolutionManager.IsSolutionAvailableAsync()) &&
                    Project == null)
                {
                    ErrorHandler.WriteProjectNotFoundError(projectName, terminating: true);
                }
            }
        }