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}"); }
public void GivenThereIsASpecFlowProjectWithAReferenceToTheExternalLibrary(string language) { var project = projectGenerator.GenerateProject(inputProjectDriver); projectCompiler.Compile(project); List <string> assembliesToReference = new List <string>(); var libName = inputProjectDriver.CompiledAssemblyPath; var savedLibPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(libName)); File.Copy(libName, savedLibPath, true); assembliesToReference.Add(savedLibPath); foreach (var assemblyFileName in inputProjectDriver.FrameworkAssembliesToCopy) { var originalAssemblyPath = Path.Combine(inputProjectDriver.DeploymentFolder, assemblyFileName); var savedAssemblyPath = Path.Combine(Path.GetTempPath(), assemblyFileName); File.Copy(originalAssemblyPath, savedAssemblyPath, true); assembliesToReference.Add(savedAssemblyPath); } inputProjectDriver.Reset(); inputProjectDriver.ProjectName = "SpecFlow.TestProject"; inputProjectDriver.Language = language; foreach (var assemblyPath in assembliesToReference) { inputProjectDriver.References.Add(assemblyPath); } }
private void CompileInternal() { var project = projectGenerator.GenerateProject(inputProjectDriver); projectCompiler.Compile(project); _hooksDriver.EnsureInitialized(); }
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); } } }
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 void WhenTheFeatureFilesInTheProjectAreGenerated() { var project = projectGenerator.GenerateProject(inputProjectDriver); try { compilationError = null; projectCompiler.Compile(project, "UpdateFeatureFilesInProject"); } catch (Exception ex) { compilationError = ex; } }
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); } }
public void GivenThereIsASpecFlowProjectWithAReferenceToTheExternalLibrary() { var project = projectGenerator.GenerateProject(inputProjectDriver); projectCompiler.Compile(project); var libName = inputProjectDriver.CompiledAssemblyPath; var savedLibPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(libName)); File.Copy(libName, savedLibPath, true); inputProjectDriver.DefaultBindingClass.OtherBindings.Clear(); inputProjectDriver.DefaultBindingClass.StepBindings.Clear(); inputProjectDriver.ProjectName = "SpecFlow.TestProject"; inputProjectDriver.References.Add(savedLibPath); }
private void CompileInternal() { var project = projectGenerator.GenerateProject(inputProjectDriver); projectCompiler.Compile(project); }
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); }