public async Task <NuGetProject> GetDefaultNuGetProjectAsync()
        {
            await EnsureInitializeAsync();

            if (string.IsNullOrEmpty(DefaultNuGetProjectName))
            {
                return(null);
            }

            _projectSystemCache.TryGetNuGetProject(DefaultNuGetProjectName, out var defaultNuGetProject);
            return(defaultNuGetProject);
        }
Esempio n. 2
0
        /// <summary>
        /// Tries to get  the projectId for a project from the project system cache using the project unique name.
        /// </summary>
        /// <param name="projectUniqueName">Unique name for the project.</param>
        /// <param name="cache">ProjectSystem cache</param>
        /// <param name="result">Contains the projectId if the return result was true else it is set to null.</param>
        /// <returns>Returns bool indicating if the operation was successful.</returns>
        private static bool TryGetProjectIdFromCache(string projectUniqueName, IProjectSystemCache cache, out string result)
        {
            result = null;

            return(cache.TryGetNuGetProject(projectUniqueName, out var cacheEntry) &&
                   cacheEntry.TryGetMetadata(NuGetProjectMetadataKeys.ProjectId, out result));
        }
Esempio n. 3
0
        public NuGetProject GetNuGetProject(string nuGetProjectSafeName)
        {
            if (string.IsNullOrEmpty(nuGetProjectSafeName))
            {
                throw new ArgumentException(
                          ProjectManagement.Strings.Argument_Cannot_Be_Null_Or_Empty,
                          nameof(nuGetProjectSafeName));
            }

            EnsureInitialize();

            NuGetProject nuGetProject = null;

            // Project system cache could be null when solution is not open.
            if (_projectSystemCache != null)
            {
                _projectSystemCache.TryGetNuGetProject(nuGetProjectSafeName, out nuGetProject);
            }
            return(nuGetProject);
        }