Пример #1
0
        public void Build()
        {
            var outputLocation = Path.ChangeExtension(ProjectLocation, "js");

            var translator = new Bridge.Translator.Translator(ProjectLocation);

            translator.Log = LogMessage;
            //translator.Rebuild = true;

            LogInfo("\t\tProjectLocation: " + ProjectLocation);

            string configuration;

            translator.BridgeLocation = FindBridgeDllPath(out configuration);
            if (translator.BridgeLocation == null)
            {
                Bridge.Translator.Exception.Throw("Unable to determine Bridge project output path");
            }

            translator.BuildArguments = WrapBuildArguments(configuration);
            translator.Configuration  = configuration;

            LogInfo("\t\tBuildArguments: " + translator.BuildArguments);
            LogInfo("\t\tConfiguration: " + translator.Configuration);
            LogInfo("\t\tBridgeLocation: " + translator.BridgeLocation);

            translator.BuildAssembly();
        }
Пример #2
0
        public void Build()
        {
            var outputLocation = Path.ChangeExtension(ProjectLocation, "js");

            var translator = new Bridge.Translator.Translator(ProjectLocation);

            translator.Log = LogMessage;
            //translator.Rebuild = true;

            LogInfo("\t\tProjectLocation: " + ProjectLocation);

            string configuration;
            translator.BridgeLocation = FindBridgeDllPath(out configuration);
            if (translator.BridgeLocation == null)
            {
                Bridge.Translator.Exception.Throw("Unable to determine Bridge project output path");
            }

            translator.BuildArguments = WrapBuildArguments(configuration);
            translator.Configuration = configuration;

            LogInfo("\t\tBuildArguments: " + translator.BuildArguments);
            LogInfo("\t\tConfiguration: " + translator.Configuration);
            LogInfo("\t\tBridgeLocation: " + translator.BridgeLocation);

            translator.BuildAssembly();
        }
Пример #3
0
        public override bool Execute()
        {
            var success = true;

#if DEBUG
            if (AttachDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            }
            ;
#endif

            Bridge.Translator.Translator translator = null;
            try
            {
                translator = new Bridge.Translator.Translator(this.ProjectPath);
                translator.Configuration  = this.Configuration;
                translator.BridgeLocation = Path.Combine(this.AssembliesPath, "Bridge.dll");
                translator.Rebuild        = false;
                translator.ChangeCase     = this.ChangeCase;
                translator.Log            = this.LogMessage;
                translator.Translate();

                string fileName = Path.GetFileNameWithoutExtension(this.Assembly.ItemSpec);

                string outputPath = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output)
                    ? Path.Combine(Path.GetDirectoryName(this.ProjectPath), translator.AssemblyInfo.Output)
                    : this.OutputPath;

                translator.SaveTo(outputPath, fileName);

                if (!this.NoCore)
                {
                    Bridge.Translator.Translator.ExtractCore(translator, outputPath);
                }
            }
            catch (EmitterException e)
            {
                this.Log.LogError(null, null, null, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                success = false;
            }
            catch (Exception e)
            {
                var ee = translator != null?translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    this.Log.LogError(null, null, null, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                }
                else
                {
                    this.Log.LogError("Error: {0} {1}", e.Message, e.StackTrace);
                }

                success = false;
            }

            return(success);
        }
Пример #4
0
        public string Translate()
        {
            var outputLocation = Path.ChangeExtension(ProjectLocation, "js");

            var translator = new Bridge.Translator.Translator(ProjectLocation);

            translator.Log     = this.Logger;
            translator.Rebuild = true;

            this.Logger.Info("\t\tProjectLocation: " + ProjectLocation);

            string configuration;

            translator.BridgeLocation = FindBridgeDllPath(out configuration);

            if (translator.BridgeLocation == null)
            {
                Bridge.Translator.Exception.Throw("Unable to determine Bridge project output path by configuration " + configuration);
            }

            translator.BuildArguments = WrapBuildArguments(configuration);
            translator.Configuration  = configuration;

            this.Logger.Info("\t\tBuildArguments: " + translator.BuildArguments);
            this.Logger.Info("\t\tConfiguration: " + translator.Configuration);
            this.Logger.Info("\t\tBridgeLocation: " + translator.BridgeLocation);

            translator.Translate();

            string path = Path.GetDirectoryName(outputLocation);

            string outputDir = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ?
                               Path.Combine(Path.GetDirectoryName(ProjectLocation), translator.AssemblyInfo.Output) :
                               path;

            this.Logger.Info("\t\toutputDir: " + outputDir);
            translator.SaveTo(outputDir, Path.GetFileNameWithoutExtension(outputLocation));

            return(outputDir);
        }
Пример #5
0
        public override bool Execute()
        {
            var success = true;

            try
            {
                var translator = new Bridge.Translator.Translator(this.ProjectPath);
                translator.Configuration  = this.Configuration;
                translator.BridgeLocation = Path.Combine(this.AssembliesPath, "Bridge.dll");
                translator.Rebuild        = false;
                translator.ChangeCase     = this.ChangeCase;
                translator.Log            = this.LogMessage;
                translator.Translate();

                string fileName = Path.GetFileNameWithoutExtension(this.Assembly.ItemSpec);

                string outputPath = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ?
                                    Path.Combine(Path.GetDirectoryName(this.ProjectPath), translator.AssemblyInfo.Output) :
                                    this.OutputPath;

                translator.SaveTo(outputPath, fileName);

                if (!this.NoCore)
                {
                    Bridge.Translator.Translator.ExtractCore(translator.BridgeLocation, outputPath);
                }

                if (!string.IsNullOrWhiteSpace(translator.AssemblyInfo.AfterBuild))
                {
                    translator.RunEvent(translator.AssemblyInfo.AfterBuild);
                }
            }
            catch (Exception e)
            {
                this.Log.LogError("Error: {0}", e.Message);
                success = false;
            }

            return(success);
        }
