private void normalRead(string text) { if (text.StartsWith(Global)) { _read = lookForGlobalSection; } else if (text.StartsWith("ProjectSection")) { _read = lookForProjectSection; } else if (IncludeAsProject(text)) { _solutionProject = new SolutionProject(text, _parent._filename.ParentDirectory()); _solutionProject.Solution = _parent; _parent._projects.Add(_solutionProject); _read = readProject; } else { _parent._header.Add(text); if (_parent.Version.IsEmpty()) { foreach (var versionLine in _versionLines.ToDictionary()) { if (text.Trim() == versionLine.Value[1]) { _parent.Version = versionLine.Key; } } } } }
/// <summary> /// Adds an existing project to the given <paramref name="solutionDirectory"/>. /// </summary> /// <param name="solutionDirectory"></param> /// <param name="project"></param> public void AddProject(string solutionDirectory, CsProjFile project) { var existing = FindProject(project.ProjectName); if (existing != null) { return; } var reference = new SolutionProject(project, solutionDirectory); this._projects.Add(reference); }
/// <summary> /// Attaches an existing project of this name to the solution or /// creates a new project based on a Class Library and attaches /// to the solution /// </summary> /// <param name="solutionFolder"></param> /// <param name="projectName"></param> public SolutionProject AddProject(string solutionFolder, string projectName) { var existing = FindProject(projectName); if (existing != null) { return(existing); } var reference = SolutionProject.CreateNewAt(ParentDirectory, projectName); _projects.Add(reference); return(reference); }
/// <summary> /// Adds a new project based on the supplied template file /// </summary> /// <param name="projectName"></param> /// <param name="templateFile"></param> public SolutionProject AddProjectFromTemplate(string projectName, string templateFile) { var existing = FindProject(projectName); if (existing != null) { ThrowExceptions.ArgumentOutOfRangeException(Exc.GetStackTrace(), type, Exc.CallingMethod(), "projectName", "Project with this name ({0}) already exists in the solution".ToFormat(projectName)); } var project = MSBuildProject.CreateFromFile(projectName, templateFile); var csProjFile = new CsProjFile(ParentDirectory.AppendPath(projectName, projectName + ".csproj"), project); csProjFile.ProjectGuid = Guid.NewGuid(); var reference = new SolutionProject(csProjFile, ParentDirectory); _projects.Add(reference); return(reference); }
public void WriteProjectConfiguration(SolutionProject solutionProject, GlobalSection section) { section.Read("\t\t{{{0}}}.{1}.ActiveCfg = {2}".ToFormat(solutionProject.ProjectGuid.ToString().ToUpper(), Key, Value)); section.Read("\t\t{{{0}}}.{1}.Build.0 = {2}".ToFormat(solutionProject.ProjectGuid.ToString().ToUpper(), Key, Value)); }
private void normalRead(string text) { if (text.StartsWith(Global)) { _read = lookForGlobalSection; } else if (text.StartsWith("Project")) { _solutionProject = new SolutionProject(text, _parent._filename.ParentDirectory()); _parent._projects.Add(_solutionProject); _read = readProject; } else if (_parent.Version.IsEmpty()) { foreach (var versionLine in _versionLines.ToDictionary()) { if (text.Trim() == versionLine.Value.First()) { _parent.Version = versionLine.Key; } } } }
/// <summary> /// Adds a new project based on the supplied template file /// </summary> /// <param name="projectName"></param> /// <param name="templateFile"></param> /// <returns></returns> public SolutionProject AddProjectFromTemplate(string projectName, string templateFile) { var existing = FindProject(projectName); if (existing != null) { throw new ArgumentOutOfRangeException("projectName", "Project with this name ({0}) already exists in the solution".ToFormat(projectName)); } var project = MSBuildProject.CreateFromFile(projectName, templateFile); var csProjFile = new CsProjFile(ParentDirectory.AppendPath(projectName, projectName + ".csproj"), project); csProjFile.ProjectGuid = Guid.NewGuid(); var reference = new SolutionProject(csProjFile, ParentDirectory); _projects.Add(reference); return reference; }
/// <summary> /// Adds an existing project /// </summary> /// <param name="project"></param> public void AddProject(CsProjFile project) { var existing = FindProject(project.ProjectName); if (existing != null) { return; } var reference = new SolutionProject(project, this.ParentDirectory); this._projects.Add(reference); }