private void Run(IEnumerable <Project> projects, bool openSolution) { var prjs = projects.ToArray(); var context = buildContextFactory.CreateBuildContext(); // We have to emulate a real build at this point to make sure all the // graph transformations are executed correctly. // Then from the transformed graph we find the first sln builder and // run it. IBuilder rootBuilder = coreBuilderFactory.Merge( projectBuilders .OfType <VsProjectBuilderFactory>() .Select(pb => pb.Create(prjs)) .Where(b => b != null).ToArray(), new ProjectBuilderTag("Top level project builders", prjs)); if (rootBuilder != null) { context.AddBuilder(rootBuilder); var slnBuilder = context.Builders.OfType <SlnBuilder>().FirstOrDefault( builder => new HashSet <Project>(builder.Projects).IsSubsetOf(prjs)); if (slnBuilder == null) { throw new InvalidOperationException("Could not find a suitable SLN builder"); } var untilSlnBuilder = new MinimalBuilderFilter(slnBuilder); context.Run(rootBuilder, untilSlnBuilder.Filter); if (openSolution) { var slnRelativePath = context.GetResults(slnBuilder).FirstOrDefault(); if (slnRelativePath != null) { log.InfoFormat("Opening {0} with Visual Studio...", slnRelativePath); var localTargetDir = targetDir as LocalFileSystemDirectory; if (localTargetDir != null) { Process.Start(Path.Combine(localTargetDir.AbsolutePath, slnRelativePath)); } else { log.Warn("The --open command only works with local target directory!"); } } } } }
private void Run(IEnumerable<Project> projects, bool openSolution) { var prjs = projects.ToArray(); var context = buildContextFactory.CreateBuildContext(); // We have to emulate a real build at this point to make sure all the // graph transformations are executed correctly. // Then from the transformed graph we find the first sln builder and // run it. IBuilder rootBuilder = coreBuilderFactory.Merge( projectBuilders .OfType<VsProjectBuilderFactory>() .Select(pb => pb.Create(prjs)) .Where(b => b != null).ToArray(), new ProjectBuilderTag("Top level project builders", prjs)); if (rootBuilder != null) { context.AddBuilder(rootBuilder); var slnBuilder = context.Builders.OfType<SlnBuilder>().FirstOrDefault( builder => new HashSet<Project>(builder.Projects).IsSubsetOf(prjs)); if (slnBuilder == null) throw new InvalidOperationException("Could not find a suitable SLN builder"); var untilSlnBuilder = new MinimalBuilderFilter(slnBuilder); context.Run(rootBuilder, untilSlnBuilder.Filter); if (openSolution) { var slnRelativePath = context.GetResults(slnBuilder).FirstOrDefault(); if (slnRelativePath != null) { log.InfoFormat("Opening {0} with Visual Studio...", slnRelativePath); var localTargetDir = targetDir as LocalFileSystemDirectory; if (localTargetDir != null) { Process.Start(Path.Combine(localTargetDir.AbsolutePath, slnRelativePath)); } else { log.Warn("The --open command only works with local target directory!"); } } } } }