Пример #6
0
        public string Translate()
        {
            var outputLocation = Path.ChangeExtension(ProjectLocation, "js");

            var translator = new Bridge.Translator.Translator(ProjectLocation);

            translator.Log = LogMessage;
            translator.Rebuild = true;

            LogInfo("\t\tProjectLocation: " + ProjectLocation);

            string configuration;
            translator.BridgeLocation = FindBridgeDllPath(out configuration);

            if (translator.BridgeLocation == null)
            {
                Bridge.Translator.Exception.Throw("Unable to determine Bridge project output path by configuration " + configuration);
            }

            translator.BuildArguments = WrapBuildArguments(configuration);
            translator.Configuration = configuration;

            LogInfo("\t\tBuildArguments: " + translator.BuildArguments);
            LogInfo("\t\tConfiguration: " + translator.Configuration);
            LogInfo("\t\tBridgeLocation: " + translator.BridgeLocation);

            translator.Translate();

            string path = Path.GetDirectoryName(outputLocation);

            string outputDir = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ?
                                    Path.Combine(Path.GetDirectoryName(ProjectLocation), translator.AssemblyInfo.Output) :
                                    path;

            LogInfo("\t\toutputDir: " + outputDir);
            translator.SaveTo(outputDir, Path.GetFileNameWithoutExtension(outputLocation));

            return outputDir;
        }
