public string CreateSolution(IBuildBootstrappedSolutions bootstrapper, SolutionConfiguration configuration) { configuration.InCodeSubscriptions = true; foreach (var endpointConfiguration in configuration.EndpointConfigurations) { endpointConfiguration.InCodeSubscriptions = configuration.InCodeSubscriptions; } var solutionData = bootstrapper.BootstrapSolution(configuration); var solutionDirectory = SavePath + Guid.NewGuid(); var solutionFile = SaveSolution(solutionDirectory, solutionData); InstallNuGetPackages(solutionDirectory, solutionData, solutionFile, NuGetExe); //AddReferencesToNugetPackages(solutionDirectory); var zipFilePath = solutionFile.Replace(".sln", ".zip"); using (var zip = new ZipFile()) { zip.AddDirectory(solutionDirectory, "Solution"); zip.Save(zipFilePath); } return zipFilePath; }
public static FileAbstraction CreateAppConfig(SolutionConfiguration solutionConfiguration) { var mappings = new List<string>(); if (!solutionConfiguration.InCodeSubscriptions) { foreach (var endpoint in solutionConfiguration.EndpointConfigurations) { foreach (var message in endpoint.MessageHandlers.Where(m => !m.IsEvent)) { mappings.Add(MakeMapping(TextPlaceholder.SharedProjectName, message.MessageTypeName, endpoint.EndpointName)); } } } var mappingSection = string.Join("", mappings.ToArray()); var appConfig = FileTemplate.Replace("{{messageMappings}}", mappingSection); return new FileAbstraction() { Name = "app.config", Content = appConfig, }; }
public static FileAbstraction CreateSolutionFile(SolutionConfiguration configuration) { var solutionName = "Ignited.NServiceBus" + configuration.NServiceBusVersion + "." + configuration.Transport.ToString(); var solutionGuid = Guid.NewGuid(); var projectIncludes = configuration.EndpointConfigurations .Select(e => CreateProjectInclude(solutionGuid, e.ProjectGuid, e.EndpointName)) .ToList(); var sharedProjectGuid = Guid.NewGuid(); var consoleProjectGuid = Guid.NewGuid(); projectIncludes.Add(CreateProjectInclude(solutionGuid, sharedProjectGuid, TextPlaceholder.SharedProjectName)); projectIncludes.Add(CreateProjectInclude(solutionGuid, consoleProjectGuid, TextPlaceholder.ConsoleProjectName)); var projectConfigurations = configuration.EndpointConfigurations .Select(e => CreateProjectConfiguration(e.ProjectGuid)) .ToList(); projectConfigurations.Add(CreateProjectConfiguration(sharedProjectGuid)); projectConfigurations.Add(CreateProjectConfiguration(consoleProjectGuid)); var solutionFileContent = SolutionFileTemplate .Replace("{{projectIncludes}}", string.Join(Environment.NewLine, projectIncludes)) //.Replace("{{instructionsIncludes}}", CreateInstructionsFolder(solutionGuid)) .Replace("{{projectConfigurations}}", string.Join(Environment.NewLine, projectConfigurations)); var solutionFile = new FileAbstraction() { Name = solutionName + ".sln", Content = solutionFileContent }; return solutionFile; }
private BootstrappedProject GenerateConsoleProject(SolutionConfiguration solutionConfig, List <ProjectReferenceData> projectDependencies) { var consoleProject = new BootstrappedProject() { ProjectName = TextPlaceholder.ConsoleProjectName, ProjectGuid = Guid.NewGuid() }; var busConfigurations = new List <string> { GetMethodBody(TransportMethods.MethodsDictionary[solutionConfig.Transport]), GetMethodBody(SerializerMethods.MethodsDictionary[solutionConfig.Serializer]), GetMethodBody(PersistenceMethods.MethodsDictionary[solutionConfig.Persistence]), }; var uniqueMessages = GetUniqueMessages(solutionConfig); var commandExamples = uniqueMessages .Where(i => !i.IsEvent) .Select(m => GetMethodBody(BusMethods.MethodsDictionary[BusMethod.Send]).Replace(TextPlaceholder.MessagePlaceholder, m.MessageTypeName)); var eventExamples = uniqueMessages .Where(i => i.IsEvent) .Select(m => GetMethodBody(BusMethods.MethodsDictionary[BusMethod.Publish]).Replace(TextPlaceholder.EventPlaceholder, m.MessageTypeName)); var messageExamples = new List <string>(); messageExamples.AddRange(commandExamples); messageExamples.AddRange(eventExamples); var programContent = GetClassTemplate <Program>(); programContent = PlaceIndentedMultiLineText(programContent, TextPlaceholder.BusConfigurationCallsPlaceholder, busConfigurations); programContent = PlaceIndentedMultiLineText(programContent, TextPlaceholder.BusExampleCalls, messageExamples); consoleProject.ProjectRoot.Files.Add(new FileAbstraction() { Name = "Program.cs", Content = programContent }); var nugetDependencies = dependencyMapper.GetDependencies(solutionConfig.NServiceBusVersion, solutionConfig.Transport); consoleProject.ProjectRoot.Files.Add(NuGetPackagesTemplator.CreatePackagesFile(nugetDependencies)); consoleProject.ProjectRoot.Files.Add(AppConfigTemplator.CreateAppConfig(solutionConfig)); consoleProject.ProjectRoot.Files.Add(new FileAbstraction() { Name = "ProvideErrorConfiguration.cs", Content = GetClassTemplate <ProvideErrorConfiguration>() }); consoleProject.ProjectRoot.Files.Add(new FileAbstraction() { Name = consoleProject.ProjectName + ".csproj", Content = ProjectFileTemplator.CreateProjectFile(consoleProject, ProjectType.Exe, projectDependencies) }); return(consoleProject); }