private void CreateSolutionAndProject() { progress.Increment("CreatingProjects"); Solution solution = new Solution(OutputFolder, Solution); int projectNumber = 65; foreach (Project project in Projects) { if (project.AssemblyName == null) { project.AssemblyName = project.Name; } if (project.Guid == null) { project.Guid = GetGuid((char)projectNumber); projectNumber++; } solution.Projects.Add(project); } foreach (Project project in solution.Projects) { project.Template = GetResourceContents("ProjectTemplate.xml"); project.Create(); if (project.Reference != null) { foreach (string reference in project.Reference.Split(',')) { project.AddProjectReference(solution.GetProject(reference)); } } project.OutputFolder = Path.GetFullPath(Path.Combine(OutputFolder, project.OutputFolder)); IList helpers = new ArrayList(); string helpersNamespace = "Helpers."; foreach (Source source in Sources.Values) { if (source.OutputFile.StartsWith(project.OutputFolder) && source.CodeFile) { project.AddFile(source.OutputFile.Replace(project.OutputFolder + Path.DirectorySeparatorChar, ""), true); UsageRemoverTransformer uur = new TypeMapper(); uur.CodeBase = codeBase; uur.VisitCompilationUnit(source.CompilationUnit, null); foreach (string type in uur.UsedTypes) { if (type.StartsWith(helpersNamespace) && !helpers.Contains(type)) { helpers.Add(type); } } } } foreach (string helperType in helpers) { string file = helperType.Substring(helpersNamespace.Length) + ".cs"; string filePath = Path.Combine(HelperDirectory, file); string helperOutputFolder = Path.Combine(project.OutputFolder, options.GetKey("Projects", "IncludeHelpersInDirectory")); string outputFile = Path.Combine(helperOutputFolder, file); project.AddFile(outputFile.Replace(project.OutputFolder + Path.DirectorySeparatorChar, ""), true); CreateDirectoryForFile(outputFile); File.Copy(filePath, outputFile, true); } if (solution.Folder != Path.Combine(OutputFolder, project.OutputFolder)) { AddAssemblyReferences(project, Path.Combine("..", ReferenceFolder)); } else { AddAssemblyReferences(project, ReferenceFolder); } project.Save(); } solution.Save(); }
private void CreateSolutionAndProject() { progress.Increment("CreatingProjects"); Solution solution = new Solution(OutputFolder, Solution); int projectNumber = 65; foreach (Project project in Projects) { if (project.AssemblyName == null) project.AssemblyName = project.Name; if (project.Guid == null) { project.Guid = GetGuid((char) projectNumber); projectNumber++; } solution.Projects.Add(project); } foreach (Project project in solution.Projects) { project.Template = GetResourceContents("ProjectTemplate.xml"); project.Create(); if (project.Reference != null) { foreach (string reference in project.Reference.Split(',')) project.AddProjectReference(solution.GetProject(reference)); } project.OutputFolder = Path.GetFullPath(Path.Combine(OutputFolder, project.OutputFolder)); IList helpers = new ArrayList(); string helpersNamespace = "Helpers."; foreach (Source source in Sources.Values) { if (source.OutputFile.StartsWith(project.OutputFolder) && source.CodeFile) { project.AddFile(source.OutputFile.Replace(project.OutputFolder + Path.DirectorySeparatorChar, ""), true); UsageRemoverTransformer uur = new TypeMapper(); uur.CodeBase = codeBase; uur.VisitCompilationUnit(source.CompilationUnit, null); foreach (string type in uur.UsedTypes) { if (type.StartsWith(helpersNamespace) && !helpers.Contains(type)) helpers.Add(type); } } } foreach (string helperType in helpers) { string file = helperType.Substring(helpersNamespace.Length) + ".cs"; string filePath = Path.Combine(HelperDirectory, file); string helperOutputFolder = Path.Combine(project.OutputFolder, options.GetKey("Projects", "IncludeHelpersInDirectory")); string outputFile = Path.Combine(helperOutputFolder, file); project.AddFile(outputFile.Replace(project.OutputFolder + Path.DirectorySeparatorChar, ""), true); CreateDirectoryForFile(outputFile); File.Copy(filePath, outputFile, true); } if (solution.Folder != Path.Combine(OutputFolder, project.OutputFolder)) AddAssemblyReferences(project, Path.Combine("..", ReferenceFolder)); else AddAssemblyReferences(project, ReferenceFolder); project.Save(); } solution.Save(); }