Пример #7
0
        static void Main(string[] args)
        {
            string projectLocation = null;
            string outputLocation = null;
            string bridgeLocation = null;
            bool rebuild = false;
            bool extractCore = true;
            string cfg = null;
            string source = null;
            string folder = Environment.CurrentDirectory;
            bool recursive = false;
            string lib = null;
            string def = null;

            if (args.Length == 0)
            {
                Console.WriteLine("Bridge.Builder commands:");
                Console.WriteLine("-p or -project           Path to csproj file (required)");
                Console.WriteLine("-o or -output            Output directory for generated script");
                Console.WriteLine("-cfg or -configuration   Configuration name, typically Debug/Release");
                Console.WriteLine("-r or -rebuild           Force assembly rebuilding");
                Console.WriteLine("-nocore                  Do not extract core javascript files");
                Console.WriteLine("-def or -define          Defines project constants. For example, \"CONSTANT1;CONSTANT2\" ");
            #if DEBUG
                // This code and logic is only compiled in when building bridge.net in Debug configuration
                Console.WriteLine("-d or -debug             Attach the builder to an visual studio debugging instance.");
                Console.WriteLine("                         Use this to attach the process to an open Bridge.NET solution.");
                Console.WriteLine("                         This option is equivalent to Build.dll's 'AttachDebugger'.");
            #endif
                Console.WriteLine("");
                return;
            }

            int i = 0;

            while (i < args.Length)
            {
                switch (args[i])
                {
                    case "-p":
                    case "-project":
                        projectLocation = args[++i];
                        break;
                    case "-b":
                    case "-bridge":
                        bridgeLocation = args[++i];
                        break;
                    case "-o":
                    case "-output":
                        outputLocation = args[++i];
                        break;
                    case "-cfg":
                    case "-configuration":
                        cfg = args[++i];
                        break;
                    case "-def":
                    case "-define":
                        def = args[++i];
                        break;
                    case "-rebuild":
                    case "-r":
                        rebuild = true;
                        break;
                    case "-nocore":
                        extractCore = false;
                        break;
                    case "-src":
                        source = args[++i];
                        break;
                    case "-folder":
                        folder = Path.Combine(Environment.CurrentDirectory, args[++i]);
                        break;
                    case "-recursive":
                        recursive = true;
                        break;
                    case "-lib":
                        lib = args[++i];
                        break;
            #if DEBUG
                    case "-debug":
                    case "-attachdebugger":
                    case "-d":
                        System.Diagnostics.Debugger.Launch();
                        break;
            #endif
                    default:
                        Console.WriteLine("Unknown command: " + args[i]);
                        return;
                }

                i++;
            }

            if (string.IsNullOrEmpty(outputLocation))
            {
                outputLocation = !string.IsNullOrWhiteSpace(projectLocation) ? Path.GetFileNameWithoutExtension(projectLocation) : folder;
            }

            Bridge.Translator.Translator translator = null;
            try
            {
                Console.WriteLine("Generating script...");

                if (!string.IsNullOrWhiteSpace(projectLocation))
                {
                    translator = new Bridge.Translator.Translator(projectLocation);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(lib))
                    {
                        throw new Exception("Please define path to assembly using -lib option");
                    }

                    lib = Path.Combine(folder, lib);
                    translator = new Bridge.Translator.Translator(folder, source, recursive, lib);
                }

                bridgeLocation = !string.IsNullOrEmpty(bridgeLocation) ? bridgeLocation : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bridge.dll");

                translator.BridgeLocation = bridgeLocation;
                translator.Rebuild = rebuild;
                translator.Log = LogMessage;
                translator.Configuration = cfg;
                if (def != null)
                {
                    translator.DefineConstants.AddRange(def.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                    translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
                }
                translator.Translate();

                string path = string.IsNullOrWhiteSpace(Path.GetFileName(outputLocation)) ? outputLocation : Path.GetDirectoryName(outputLocation);
                string outputPath = null;

                if (!string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output))
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(projectLocation) ? Path.GetDirectoryName(projectLocation) : folder, translator.AssemblyInfo.Output);
                }
                else
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(projectLocation) ? Path.GetDirectoryName(projectLocation) : folder, !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ? translator.AssemblyInfo.Output : path);
                }

                if (translator.AssemblyInfo != null && translator.AssemblyInfo.CleanOutputFolderBeforeBuild)
                {
                    Console.WriteLine("Cleaning output folder before extracting scripts...");
                    CleanDirectory(outputPath);
                }

                if (extractCore)
                {
                    Console.WriteLine("Extracting core scripts...");
                    Bridge.Translator.Translator.ExtractCore(translator, outputPath);
                }

                translator.Plugins.AfterOutput(translator, outputPath, !extractCore);

                Console.WriteLine("Saving to " + outputPath);
                translator.SaveTo(outputPath, Path.GetFileName(outputLocation));

                Console.WriteLine("Done.");
            }
            catch (EmitterException e)
            {
                Console.WriteLine("{2} ({3}, {4}) Error: {0} {1}", e.Message, e.StackTrace, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1);
            }
            catch (Exception e)
            {
                var ee = translator != null ? translator.CreateExceptionFromLastNode() : null;
                Console.ForegroundColor = ConsoleColor.Red;

                if (ee != null)
                {
                    Console.WriteLine("{2} ({3}, {4}) Error: {0} {1}", e.Message, e.StackTrace, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1);
                }
                else
                {
                    // Iteractively print inner exceptions
                    var ine = e;
                    var elvl = 0;
                    while (ine != null)
                    {
                        Console.WriteLine("Error: exception level: {0} - {1}\nStack trace:\n{2}", elvl++, ine.Message, ine.StackTrace);
                        ine = ine.InnerException;
                    }
                }

                Console.ResetColor();
                Console.ReadLine();
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            string projectLocation = null;
            string outputLocation  = null;
            string bridgeLocation  = null;
            bool   rebuild         = false;
            bool   extractCore     = true;
            bool   changeCase      = true;
            string cfg             = null;
            string source          = null;
            string folder          = Environment.CurrentDirectory;
            bool   recursive       = false;
            string lib             = null;

            if (args.Length == 0)
            {
                Console.WriteLine("Bridge.Builder commands:");
                Console.WriteLine("-p or -project           Path to csproj file (required)");
                Console.WriteLine("-o or -output            Output directory for generated script");
                Console.WriteLine("-cfg or -configuration   Configuration name, typically Debug/Release");
                Console.WriteLine("-r or -rebuild           Force assembly rebuilding");
                Console.WriteLine("-nocore                  Do not extract core javascript files");
                Console.WriteLine("-c or -case              Do not change case of members");
#if DEBUG
                // This code and logic is only compiled in when building bridge.net in Debug configuration
                Console.WriteLine("-d or -debug             Attach the builder to an visual studio debugging instance.");
                Console.WriteLine("                         Use this to attach the process to an open Bridge.NET solution.");
                Console.WriteLine("                         This option is equivalent to Build.dll's 'AttachDebugger'.");
#endif
                Console.WriteLine("");
                return;
            }

            int i = 0;

            while (i < args.Length)
            {
                switch (args[i])
                {
                case "-p":
                case "-project":
                    projectLocation = args[++i];
                    break;

                case "-b":
                case "-bridge":
                    bridgeLocation = args[++i];
                    break;

                case "-o":
                case "-output":
                    outputLocation = args[++i];
                    break;

                case "-cfg":
                case "-configuration":
                    cfg = args[++i];
                    break;

                case "-rebuild":
                case "-r":
                    rebuild = true;
                    break;

                case "-case":
                case "-c":
                    changeCase = false;
                    break;

                case "-nocore":
                    extractCore = false;
                    break;

                case "-src":
                    source = args[++i];
                    break;

                case "-folder":
                    folder = Path.Combine(Environment.CurrentDirectory, args[++i]);
                    break;

                case "-recursive":
                    recursive = true;
                    break;

                case "-lib":
                    lib = args[++i];
                    break;

#if DEBUG
                case "-debug":
                case "-attachdebugger":
                case "-d":
                    System.Diagnostics.Debugger.Launch();
                    break;
#endif
                default:
                    Console.WriteLine("Unknown command: " + args[i]);
                    return;
                }

                i++;
            }

            if (string.IsNullOrEmpty(outputLocation))
            {
                outputLocation = !string.IsNullOrWhiteSpace(projectLocation) ? Path.GetFileNameWithoutExtension(projectLocation) : folder;
            }

            Bridge.Translator.Translator translator = null;
            try
            {
                Console.WriteLine("Generating script...");

                if (!string.IsNullOrWhiteSpace(projectLocation))
                {
                    translator = new Bridge.Translator.Translator(projectLocation);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(lib))
                    {
                        throw new Exception("Please define path to assembly using -lib option");
                    }

                    lib        = Path.Combine(folder, lib);
                    translator = new Bridge.Translator.Translator(folder, source, recursive, lib);
                }

                bridgeLocation = !string.IsNullOrEmpty(bridgeLocation) ? bridgeLocation : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bridge.dll");

                translator.BridgeLocation = bridgeLocation;
                translator.Rebuild        = rebuild;
                translator.ChangeCase     = changeCase;
                translator.Log            = LogMessage;
                translator.Configuration  = cfg;
                translator.Translate();

                string path       = string.IsNullOrWhiteSpace(Path.GetFileName(outputLocation)) ? outputLocation : Path.GetDirectoryName(outputLocation);
                string outputPath = null;

                if (!string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output))
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(projectLocation) ? Path.GetDirectoryName(projectLocation) : folder, translator.AssemblyInfo.Output);
                }
                else
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(projectLocation) ? Path.GetDirectoryName(projectLocation) : folder, !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ? translator.AssemblyInfo.Output : path);
                }

                Console.WriteLine("Saving to " + outputPath);
                translator.SaveTo(outputPath, Path.GetFileName(outputLocation));

                if (extractCore)
                {
                    Console.WriteLine("Extracting core scripts...");
                    Bridge.Translator.Translator.ExtractCore(translator, outputPath);
                }

                Console.WriteLine("Done.");
            }
            catch (EmitterException e)
            {
                Console.WriteLine("{2} ({3}, {4}) Error: {0} {1}", e.Message, e.StackTrace, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1);
            }
            catch (Exception e)
            {
                var ee = translator != null?translator.CreateExceptionFromLastNode() : null;

                Console.ForegroundColor = ConsoleColor.Red;

                if (ee != null)
                {
                    Console.WriteLine("{2} ({3}, {4}) Error: {0} {1}", e.Message, e.StackTrace, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1);
                }
                else
                {
                    // Iteractively print inner exceptions
                    var ine  = e;
                    var elvl = 0;
                    while (ine != null)
                    {
                        Console.WriteLine("Error: exception level: {0} - {1}\nStack trace:\n{2}", elvl++, ine.Message, ine.StackTrace);
                        ine = ine.InnerException;
                    }
                }

                Console.ResetColor();
                Console.ReadLine();
            }
        }
