public ProjectSteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler, HooksDriver hooksDriver) { this.inputProjectDriver = inputProjectDriver; this.projectCompiler = projectCompiler; _hooksDriver = hooksDriver; this.projectGenerator = projectGenerator; }
public static void CompileProject(string projectFile) { //ResourceCompiler resourceCompiler = InitCompiler(); Trace.WriteLine("Compile project \"{0}\"", projectFile); //ProjectCompiler projectCompiler = new ProjectCompiler(CompilerManager.Current.ResourceCompiler); ////compiler.SetParameters(GetRunSourceConfigCompilerDefaultValues(), runCode: true); //CompilerProjectReader compilerProject = CompilerProjectReader.Create(new XmlConfig(projectFile).GetConfigElementExplicit("/AssemblyProject")); //projectCompiler.SetParameters(compilerProject); //projectCompiler.SetProjectCompilerFile(compilerProject.GetProjectCompilerFile()); ProjectCompiler compiler = ProjectCompiler.Create(projectFile, CompilerManager.Current.Win32ResourceCompiler, CompilerManager.Current.ResourceCompiler); compiler.Compile(); compiler.TraceMessages(); //if (!compiler.HasError() && compiler.CopyRunSourceSourceFiles) //{ // string runsourceDirectory = GetRunSourceConfig().Get("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory()); // if (runsourceDirectory != null) // { // foreach (string directory in compiler.CopyOutputDirectories) // { // Trace.WriteLine(" copy runsource source files from \"{0}\" to \"{1}\"", runsourceDirectory, directory); // foreach (string file in zDirectory.EnumerateFiles(runsourceDirectory, "*" + Compiler.ZipSourceFilename)) // zfile.CopyFileToDirectory(file, directory, options: CopyFileOptions.OverwriteReadOnly | CopyFileOptions.CopyOnlyIfNewer); // } // } //} string withError = !compiler.Success ? " with error(s)" : ""; Trace.WriteLine($" compiled{withError} : {compiler.OutputAssembly}"); }
private static int Compile(string input, string outputPath) { string intermediateDirectory = Path.Combine(Path.GetDirectoryName(input), ".peu", Path.GetFileNameWithoutExtension(input)); string logPath = Path.Combine(intermediateDirectory, "compile.log"); ErrorCollection errors = new ErrorCollection(); ProjectFile project = ProjectFile.FromFile(input, errors); if (AssertErrors()) { return(1); } ProjectCompiler compiler = ProjectCompiler.Create ( project, intermediateDirectory, outputPath, errors ); compiler.Compile(); if (AssertErrors()) { return(1); } try { errors.WriteToConsole(); errors.ToFile(logPath); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Successfully compiled " + Path.GetFileName(outputPath) + " (" + new FileInfo(outputPath).Length + " bytes)."); } finally { Console.ResetColor(); Console.WriteLine(); } return(0); bool AssertErrors() { if (errors.HasErrors) { errors.WriteToConsole(); Directory.CreateDirectory(Path.GetDirectoryName(logPath)); errors.ToFile(logPath); return(true); } else { return(false); } } }
public bool CompileProjects(string projectsFile, string runsourceSourceDirectory = null) { return(ProjectCompiler.CompileProjects(GetPathProject(projectsFile), CompilerManager.Current.Win32ResourceCompiler, CompilerManager.Current.ResourceCompiler, runsourceSourceDirectory, onCompiled: compiler => { if (!compiler.Success) { SetResult(compiler.GetCompilerMessagesDataTable()); } })); }
public static async Task Main(string[] args) { MSBuildLocator.RegisterDefaults(); RootCommand rootCommand = Program.GenerateCommands(); rootCommand.Handler = CommandHandler.Create(async(bool generatePointsFile, bool runTests, DirectoryInfo? projectDir, FileInfo? outputFile) => { if (!generatePointsFile && !runTests) { Console.WriteLine("You didn't give me a task! Use --help for... help! Leave a like if you found out this to be useful!"); return; } string projectDirectory = projectDir?.FullName ?? Environment.CurrentDirectory; ProjectCompiler compiler = new ProjectCompiler(); ICollection <string> assemblyPaths; try { assemblyPaths = compiler.CompileTestProjects(projectDirectory); } catch (CompilationFaultedException exception) { Console.WriteLine(exception.Message); Environment.Exit(1); return; } TestProjectData projectData = new TestProjectData(); foreach (string assemblyPath in assemblyPaths) { projectData.LoadProject(assemblyPath); } if (generatePointsFile) { FileInfo resultsFile = outputFile ?? new FileInfo(Path.Combine(projectDirectory, ".tmc_available_points.json")); await WriteToFile(resultsFile, projectData.Points); } if (runTests) { ProjectTestRunner testRunner = new ProjectTestRunner(projectData); testRunner.RunAssemblies(projectData.Assemblies); FileInfo resultsFile = outputFile ?? new FileInfo(Path.Combine(projectDirectory, ".tmc_test_results.json")); await WriteToFile(resultsFile, testRunner.TestResults); }
internal override void Compile(ElobuddyAddon addon) { var logFileName = string.Format("compile_log_{0}.txt", addon.GetUniqueName()); var logFile = Path.Combine(Settings.Instance.Directories.TempDirectory, logFileName); var compileResult = ProjectCompiler.Compile(addon.ProjectFilePath, logFile); File.Delete(logFile); if (!compileResult.BuildSuccessful) { addon.SetState(AddonState.CompilingError); var logFileSavePath = Path.Combine(Settings.Instance.Directories.LogsDirectory, logFileName); File.WriteAllBytes(logFileSavePath, compileResult.LogFile); Log.Instance.DoLog(string.Format("Failed to compile project: \"{0}\". Build log file saved to \"{1}\".", addon.ProjectFilePath, logFileSavePath), Log.LogType.Error); } else { addon.SetState(AddonState.Ready); addon.Type = compileResult.Type; if (!addon.IsLocal) { var split = addon.Url.Split('/'); addon.Author = split.Length > 3 ? split[3] : ""; } var exePath = addon.GetOutputFilePath(); var pdpPath = Path.Combine(Path.GetDirectoryName(exePath), compileResult.PdbFileName ?? ""); FileHelper.SafeWriteAllBytes(exePath, compileResult.OutputFile); if (Settings.Instance.DeveloperMode && compileResult.PdbFile != null) { FileHelper.SafeWriteAllBytes(pdpPath, compileResult.PdbFile); } else if (File.Exists(pdpPath)) { try { File.Delete(pdpPath); } catch { // ignored } } addon.Version = FileVersionInfo.GetVersionInfo(exePath).FileVersion; Log.Instance.DoLog(string.Format("Successfully compiled project: \"{0}\".", addon.ProjectFilePath)); } }
public override int Run(string[] remainingArguments) { try { var compiler = new ProjectCompiler(ProjectPath); var projects = compiler.Compile(); return 0; } catch(CompileFailedException) { Console.WriteLine("Compile Failed, stopping"); return 1; } }
public override int Run(string[] remainingArguments) { try { var compiler = new ProjectCompiler(ProjectPath); var projects = compiler.Compile(); return(0); } catch (CompileFailedException) { Console.WriteLine("Compile Failed, stopping"); return(1); } }
// Returns ID public int Load(string projectSource) { int id = m_rand.Next(1, Int32.MaxValue); int oldid = 0; lock (m_ProjectsByID) { while (m_ProjectsByID.ContainsKey(id)) { id = m_rand.Next(1, Int32.MaxValue); } ProjectRunner runner; try { runner = new ProjectCompiler().Compile(projectSource); } catch (Exception ex) { Console.WriteLine(ex.Message); return(0); } string projectName = runner.Project.Name; m_Builds[id] = runner; m_ProjectsByID[id] = projectName; if (m_ProjectsByName.ContainsKey(projectName)) { oldid = m_ProjectsByName[projectName]; } m_ProjectsByName[projectName] = id; } if (oldid > 0) { Unload(oldid); } Console.WriteLine("Project " + m_ProjectsByID[id] + " loaded with ID: " + id.ToString()); SaveProject(m_ProjectsByID[id], projectSource); return(id); }
public string LoadErrors(string projectSource) { ProjectRunner runner; try { runner = new ProjectCompiler().Compile(projectSource); } catch (Exception ex) { return(ex.Message); } return(""); }
public IEnumerable <Page> Process(Project project) { var projectCompilerTask = ProjectCompiler.OpenProjectAsync(project.FullPath); projectCompilerTask.Wait(); var projectCompiler = projectCompilerTask.Result; var compilation = projectCompiler.Compile().Result; foreach (var syntaxTree in compilation.SyntaxTrees) { var model = compilation.GetSemanticModel(syntaxTree); } return(Enumerable.Empty <Page>()); }
public ExternalLibrarySteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler) { this.inputProjectDriver = inputProjectDriver; this.projectGenerator = projectGenerator; this.projectCompiler = projectCompiler; }
public GeneratorSteps(InputProjectDriver inputProjectDriver, ProjectGenerator projectGenerator, ProjectCompiler projectCompiler) { this.inputProjectDriver = inputProjectDriver; this.projectCompiler = projectCompiler; this.projectGenerator = projectGenerator; }
public static void CompileProjects(string projectsFile) { Trace.WriteLine("Compile projects \"{0}\"", projectsFile); ProjectCompiler.CompileProjects(projectsFile, CompilerManager.Current.Win32ResourceCompiler, CompilerManager.Current.ResourceCompiler, _runsourceSourceDirectory, onCompiled: compiler => { compiler.TraceMessages(); }); }
public async Task<Tuple<string, Project>> CompileProject(string projectFile) { var projectFileInfo = new FileInfo(projectFile); var projectFolder = projectFileInfo.Directory.FullName; // These two lines are just a weird hack because you get no files back from compilation.SyntaxTrees // if the user file isn't modified. Not sure why that's happening. // var projectUserFile = projectFolder + "\\" + projectFileInfo.Name + ".user"; // if (File.Exists(projectUserFile)) // File.SetLastWriteTime(projectUserFile, DateTime.Now); var jsCompilationUnit = new JsCompilationUnit { UseStrict = true }; var workspace = MSBuildWorkspace.Create(); var project = await Profiler.Time("Loading Project", async () => { string mscorlib = this.mscorlib; if (mscorlib == null) { mscorlib = FileUtils.GetWootzJsTargetFile(projectFile); } Project result; if (mscorlib != null) { var mscorlibProject = await workspace.OpenProjectAsync(mscorlib); result = await workspace.OpenProjectAsync(projectFile); result = result.AddProjectReference(new ProjectReference(mscorlibProject.Id)); result = result.RemoveMetadataReference(result.MetadataReferences.Single(x => x.Display.Contains("mscorlib.dll"))); } else { result = await workspace.OpenProjectAsync(projectFile); } return result; }); var projectCompiler = new ProjectCompiler(project, jsCompilationUnit, defines); await projectCompiler.Compile(); // Write out the compiled Javascript file to the target location. var renderer = new JsRenderer(); // renderer.Builder.IsCompacting = true; Profiler.Time("Rendering javascript", () => jsCompilationUnit.Accept(renderer)); return Tuple.Create(renderer.Output, project); }