Ejemplo n.º 1
0
        private static async Task <Application> InferApplicationForProject(OutputContext output, FileInfo projectFile)
        {
            var globals = new ApplicationGlobals();

            globals.Name = Names.NormalizeToDns(Path.GetFileNameWithoutExtension(projectFile.Name));

            var services = new List <ServiceEntry>();

            var name    = Path.GetFileNameWithoutExtension(projectFile.Name);
            var project = new Project(projectFile.FullName);
            var service = new ServiceEntry(new Service(name), name);

            service.Service.Source = project;
            services.Add(service);

            await ProjectReader.ReadProjectDetailsAsync(output, projectFile, project);

            var container = new ContainerInfo();

            service.Service.GeneratedAssets.Container = container;

            var application = new GroveledApplication(globals, projectFile.DirectoryName, services);

            DockerfileGenerator.ApplyContainerDefaults(application, service, project, container);

            return(application);
        }
Ejemplo n.º 2
0
        private static async Task <Application> InferApplicationForSolution(OutputContext output, FileInfo solutionFile, SolutionFile solution)
        {
            var globals = new ApplicationGlobals();

            globals.Name = Names.NormalizeToDns(Path.GetFileNameWithoutExtension(solutionFile.Name));

            var services = new List <ServiceEntry>();

            for (var i = 0; i < solution.ProjectsInOrder.Count; i++)
            {
                // The library we're using doesn't translate Windows style paths automatically.
                var solutionProject = solution.ProjectsInOrder[i];
                if (solutionProject.AbsolutePath.EndsWith(".csproj", StringComparison.Ordinal))
                {
                    var projectFilePath = solutionProject.RelativePath.Replace('\\', Path.DirectorySeparatorChar);
                    var projectFile     = new FileInfo(projectFilePath);

                    var name    = Path.GetFileNameWithoutExtension(projectFile.Name);
                    var project = new Project(projectFile.FullName);
                    var service = new ServiceEntry(new Service(name), name);
                    service.Service.Source = project;
                    services.Add(service);

                    await ProjectReader.ReadProjectDetailsAsync(output, projectFile, project);

                    var container = new ContainerInfo();
                    service.Service.GeneratedAssets.Container = container;
                }
            }

            var application = new GroveledApplication(globals, solutionFile.DirectoryName, services);

            foreach (var service in application.Services)
            {
                DockerfileGenerator.ApplyContainerDefaults(application, service, (Project)service.Service.Source !, service.Service.GeneratedAssets.Container !);
            }

            return(application);
        }