Пример #9
0
        private static void Main(string[] args)
        {
            var logger = new Logger(null, true, new ConsoleLoggerWriter(), SimpleFileLoggerWriter.Instance);

            string projectLocation = null;
            string outputLocation  = null;
            string bridgeLocation  = null;
            bool   rebuild         = false;
            bool   extractCore     = true;
            string cfg             = null;
            string source          = null;
            string folder          = Environment.CurrentDirectory;
            bool   recursive       = false;
            string lib             = null;
            string def             = null;

            if (args.Length == 0)
            {
                logger.Info("Bridge.Builder commands:");
                logger.Info("-p or -project           Path to csproj file (required)");
                logger.Info("-o or -output            Output directory for generated script");
                logger.Info("-cfg or -configuration   Configuration name, typically Debug/Release");
                logger.Info("-r or -rebuild           Force assembly rebuilding");
                logger.Info("-nocore                  Do not extract core javascript files");
                logger.Info("-def or -define          Defines project constants. For example, \"CONSTANT1;CONSTANT2\" ");
#if DEBUG
                // This code and logic is only compiled in when building bridge.net in Debug configuration
                logger.Info("-d or -debug             Attach the builder to an visual studio debugging instance.");
                logger.Info("                         Use this to attach the process to an open Bridge.NET solution.");
                logger.Info("                         This option is equivalent to Build.dll's 'AttachDebugger'.");
#endif
                logger.Info("");
                return;
            }

            int i = 0;

            while (i < args.Length)
            {
                switch (args[i])
                {
                case "-p":
                case "-project":
                    projectLocation = args[++i];
                    break;

                case "-b":
                case "-bridge":
                    bridgeLocation = args[++i];
                    break;

                case "-o":
                case "-output":
                    outputLocation = args[++i];
                    break;

                case "-cfg":
                case "-configuration":
                    cfg = args[++i];
                    break;

                case "-def":
                case "-define":
                    def = args[++i];
                    break;

                case "-rebuild":
                case "-r":
                    rebuild = true;
                    break;

                case "-nocore":
                    extractCore = false;
                    break;

                case "-src":
                    source = args[++i];
                    break;

                case "-folder":
                    folder = Path.Combine(Environment.CurrentDirectory, args[++i]);
                    break;

                case "-recursive":
                    recursive = true;
                    break;

                case "-lib":
                    lib = args[++i];
                    break;

#if DEBUG
                case "-debug":
                case "-attachdebugger":
                case "-d":
                    System.Diagnostics.Debugger.Launch();
                    break;
#endif
                default:
                    logger.Info("Unknown command: " + args[i]);
                    return;
                }

                i++;
            }

            if (string.IsNullOrEmpty(outputLocation))
            {
                outputLocation = !string.IsNullOrWhiteSpace(projectLocation) ? Path.GetFileNameWithoutExtension(projectLocation) : folder;
            }

            Bridge.Translator.Translator translator = null;
            try
            {
                logger.Name = "Bridge.Builder.Console";

                logger.Info("Generating script...");

                logger.Info("Command line arguments:");
                logger.Info("\t" + (string.Join(" ", args) ?? ""));

                if (!string.IsNullOrWhiteSpace(projectLocation))
                {
                    translator = new Bridge.Translator.Translator(projectLocation);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(lib))
                    {
                        throw new Exception("Please define path to assembly using -lib option");
                    }

                    lib        = Path.Combine(folder, lib);
                    translator = new Bridge.Translator.Translator(folder, source, recursive, lib);
                }

                bridgeLocation = !string.IsNullOrEmpty(bridgeLocation) ? bridgeLocation : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bridge.dll");

                translator.BridgeLocation = bridgeLocation;
                translator.Rebuild        = rebuild;
                translator.Log            = logger;
                translator.Configuration  = cfg;
                if (def != null)
                {
                    translator.DefineConstants.AddRange(def.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                    translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
                }

                translator.Log.Info("Translator properties:");
                translator.Log.Info("\tBridgeLocation:" + translator.BridgeLocation ?? "");
                translator.Log.Info("\tBuildArguments:" + translator.BuildArguments ?? "");
                translator.Log.Info("\tConfiguration:" + translator.Configuration ?? "");
                translator.Log.Info("\tDefineConstants:" + (translator.DefineConstants != null  ? string.Join(" ", translator.DefineConstants) :  ""));
                translator.Log.Info("\tRebuild:" + translator.Rebuild);

                translator.Translate();

                string path       = string.IsNullOrWhiteSpace(Path.GetFileName(outputLocation)) ? outputLocation : Path.GetDirectoryName(outputLocation);
                string outputPath = null;

                if (!string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output))
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(projectLocation) ? Path.GetDirectoryName(projectLocation) : folder, translator.AssemblyInfo.Output);
                }
                else
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(projectLocation) ? Path.GetDirectoryName(projectLocation) : folder, !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ? translator.AssemblyInfo.Output : path);
                }

                translator.CleanOutputFolderIfRequired(outputPath);

                if (extractCore)
                {
                    logger.Info("Extracting core scripts...");
                    translator.ExtractCore(outputPath);
                }

                logger.Info("Saving to " + outputPath);
                translator.SaveTo(outputPath, Path.GetFileName(outputLocation));
                translator.Flush(outputPath, Path.GetFileName(outputLocation));
                translator.Plugins.AfterOutput(translator, outputPath, !extractCore);

                logger.Info("Done translation console");
            }
            catch (EmitterException ex)
            {
                logger.Error(string.Format("Error: {2} ({3}, {4}) {0} {1}", ex.Message, ex.StackTrace, ex.FileName, ex.StartLine, ex.StartColumn, ex.EndLine, ex.EndColumn));
            }
            catch (Exception ex)
            {
                var ee = translator != null?translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    logger.Error(string.Format("Error: {2} ({3}, {4}) {0} {1}", ex.Message, ex.StackTrace, ee.FileName, ee.StartLine, ee.StartColumn, ee.EndLine, ee.EndColumn));
                }
                else
                {
                    // Iteractively print inner exceptions
                    var ine  = ex;
                    var elvl = 0;
                    while (ine != null)
                    {
                        logger.Error(string.Format("Error: exception level: {0} - {1}\nStack trace:\n{2}", elvl++, ine.Message, ine.StackTrace));
                        ine = ine.InnerException;
                    }
                }

                Console.ReadLine();
            }
        }
