예제 #1
0
        public void AddProject(Project project)
        {
            IsSccBound |= project.IsSccBound;

            if (_solutionRoot.ContainsProject(project))
            {
                return;
            }

            _solutionRoot.AddProject(project);

            var referenceFolder = _solutionRoot.Items.OfType <SolutionFolder>().SingleOrDefault();

            if (referenceFolder != null)
            {
                RemoveProject(referenceFolder, project);
            }

            if (_settings.IncludeReferencedProjects)
            {
                AddReferencedProjects(project, _settings.ReferenceTreeDepth);
            }

            var projectCount = SolutionItems.Flatten <SolutionItem, SolutionProject, SolutionFolder>(p => p.Items).Count();

            _statusMessenger.Show(String.Format("{0} projects in the solution.", projectCount));

            Refresh();
        }
예제 #2
0
파일: SlnGen.cs 프로젝트: psnwd/SlnGen
 /// <summary>
 /// Gets the solution items' full paths.
 /// </summary>
 /// <param name="fileExists">A <see cref="Func{String, Boolean}"/> to use when determining if a file exists.</param>
 /// <returns>An <see cref="IEnumerable{String}"/> of full paths to include as solution items.</returns>
 internal IEnumerable <string> GetSolutionItems(Func <string, bool> fileExists)
 {
     foreach (string solutionItem in SolutionItems.Select(i => i.GetMetadata("FullPath")).Where(i => !string.IsNullOrWhiteSpace(i)))
     {
         if (!fileExists(solutionItem))
         {
             Log.LogMessageFromText($"The solution item \"{solutionItem}\" does not exist and will not be added to the solution.", MessageImportance.Low);
         }
         else
         {
             yield return(solutionItem);
         }
     }
 }
예제 #3
0
        /// <inheritdoc cref="Task.Execute()" />
        public override bool Execute()
        {
            ISlnGenLogger logger = new TaskLogger(BuildEngine);

            if (BuildingSolutionFile)
            {
                if (!File.Exists(SolutionFileFullPath))
                {
                    Log.LogError($"Could not find part of the path '{SolutionFileFullPath}'.");
                }
            }
            else
            {
                IDictionary <string, string> globalProperties = GetGlobalProperties();

                // Load up the full project closure
                ProjectCollection projectCollection = SlnGenUtility.LoadProjectsAndReferences(
                    globalProperties,
                    ToolsVersion,
                    BuildEngine,
                    CollectStats,
                    ProjectFullPath,
                    ProjectReferences,
                    logger);

                // Return if loading projects logged any errors
                if (!Log.HasLoggedErrors)
                {
                    SlnGenUtility.GenerateSolutionFile(
                        projectCollection,
                        SolutionFileFullPath,
                        ProjectFullPath,
                        SlnProject.GetCustomProjectTypeGuids(CustomProjectTypeGuids.Select(i => new MSBuildTaskItem(i))),
                        Folders,
                        SlnFile.GetSolutionItems(SolutionItems.Select(i => new MSBuildTaskItem(i)), logger),
                        logger);
                }
            }

            if (!Log.HasLoggedErrors && ShouldLaunchVisualStudio)
            {
                SlnGenUtility.LaunchVisualStudio(
                    DevEnvFullPath,
                    UseShellExecute,
                    SolutionFileFullPath,
                    logger);
            }

            return(!Log.HasLoggedErrors);
        }
예제 #4
0
        public void RemoveSolutionItem()
        {
            if (_selectedItem != null)
            {
                var parentFolder = _selectedItem.Parent;

                var index = parentFolder.Items.IndexOf(_selectedItem);
                parentFolder.Items.Remove(_selectedItem);

                if (index >= 0)
                {
                    if (index >= parentFolder.Items.Count)
                    {
                        index--;
                    }
                    SelectedItem = index >= 0 ? parentFolder.Items[index] : parentFolder;
                }

                var projectCount = SolutionItems.Flatten <SolutionItem, SolutionProject, SolutionFolder>(p => p.Items).Count();
                _statusMessenger.Show(String.Format("{0} projects in the solution.", projectCount));

                Refresh();
            }
        }