private string GetRelativePathToProject(string toProject) { Project.Identifier toId = projectIdLookup[toProject]; return(Path.GetRelativePath(Reader.SolutionConfigDir, toId.AbsoluteSourcePath)); }
public DuplicateProjectGuidException(Project.Identifier a, Project.Identifier b) : base(string.Format("Project '{0}' guid {{{1}}} was already used by project '{2}'.", b.Name, b.Guid, a.Name)) { }
private List <Project> CreateProjectsForConfig(string moduleName, Configuration config, TemplateConfiguration templateConfig) { var projects = new List <Project>(); foreach (ProjectDelcaration declaration in templateConfig.ProjectDeclarations.Values) { string projectName = ExpandableVars.Instance.ExpandModuleNameInCopy(declaration.ProjectName, moduleName) .ToString(); using (new ExpandableVars.ScopedVariable(ExpandableVars.Instance, ExpandableVars.VAR_PROJECT_NAME, projectName)) { Log.Heading( "Creating project config '{0} - {1}' for project '{2}' (module '{3}') with settings '{4}'", config.GroupName, config.Name, projectName, moduleName, declaration.SettingsName); using (new Log.ScopedIndent()) { if (solution.IncludedProjectsPatterns.Count > 0 && !solution.CanIncludeProject(projectName)) { Log.Info("Project '{0}' is excluded by solution '{1}' property white list", projectName, Settings.PROP_INCLUDE_PROJECTS); excludedProjects.Add(projectName); continue; } Settings projectSettings = templateConfig.ProjectSettingsLookup[declaration.SettingsName]; if (projectSettings.GetProperty <string>(Settings.PROP_EXCLUDE) == "true") { Log.Info("Project '{0}' is excluded from configuration '{1} - {2}'", projectName, config.GroupName, config.Name); excludedProjects.Add(projectName); continue; } projectSettings = projectSettings.ExpandVariablesInCopy(); string moduleSourcePath = projectSettings.GetProperty <string>(Settings.PROP_PROJECT_SOURCE_PATH); string guidStr = projectSettings.GetProperty <string>(Settings.PROP_GUID); Guid guid = string.IsNullOrEmpty(guidStr) ? Guid.NewGuid() : Guid.Parse(guidStr); // All configurations of a project must have the same guid. if (!idLookup.TryGetValue(projectName, out Project.Identifier id)) { string relativeSourcePath = Path.GetRelativePath(solution.SolutionConfigDir, moduleSourcePath); id = new Project.Identifier(projectName, guid, moduleSourcePath, relativeSourcePath); idLookup[projectName] = id; } var project = new Project(solution, moduleName, id, config, projectSettings); if (solution.IncludedProjectsPatterns.Count > 0) { string[] invalidProjectRefs = project.ProjectRefs .Where(r => !solution.CanIncludeProject(r)) .ToArray(); if (invalidProjectRefs.Length > 0) { throw new InvalidProjectReferenceException(project, $"Referenced project is not in the '{Settings.PROP_INCLUDE_PROJECTS}' whitelist property." + $" Invalid references are [{string.Join(", ", invalidProjectRefs)}]"); } } projects.Add(project); } } } return(projects); }