Пример #10
0
        static void Main(string[] args)
        {
            string projectLocation = null;
            string outputLocation  = null;
            string bridgeLocation  = null;
            bool   rebuild         = false;
            bool   extractCore     = true;
            bool   changeCase      = true;
            string cfg             = null;

            if (args.Length == 0)
            {
                Console.WriteLine("Bridge.Builder commands:");
                Console.WriteLine("-p or -project           Path to csproj file (required)");
                Console.WriteLine("-o or -output            Output directory for generated script");
                Console.WriteLine("-cfg or -configuration   Configuration name, typically Debug/Release");
                Console.WriteLine("-r or -rebuild           Force assembly rebuilding");
                Console.WriteLine("-nocore                  Do not extract core javascript files");
                Console.WriteLine("-c or -case              Do not change case of members");
#if DEBUG
                // This code and logic is only compiled in when building bridge.net in Debug configuration
                Console.WriteLine("-d or -debug             Attach the builder to an visual studio debugging instance.");
                Console.WriteLine("                         Use this to attach the process to an open Bridge.NET solution.");
#endif
                Console.WriteLine("");
                return;
            }

            int i = 0;

            while (i < args.Length)
            {
                switch (args[i])
                {
                case "-p":
                case "-project":
                    projectLocation = args[++i];
                    break;

                case "-b":
                case "-bridge":
                    bridgeLocation = args[++i];
                    break;

                case "-o":
                case "-output":
                    outputLocation = args[++i];
                    break;

                case "-cfg":
                case "-configuration":
                    cfg = args[++i];
                    break;

                case "-rebuild":
                case "-r":
                    rebuild = true;
                    break;

                case "-case":
                case "-c":
                    changeCase = false;
                    break;

                case "-nocore":
                    extractCore = false;
                    break;

#if DEBUG
                case "-debug":
                case "-d":
                    System.Diagnostics.Debugger.Launch();
                    break;
#endif
                default:
                    Console.WriteLine("Unknown command: " + args[i]);
                    return;
                }

                i++;
            }

            if (string.IsNullOrEmpty(projectLocation))
            {
                Console.WriteLine("Project location is empty, please define argument with -p command");
                return;
            }

            if (!File.Exists(projectLocation))
            {
                Console.WriteLine("Project file doesn't exist: " + projectLocation);
                return;
            }

            if (string.IsNullOrEmpty(outputLocation))
            {
                outputLocation = Path.GetFileNameWithoutExtension(projectLocation);
            }

            try
            {
                Console.WriteLine("Generating script...");
                var translator = new Bridge.Translator.Translator(projectLocation);

                bridgeLocation = !string.IsNullOrEmpty(bridgeLocation) ? bridgeLocation : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bridge.dll");

                translator.BridgeLocation = bridgeLocation;
                translator.Rebuild        = rebuild;
                translator.ChangeCase     = changeCase;
                translator.Log            = LogMessage;
                translator.Configuration  = cfg;
                translator.Translate();

                string path       = string.IsNullOrWhiteSpace(Path.GetFileName(outputLocation)) ? outputLocation : Path.GetDirectoryName(outputLocation);
                string outputPath = Path.Combine(Path.GetDirectoryName(projectLocation), !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ? translator.AssemblyInfo.Output : path);

                translator.SaveTo(outputPath, Path.GetFileName(outputLocation));

                if (extractCore)
                {
                    Console.WriteLine("Extracting core scripts...");
                    Bridge.Translator.Translator.ExtractCore(translator.BridgeLocation, outputPath);
                }

                Console.WriteLine("Done.");

                if (!string.IsNullOrWhiteSpace(translator.AssemblyInfo.AfterBuild))
                {
                    translator.RunEvent(translator.AssemblyInfo.AfterBuild);
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error: {0}", e.Message);
                Console.ResetColor();
                Console.ReadLine();
            }
        }
Пример #11
0
        public override bool Execute()
        {
            var success = true;

            #if DEBUG
            if (AttachDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            };
            #endif

            Bridge.Translator.Translator translator = null;
            try
            {
                translator = new Bridge.Translator.Translator(this.ProjectPath);
                translator.Configuration = this.Configuration;
                translator.BridgeLocation = Path.Combine(this.AssembliesPath, "Bridge.dll");
                translator.Rebuild = false;
                translator.ChangeCase = this.ChangeCase;
                translator.Log = this.LogMessage;
                translator.Translate();

                string fileName = Path.GetFileNameWithoutExtension(this.Assembly.ItemSpec);

                string outputPath = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output)
                    ? Path.Combine(Path.GetDirectoryName(this.ProjectPath), translator.AssemblyInfo.Output)
                    : this.OutputPath;

                translator.SaveTo(outputPath, fileName);

                if (!this.NoCore)
                {
                    Bridge.Translator.Translator.ExtractCore(translator, outputPath);
                }
            }
            catch (EmitterException e)
            {
                this.Log.LogError(null, null, null, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                success = false;
            }
            catch (Exception e)
            {
                var ee = translator != null ? translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    this.Log.LogError(null, null, null, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                }
                else
                {
                    this.Log.LogError("Error: {0} {1}", e.Message, e.StackTrace);
                }

                success = false;
            }

            return success;
        }
Пример #12
0
        public override bool Execute()
        {
            var success = true;

#if DEBUG
            if (AttachDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            }
            ;
#endif

            Bridge.Translator.Translator translator = null;
            try
            {
                translator = new Bridge.Translator.Translator(this.ProjectPath, true);
                translator.Configuration = this.Configuration;

                if (this.DefineConstants != null)
                {
                    translator.DefineConstants.AddRange(this.DefineConstants.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                    translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
                }

                translator.BridgeLocation = Path.Combine(this.AssembliesPath, "Bridge.dll");
                translator.Rebuild        = false;
                translator.Log            = new Translator.Logging.Logger("Bridge.Build.Task", true, new ConsoleLoggerWriter(), SimpleFileLoggerWriter.Instance);
                translator.Translate();

                string fileName = Path.GetFileNameWithoutExtension(this.Assembly.ItemSpec);

                string outputPath = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output)
                    ? Path.Combine(Path.GetDirectoryName(this.ProjectPath), translator.AssemblyInfo.Output)
                    : this.OutputPath;

                if (translator.AssemblyInfo != null && translator.AssemblyInfo.CleanOutputFolderBeforeBuild)
                {
                    Console.WriteLine("Cleaning output folder before extracting scripts...");
                    CleanDirectory(outputPath);
                }

                if (!this.NoCore)
                {
                    translator.ExtractCore(outputPath);
                }
                translator.SaveTo(outputPath, fileName);
                translator.Flush(outputPath, fileName);
                translator.Plugins.AfterOutput(translator, outputPath, this.NoCore);
            }
            catch (EmitterException e)
            {
                this.Log.LogError(null, null, null, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                success = false;
            }
            catch (Exception e)
            {
                var ee = translator != null?translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    this.Log.LogError(null, null, null, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                }
                else
                {
                    this.Log.LogError("Error: {0} {1}", e.Message, e.StackTrace);
                }

                success = false;
            }

            return(success);
        }
Пример #13
0
        private Translator SetTranslatorProperties()
        {
            var logger         = this.Logger;
            var bridgeOptions  = this.BridgeOptions;
            var assemblyConfig = this.TranslatorConfiguration;

            logger.Trace("Setting translator properties...");

            Bridge.Translator.Translator translator = null;

            // FIXME: detect by extension whether first argument is a project or DLL
            if (!bridgeOptions.IsFolderMode)
            {
                translator = new Bridge.Translator.Translator(bridgeOptions.ProjectLocation, bridgeOptions.Sources, bridgeOptions.FromTask);
            }
            else
            {
                if (string.IsNullOrWhiteSpace(bridgeOptions.Lib))
                {
                    throw new InvalidOperationException("Please define path to assembly using -lib option");
                }

                bridgeOptions.Lib = Path.Combine(bridgeOptions.Folder, bridgeOptions.Lib);
                translator        = new Bridge.Translator.Translator(bridgeOptions.Folder, bridgeOptions.Sources, bridgeOptions.Recursive, bridgeOptions.Lib);
            }

            translator.ProjectProperties = bridgeOptions.ProjectProperties;

            translator.AssemblyInfo = assemblyConfig;

            if (this.BridgeOptions.ReferencesPath != null)
            {
                translator.AssemblyInfo.ReferencesPath = this.BridgeOptions.ReferencesPath;
            }

            translator.OverflowMode = bridgeOptions.ProjectProperties.CheckForOverflowUnderflow.HasValue ?
                                      (bridgeOptions.ProjectProperties.CheckForOverflowUnderflow.Value ? OverflowMode.Checked : OverflowMode.Unchecked) : (OverflowMode?)null;

            if (string.IsNullOrEmpty(bridgeOptions.BridgeLocation))
            {
                bridgeOptions.BridgeLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bridge.dll");
            }

            translator.BridgeLocation = bridgeOptions.BridgeLocation;
            translator.Rebuild        = bridgeOptions.Rebuild;
            translator.Log            = logger;

            if (bridgeOptions.ProjectProperties.DefineConstants != null)
            {
                translator.DefineConstants.AddRange(bridgeOptions.ProjectProperties.DefineConstants.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
            }

            translator.Log.Trace("Translator properties:");
            translator.Log.Trace("\tBridgeLocation:" + translator.BridgeLocation);
            translator.Log.Trace("\tBuildArguments:" + translator.BuildArguments);
            translator.Log.Trace("\tDefineConstants:" + (translator.DefineConstants != null ? string.Join(" ", translator.DefineConstants) : ""));
            translator.Log.Trace("\tRebuild:" + translator.Rebuild);
            translator.Log.Trace("\tProjectProperties:" + translator.ProjectProperties);

            if (translator.FolderMode)
            {
                translator.ReadFolderFiles();

                if (!string.IsNullOrEmpty(assemblyConfig.FileName))
                {
                    translator.DefaultNamespace = Path.GetFileNameWithoutExtension(assemblyConfig.FileName);
                }
                else
                {
                    translator.DefaultNamespace = bridgeOptions.DefaultFileName;
                }
            }
            else
            {
                translator.EnsureProjectProperties();
            }

            translator.ApplyProjectPropertiesToConfig();

            logger.Trace("Setting translator properties done");

            return(translator);
        }
Пример #14
0
        private static int Main(string[] args)
        {
            var logger = new Logger(null, false, LoggerLevel.Trace, new ConsoleLoggerWriter(), new SimpleFileLoggerWriter());

            var bridgeOptions = GetBridgeOptionsFromCommandLine(args, logger);

            if (bridgeOptions == null)
            {
                return(1);
            }

            if (bridgeOptions.Help)
            {
                return(0);
            }

            logger.Name         = "Bridge.Builder.Console";
            logger.UseTimeStamp = !bridgeOptions.NoTimeStamp;

            logger.Info("Command line arguments:");
            logger.Info("\t" + (string.Join(" ", args) ?? ""));

            logger.Info("Generating script...");

            Bridge.Translator.Translator translator = null;

            try
            {
                // FIXME: detect by extension whether first argument is a project or DLL
                if (!string.IsNullOrWhiteSpace(bridgeOptions.ProjectLocation))
                {
                    translator = new Bridge.Translator.Translator(bridgeOptions.ProjectLocation);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(bridgeOptions.Lib))
                    {
                        throw new Exception("Please define path to assembly using -lib option");
                    }

                    bridgeOptions.Lib = Path.Combine(bridgeOptions.Folder, bridgeOptions.Lib);
                    translator        = new Bridge.Translator.Translator(bridgeOptions.Folder, bridgeOptions.Source, bridgeOptions.Recursive, bridgeOptions.Lib);
                }

                bridgeOptions.BridgeLocation = !string.IsNullOrEmpty(bridgeOptions.BridgeLocation) ? bridgeOptions.BridgeLocation : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bridge.dll");

                translator.BridgeLocation = bridgeOptions.BridgeLocation;
                translator.Rebuild        = bridgeOptions.Rebuild;
                translator.Log            = logger;
                translator.Configuration  = bridgeOptions.Cfg;
                if (bridgeOptions.Def != null)
                {
                    translator.DefineConstants.AddRange(bridgeOptions.Def.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                    translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
                }

                translator.Log.Info("Translator properties:");
                translator.Log.Info("\tBridgeLocation:" + translator.BridgeLocation ?? "");
                translator.Log.Info("\tBuildArguments:" + translator.BuildArguments ?? "");
                translator.Log.Info("\tConfiguration:" + translator.Configuration ?? "");
                translator.Log.Info("\tDefineConstants:" + (translator.DefineConstants != null ? string.Join(" ", translator.DefineConstants) : ""));
                translator.Log.Info("\tRebuild:" + translator.Rebuild);

                translator.Translate();

                string path = string.IsNullOrWhiteSpace(Path.GetFileName(bridgeOptions.OutputLocation))
                    ? bridgeOptions.OutputLocation : Path.GetDirectoryName(bridgeOptions.OutputLocation);
                string outputPath = null;

                if (!string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output))
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(bridgeOptions.ProjectLocation)
                        ? Path.GetDirectoryName(bridgeOptions.ProjectLocation) : bridgeOptions.Folder, translator.AssemblyInfo.Output);
                }
                else
                {
                    outputPath = Path.Combine(!string.IsNullOrWhiteSpace(bridgeOptions.ProjectLocation)
                        ? Path.GetDirectoryName(bridgeOptions.ProjectLocation) : bridgeOptions.Folder, !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output) ? translator.AssemblyInfo.Output : path);
                }

                translator.CleanOutputFolderIfRequired(outputPath);

                if (bridgeOptions.ExtractCore)
                {
                    logger.Info("Extracting core scripts...");
                    translator.ExtractCore(outputPath);
                }

                logger.Info("Saving to " + outputPath);
                translator.SaveTo(outputPath, Path.GetFileName(bridgeOptions.OutputLocation));
                translator.Flush(outputPath, Path.GetFileName(bridgeOptions.OutputLocation));
                translator.Plugins.AfterOutput(translator, outputPath, !bridgeOptions.ExtractCore);

                logger.Info("Done translating Bridge files.");
            }
            catch (EmitterException ex)
            {
                logger.Error(string.Format("Error: {2} ({3}, {4}) {0} {1}", ex.Message, ex.StackTrace, ex.FileName, ex.StartLine, ex.StartColumn, ex.EndLine, ex.EndColumn));
                return(1);
            }
            catch (Exception ex)
            {
                var ee = translator != null?translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    logger.Error(string.Format("Error: {2} ({3}, {4}) {0} {1}", ex.Message, ex.StackTrace, ee.FileName, ee.StartLine, ee.StartColumn, ee.EndLine, ee.EndColumn));
                }
                else
                {
                    // Iteractively print inner exceptions
                    var ine  = ex;
                    var elvl = 0;
                    while (ine != null)
                    {
                        logger.Error(string.Format("Error: exception level: {0} - {1}\nStack trace:\n{2}", elvl++, ine.Message, ine.StackTrace));
                        ine = ine.InnerException;
                    }
                }
                return(1);
            }

            return(0);
        }
