private void GeneratePlatformSpecificSolution(ProjectFileConfiguration projectConfig, bool includeTests, bool travisSolution, string solutionFileName = null) { // Do not generate solutions for PCL sub profiles. if (projectConfig.IsSubProfile) { return; } var projectType = projectConfig.Name; Console.WriteLine("...generating platform-specific solution file AWSSDK.{0}.sln", projectType); var session = new Dictionary <string, object>(); var buildConfigurations = new HashSet <string>(StringComparer.OrdinalIgnoreCase); var solutionProjects = new Dictionary <string, ProjectFileCreator.ProjectConfigurationData>(); var projectTypeWildCard = string.Format("AWSSDK.*.{0}.csproj", projectType); var sdkSourceFolder = Path.Combine(Options.SdkRootFolder, GeneratorDriver.SourceSubFoldername); var coreProjects = new List <Project>(); var coreProjectsRoot = Path.Combine(sdkSourceFolder, GeneratorDriver.CoreSubFoldername); foreach (var projectFile in Directory.GetFiles(coreProjectsRoot, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { coreProjects.Add(CoreProjectFromFile(projectFile)); SelectProjectAndConfigurationsForSolution(projectFile, solutionProjects, buildConfigurations); } var serviceSolutionFolders = new List <ServiceSolutionFolder>(); var serviceProjectsRoot = Path.Combine(sdkSourceFolder, GeneratorDriver.ServicesSubFoldername); foreach (var servicePath in Directory.GetDirectories(serviceProjectsRoot)) { var di = new DirectoryInfo(servicePath); var folder = ServiceSolutionFolderFromPath(di.Name); foreach (var projectFile in Directory.GetFiles(servicePath, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { if (travisSolution && projectFile.Contains("AWSSDK.MobileAnalytics")) { continue; } folder.Projects.Add(ServiceProjectFromFile(di.Name, projectFile)); SelectProjectAndConfigurationsForSolution(projectFile, solutionProjects, buildConfigurations); } serviceSolutionFolders.Add(folder); } var testProjects = new List <Project>(); if (includeTests) { var sdkTestsFolder = Path.Combine(Options.SdkRootFolder, GeneratorDriver.TestsSubFoldername); foreach (var testFoldername in new[] { GeneratorDriver.CommonTestSubFoldername, GeneratorDriver.UnitTestsSubFoldername, GeneratorDriver.IntegrationTestsSubFolderName }) { var testFolder = Path.Combine(sdkTestsFolder, testFoldername); foreach (var projectFile in Directory.GetFiles(testFolder, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { testProjects.Add(TestProjectFromFile(testFoldername, projectFile)); var projectKey = Path.GetFileNameWithoutExtension(projectFile); solutionProjects.Add(projectKey, _allProjects[projectKey]); SelectBuildConfigurationsForProject(projectKey, buildConfigurations); } } if (projectType.Equals(ProjectTypes.Net35, StringComparison.Ordinal) || projectType.Equals(ProjectTypes.Net45, StringComparison.Ordinal)) { solutionProjects.Add(GeneratorLibProjectName, GeneratorLibProjectConfig); testProjects.Add(GeneratorLibProject); SelectBuildConfigurationsForProject(GeneratorLibProjectName, buildConfigurations); } AddExtraTestProjects(projectConfig, solutionProjects, testProjects); } var configurationsList = buildConfigurations.ToList(); configurationsList.Sort(); session["AllProjects"] = solutionProjects; session["CoreProjects"] = coreProjects; session["ServiceSolutionFolders"] = serviceSolutionFolders; session["TestProjects"] = testProjects; session["Configurations"] = configurationsList; var generator = new SolutionFileGenerator { Session = session }; var content = generator.TransformText(); if (string.IsNullOrEmpty(solutionFileName)) { solutionFileName = string.Format("AWSSDK.{0}.sln", projectType); } GeneratorDriver.WriteFile(Options.SdkRootFolder, null, solutionFileName, content, true, false); }
private void GenerateAllPlatformsSolution(string solutionFileName, IEnumerable <ProjectFileConfiguration> projectFileConfigurations) { var session = new Dictionary <string, object>(); Console.WriteLine("...generating all-platforms solution file solutionFileName", solutionFileName); // use an AWSSDK prefix on project names so as to not collect any user-created projects (unless they // chose to use our naming pattern) const string awssdkProjectFileNamePattern = "AWSSDK.*.csproj"; var sdkSourceFolder = Path.Combine(Options.SdkRootFolder, GeneratorDriver.SourceSubFoldername); var coreProjects = new List <Project>(); var coreProjectsRoot = Path.Combine(sdkSourceFolder, GeneratorDriver.CoreSubFoldername); foreach (var projectFile in Directory.GetFiles(coreProjectsRoot, awssdkProjectFileNamePattern, SearchOption.TopDirectoryOnly)) { coreProjects.Add(CoreProjectFromFile(projectFile)); } var serviceSolutionFolders = new List <ServiceSolutionFolder>(); var serviceProjectsRoot = Path.Combine(sdkSourceFolder, GeneratorDriver.ServicesSubFoldername); foreach (var servicePath in Directory.GetDirectories(serviceProjectsRoot)) { var di = new DirectoryInfo(servicePath); var folder = ServiceSolutionFolderFromPath(di.Name); foreach (var projectFile in Directory.GetFiles(servicePath, awssdkProjectFileNamePattern, SearchOption.TopDirectoryOnly)) { folder.Projects.Add(ServiceProjectFromFile(di.Name, projectFile)); } serviceSolutionFolders.Add(folder); } var testProjects = new List <Project> { GeneratorLibProject }; var sdkTestsFolder = Path.Combine(Options.SdkRootFolder, GeneratorDriver.TestsSubFoldername); foreach (var testFoldername in new[] { GeneratorDriver.CommonTestSubFoldername, GeneratorDriver.UnitTestsSubFoldername, GeneratorDriver.IntegrationTestsSubFolderName }) { var testsFolder = Path.Combine(sdkTestsFolder, testFoldername); foreach (var projectFile in Directory.GetFiles(testsFolder, awssdkProjectFileNamePattern, SearchOption.TopDirectoryOnly)) { testProjects.Add(TestProjectFromFile(testFoldername, projectFile)); } } foreach (var pfc in projectFileConfigurations) { AddExtraTestProjects(pfc, _allProjects, testProjects); } // as we are processing _allProjects, construct the set of distinct build configurations at the end var distinctConfigurations = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var projectKey in _allProjects.Keys) { foreach (var cp in _allProjects[projectKey].ConfigurationPlatforms) { distinctConfigurations.Add(cp); } } var configurationsList = distinctConfigurations.ToList(); configurationsList.Sort(); session["AllProjects"] = _allProjects; session["CoreProjects"] = coreProjects; session["ServiceSolutionFolders"] = serviceSolutionFolders; session["TestProjects"] = testProjects; session["Configurations"] = configurationsList; var generator = new SolutionFileGenerator { Session = session }; var content = generator.TransformText(); GeneratorDriver.WriteFile(Options.SdkRootFolder, null, solutionFileName, content, true, false); }
private void GenerateCombinedSolution(string solutionFileName, bool includeTests, IEnumerable <ProjectFileConfiguration> projectFileConfigurations) { Console.WriteLine("Generating solution file {0}", solutionFileName); var session = new Dictionary <string, object>(); var buildConfigurations = new HashSet <string>(StringComparer.OrdinalIgnoreCase); var solutionProjects = new Dictionary <string, ProjectFileCreator.ProjectConfigurationData>(); var sdkSourceFolder = Path.Combine(Options.SdkRootFolder, GeneratorDriver.SourceSubFoldername); var coreProjects = new List <Project>(); var coreProjectsRoot = Path.Combine(sdkSourceFolder, GeneratorDriver.CoreSubFoldername); foreach (var pfc in projectFileConfigurations) { var projectTypeWildCard = string.Format("AWSSDK.*.{0}.csproj", pfc.Name); foreach (var projectFile in Directory.GetFiles(coreProjectsRoot, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { coreProjects.Add(CoreProjectFromFile(projectFile)); SelectProjectAndConfigurationsForSolution(projectFile, solutionProjects, buildConfigurations); } } var serviceSolutionFolders = new List <ServiceSolutionFolder>(); var serviceProjectsRoot = Path.Combine(sdkSourceFolder, GeneratorDriver.ServicesSubFoldername); foreach (var servicePath in Directory.GetDirectories(serviceProjectsRoot)) { var di = new DirectoryInfo(servicePath); var folder = ServiceSolutionFolderFromPath(di.Name); foreach (var pfc in projectFileConfigurations) { var projectTypeWildCard = string.Format("AWSSDK.*.{0}.csproj", pfc.Name); foreach (var projectFile in Directory.GetFiles(servicePath, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { folder.Projects.Add(ServiceProjectFromFile(di.Name, projectFile)); SelectProjectAndConfigurationsForSolution(projectFile, solutionProjects, buildConfigurations); } } if (folder.Projects.Count > 0) { serviceSolutionFolders.Add(folder); } } var testProjects = new List <Project>(); if (includeTests) { foreach (var pfc in projectFileConfigurations) { var projectType = pfc.Name; var projectTypeWildCard = string.Format("AWSSDK.*.{0}.csproj", pfc.Name); var sdkTestsFolder = Path.Combine(Options.SdkRootFolder, GeneratorDriver.TestsSubFoldername); foreach (var testFoldername in new[] { GeneratorDriver.CommonTestSubFoldername, GeneratorDriver.UnitTestsSubFoldername, GeneratorDriver.IntegrationTestsSubFolderName }) { var testFolder = Path.Combine(sdkTestsFolder, testFoldername); foreach (var projectFile in Directory.GetFiles(testFolder, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { testProjects.Add(TestProjectFromFile(testFoldername, projectFile)); var projectKey = Path.GetFileNameWithoutExtension(projectFile); solutionProjects.Add(projectKey, _allProjects[projectKey]); SelectBuildConfigurationsForProject(projectKey, buildConfigurations); } } if (projectType.Equals(ProjectTypes.Net35, StringComparison.Ordinal) || projectType.Equals(ProjectTypes.Net45, StringComparison.Ordinal) && !solutionProjects.ContainsKey(GeneratorLibProjectName)) { solutionProjects.Add(GeneratorLibProjectName, GeneratorLibProjectConfig); testProjects.Add(GeneratorLibProject); SelectBuildConfigurationsForProject(GeneratorLibProjectName, buildConfigurations); } AddExtraTestProjects(pfc, solutionProjects, testProjects); } } var configurationsList = buildConfigurations.ToList(); configurationsList.Sort(); session["AllProjects"] = solutionProjects; session["CoreProjects"] = coreProjects; session["ServiceSolutionFolders"] = serviceSolutionFolders; session["TestProjects"] = testProjects; session["Configurations"] = configurationsList; var generator = new SolutionFileGenerator { Session = session }; var content = generator.TransformText(); GeneratorDriver.WriteFile(Options.SdkRootFolder, null, solutionFileName, content, true, false); }
private void GenerateBuildUnitTestSolution(string solutionFileName, IEnumerable <ProjectFileConfiguration> projectFileConfigurations, ICollection <string> serviceProjectsForPartialBuild = null) { var buildConfigurations = new HashSet <string>(StringComparer.OrdinalIgnoreCase); // AllProjects var solutionProjects = new Dictionary <string, ProjectFileCreator.ProjectConfigurationData>(); // CoreProjects var coreProjects = new List <Project>(); // TestProjects var testProjects = new List <Project> { GeneratorLibProject }; foreach (var pfc in projectFileConfigurations) { var projectType = pfc.Name; var sdkTestsFolder = Path.Combine(Options.SdkRootFolder, GeneratorDriver.TestsSubFoldername); // Add partial project files var projectTypeWildCard = string.Format("AWSSDK.*.{0}.partial.csproj", pfc.Name); var testFolder = Path.Combine(sdkTestsFolder, GeneratorDriver.UnitTestsSubFoldername); foreach (var projectFile in Directory.GetFiles(testFolder, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { testProjects.Add(TestProjectFromFile(GeneratorDriver.UnitTestsSubFoldername, projectFile)); var projectKey = Path.GetFileNameWithoutExtension(projectFile); solutionProjects.Add(projectKey, _allProjects[projectKey]); SelectBuildConfigurationsForProject(projectKey, buildConfigurations); } // Add common test project files projectTypeWildCard = string.Format("AWSSDK.*.{0}.csproj", pfc.Name); testFolder = Path.Combine(sdkTestsFolder, GeneratorDriver.CommonTestSubFoldername); foreach (var projectFile in Directory.GetFiles(testFolder, projectTypeWildCard, SearchOption.TopDirectoryOnly)) { testProjects.Add(TestProjectFromFile(GeneratorDriver.CommonTestSubFoldername, projectFile)); var projectKey = Path.GetFileNameWithoutExtension(projectFile); solutionProjects.Add(projectKey, _allProjects[projectKey]); SelectBuildConfigurationsForProject(projectKey, buildConfigurations); } if (projectType.Equals(ProjectTypes.Net35, StringComparison.Ordinal) || projectType.Equals(ProjectTypes.Net45, StringComparison.Ordinal) && !solutionProjects.ContainsKey(GeneratorLibProjectName)) { solutionProjects.Add(GeneratorLibProjectName, GeneratorLibProjectConfig); SelectBuildConfigurationsForProject(GeneratorLibProjectName, buildConfigurations); } AddExtraTestProjects(pfc, solutionProjects, testProjects); } var configurationsList = buildConfigurations.ToList(); configurationsList.Sort(); var session = new Dictionary <string, object>(); session["AllProjects"] = solutionProjects; session["CoreProjects"] = coreProjects; session["ServiceSolutionFolders"] = new List <ServiceSolutionFolder>(); session["TestProjects"] = testProjects; session["Configurations"] = configurationsList; var generator = new SolutionFileGenerator { Session = session }; var content = generator.TransformText(); GeneratorDriver.WriteFile(Options.SdkRootFolder, null, "Build.UnitTests.partial.sln", content, true, false); }