Пример #15
0
        public override bool Execute()
        {
            var success = true;

            #if DEBUG
            if (AttachDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            };
            #endif

            Bridge.Translator.Translator translator = null;
            try
            {
                translator = new Bridge.Translator.Translator(this.ProjectPath, true);
                translator.Configuration = this.Configuration;

                if (this.DefineConstants != null)
                {
                    translator.DefineConstants.AddRange(this.DefineConstants.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                    translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
                }

                translator.BridgeLocation = Path.Combine(this.AssembliesPath, "Bridge.dll");
                translator.Rebuild = false;
                translator.Log = this.LogMessage;
                translator.Translate();

                string fileName = Path.GetFileNameWithoutExtension(this.Assembly.ItemSpec);

                string outputPath = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output)
                    ? Path.Combine(Path.GetDirectoryName(this.ProjectPath), translator.AssemblyInfo.Output)
                    : this.OutputPath;

                if (translator.AssemblyInfo != null && translator.AssemblyInfo.CleanOutputFolderBeforeBuild)
                {
                    Console.WriteLine("Cleaning output folder before extracting scripts...");
                    CleanDirectory(outputPath);
                }

                if (!this.NoCore)
                {
                    translator.ExtractCore(outputPath);
                }
                translator.SaveTo(outputPath, fileName);
                translator.Flush(outputPath, fileName);
                translator.Plugins.AfterOutput(translator, outputPath, this.NoCore);
            }
            catch (EmitterException e)
            {
                this.Log.LogError(null, null, null, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                success = false;
            }
            catch (Exception e)
            {
                var ee = translator != null ? translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    this.Log.LogError(null, null, null, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                }
                else
                {
                    this.Log.LogError("Error: {0} {1}", e.Message, e.StackTrace);
                }

                success = false;
            }

            return success;
        }
Пример #16
0
        private Translator SetTranslatorProperties()
        {
            var logger         = this.Logger;
            var bridgeOptions  = this.BridgeOptions;
            var assemblyConfig = this.TranslatorConfiguration;

            logger.Info("Setting translator properties...");

            try
            {
                Bridge.Translator.Translator translator = null;

                // FIXME: detect by extension whether first argument is a project or DLL
                if (!bridgeOptions.IsFolderMode)
                {
                    translator = new Bridge.Translator.Translator(bridgeOptions.ProjectLocation, bridgeOptions.FromTask);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(bridgeOptions.Lib))
                    {
                        throw new Exception("Please define path to assembly using -lib option");
                    }

                    bridgeOptions.Lib = Path.Combine(bridgeOptions.Folder, bridgeOptions.Lib);
                    translator        = new Bridge.Translator.Translator(bridgeOptions.Folder, bridgeOptions.Source, bridgeOptions.Recursive, bridgeOptions.Lib);
                }

                translator.AssemblyInfo  = assemblyConfig;
                translator.Configuration = bridgeOptions.Configuration;
                translator.Platform      = bridgeOptions.Platform;

                if (string.IsNullOrEmpty(bridgeOptions.BridgeLocation))
                {
                    bridgeOptions.BridgeLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bridge.dll");
                }

                translator.BridgeLocation = bridgeOptions.BridgeLocation;
                translator.Rebuild        = bridgeOptions.Rebuild;
                translator.Log            = logger;

                if (bridgeOptions.DefinitionConstants != null)
                {
                    translator.DefineConstants.AddRange(bridgeOptions.DefinitionConstants.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                    translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
                }

                translator.Log.Info("Translator properties:");
                translator.Log.Info("\tBridgeLocation:" + translator.BridgeLocation ?? "");
                translator.Log.Info("\tBuildArguments:" + translator.BuildArguments ?? "");
                translator.Log.Info("\tConfiguration:" + translator.Configuration ?? "");
                translator.Log.Info("\tPlatform:" + translator.Platform ?? "");
                translator.Log.Info("\tDefineConstants:" + (translator.DefineConstants != null ? string.Join(" ", translator.DefineConstants) : ""));
                translator.Log.Info("\tRebuild:" + translator.Rebuild);

                logger.Info("Setting translator properties done");

                return(translator);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not read configuration: " + ex.ToString());
            }

            return(null);
        }
Пример #17
0
        public override bool Execute()
        {
            var success = true;

#if DEBUG
            if (AttachDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            };
#endif

            Bridge.Translator.Translator translator = null;
            try
            {
                translator = new Bridge.Translator.Translator(this.ProjectPath, true);
                translator.Configuration = this.Configuration;

                if (this.DefineConstants != null)
                {
                    translator.DefineConstants.AddRange(this.DefineConstants.Split(';').Select(s => s.Trim()).Where(s => s != ""));
                    translator.DefineConstants = translator.DefineConstants.Distinct().ToList();
                }

                translator.BridgeLocation = Path.Combine(this.AssembliesPath, "Bridge.dll");
                translator.Rebuild = false;
                translator.Log = new Translator.Logging.Logger("Bridge.Build.Task", true, new SimpleFileLoggerWriter());

                translator.Log.Info("Translator properties:");
                translator.Log.Info("\tBridgeLocation:" + translator.BridgeLocation ?? "");
                translator.Log.Info("\tBuildArguments:" + translator.BuildArguments ?? "");
                translator.Log.Info("\tConfiguration:" + translator.Configuration ?? "");
                translator.Log.Info("\tDefineConstants:" + (translator.DefineConstants != null ? string.Join(" ", translator.DefineConstants) : ""));
                translator.Log.Info("\tRebuild:" + translator.Rebuild);

                translator.Translate();

                string fileName = Path.GetFileNameWithoutExtension(this.Assembly.ItemSpec);

                string outputPath = !string.IsNullOrWhiteSpace(translator.AssemblyInfo.Output)
                    ? Path.Combine(Path.GetDirectoryName(this.ProjectPath), translator.AssemblyInfo.Output)
                    : this.OutputPath;

                translator.CleanOutputFolderIfRequired(outputPath);

                if (!this.NoCore)
                {
                    translator.ExtractCore(outputPath);
                }

                translator.SaveTo(outputPath, fileName);
                translator.Flush(outputPath, fileName);
                translator.Plugins.AfterOutput(translator, outputPath, this.NoCore);
            }
            catch (EmitterException e)
            {
                this.Log.LogError(null, null, null, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                success = false;
            }
            catch (Exception e)
            {
                var ee = translator != null ? translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    this.Log.LogError(null, null, null, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                }
                else
                {
                    this.Log.LogError("Error: {0} {1}", e.Message, e.StackTrace);
                }

                success = false;
            }

            translator = null;

            return success;
        }