예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length < 1 || !uint.TryParse(args[0], out var numNodes))
            {
                numNodes = 4;
            }

            Console.WriteLine("Building Application...");
            var compiler = new ApplicationCompiler();

            compiler.AddService <BankTestsService>();
            var compiled = compiler.Compile(numNodes);

            Console.WriteLine("Building Host...");

            var deploymentTimestamp = DateTime.UtcNow;
            var emulator            = new EmulatorHost.Emulator($"bank/emulator/{deploymentTimestamp:o}", deploymentTimestamp);

            Console.WriteLine("Starting Host...");
            emulator.Run(compiled);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Building Application...");
            var compiler = new ApplicationCompiler();

            uint numberProcesses   = 5;
            uint workersPerProcess = 2;

            compiler
            .AddService <MinerService>()
            .AddBuildStep(serviceBuilder => serviceBuilder.OnFirstStart(
                              new SearchJob()
            {
                Target        = 100007394059441.GetHashCode(),
                Start         = 100000000000000,
                Count         = 10000000000,
                NumberWorkers = numberProcesses * workersPerProcess
            }))
            ;

            var application = compiler.Compile(numberProcesses);

            Console.WriteLine("Building Host...");
            var deploymentTimestamp = DateTime.UtcNow;
            var emulator            = new EmulatorHost.Emulator($"miner/emulator/{deploymentTimestamp:o}", deploymentTimestamp);

            Console.WriteLine("Starting Host...");
            emulator.Run(application);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #3
0
            /// <summary>
            /// Compiles in a seperate appdomain utilitizing one of the compilers on the stack.
            /// </summary>
            public static void Compile(ErrorSink /*!*/ errorSink, CompilationParameters /*!*/ ps)
            {
                // obtain a compiler
                StackItem item = new StackItem();

                lock (stack)
                {
                    if (stack.Count > 0)
                    {
                        item = stack.Pop();
                    }
                }
                if (item.Compiler == null)
                {
                    item.Compiler = ApplicationCompiler.CreateRemoteCompiler();
                }

                // compile
                item.Compiler.RemoteCompile(ref errorSink, ps);

                // check whether the separate appdomain is not too weedy
                if (++item.CompileCounter == 1 || item.CompileCounter == compileCounterTreshold)
                {
                    item.CompileCounter = 1;

                    CallBackDisplay display = new CallBackDisplay();

                    // avoid passing the array of assemblies across appdomain boundary
                    item.Compiler.Domain.DoCallBack(display.Handler);

                    if (item.RemoteAssemblyCount == 0)
                    {
                        item.RemoteAssemblyCount = display.AssemblyCount;
                    }
                    else
                    {
                        if (display.AssemblyCount > (2 * item.RemoteAssemblyCount))
                        {
                            AppDomain.Unload(item.Compiler.Domain);
                            return;
                        }
                    }
                }

                // recycle the compiler
                lock (stack) stack.Push(item);
            }
예제 #4
0
        static void Main(string[] args)
        {
            var applicationConfiguration = new RideSharing.Benchmark.Configuration()
            {
                NumberGeneratorProcesses = 1,
                NumberRiders             = 10,
                NumberDrivers            = 10,
                NumberServiceProcesses   = 1,
                Duration = TimeSpan.FromSeconds(10),
                Cooldown = TimeSpan.FromSeconds(5),
                Rate     = 0.333333333333,
            };

            var hostConfiguration = new EmulatorHost.Configuration()
            {
                RoundTripMessages             = true,
                RoundTripProcessStateEvery    = int.MaxValue,
                DeliverStaleExternalsOneOutOf = 10000
            };

            Console.WriteLine("Building Application...");

            var application = new ApplicationCompiler()
                              .SetConfiguration(applicationConfiguration)
                              .AddService <RideSharingBenchmark>()
                              .Compile(applicationConfiguration.NumberServiceProcesses + applicationConfiguration.NumberGeneratorProcesses);

            var experimentAndHost = "ridesharing/emulator/";

            var localOrCloudDeployment =
                Environment.GetEnvironmentVariable("REACTIVE_MACHINE_DIR") == null ? "cloud" : "local";

            var deploymentTimestamp = DateTime.UtcNow;

            var deploymentId = string.Format("{1}{2}/{0:o}", deploymentTimestamp, experimentAndHost, localOrCloudDeployment);

            var emulator = new EmulatorHost.Emulator(deploymentId, deploymentTimestamp);

            Console.WriteLine("Starting Host...");
            emulator.Run(application);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #5
0
        static void Main(string[] args)
        {
            if (args.Length < 1 || !uint.TryParse(args[0], out var numNodes))
            {
                numNodes = 4;
            }

            var configuration = new EmulatorHost.Configuration()
            {
                MultiThreaded       = true,
                ApplicationLogLevel = LogLevel.Trace,
                RuntimeLogLevel     = LogLevel.Trace,
                FileLogLevel        = LogLevel.Trace,
                LocalLogDirectory   = "C:\\logs\\",
            };
            var loggingConfig = new ReactiveMachine.LoggingConfiguration()
            {
                //SendLogLevel = LogLevel.Trace,
                //LockLogLevel = LogLevel.Trace
            };

            Console.WriteLine("Building Application...");
            var compiler = new ApplicationCompiler();

            compiler.AddService <BankTestsService>();
            compiler.AddBuildStep(sb => sb
                                  .SetConfiguration(configuration)
                                  .SetConfiguration(loggingConfig));
            var compiled = compiler.Compile(numNodes);

            Console.WriteLine("Building Host...");

            var deploymentTimestamp = DateTime.UtcNow;
            var emulator            = new EmulatorHost.Emulator($"bank/emulator/{deploymentTimestamp:o}", deploymentTimestamp);

            Console.WriteLine("Starting Host...");
            emulator.Run(compiled);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Building Application...");
            var compiler = new ApplicationCompiler();

            compiler.AddService <PingPongService>();
            var application = compiler.Compile(2);

            Console.WriteLine("Starting Host...");
            var deploymentTimestamp = DateTime.UtcNow;
            var emulator            = new EmulatorHost.Emulator($"pingpong/emulator/{deploymentTimestamp:o}", deploymentTimestamp);

            emulator.Run(application);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #7
0
        static void Main(string[] args)
        {
            var compiler = new ApplicationCompiler();

            Console.WriteLine("Setting configuration objects...");

            compiler.SetConfiguration(new HelloWorldTestConfiguration()
            {
                NumberRepetitions = 100
            });
            compiler.SetConfiguration(new ReactiveMachine.TelemetryBlobWriter.Configuration()
            {
                CollectHostEvents        = true,
                CollectApplicationEvents = true,
                CollectThroughput        = false,
            });

            Console.WriteLine("Building Application...");

            compiler.AddService <HelloWorldTestService>();

            Console.WriteLine("Compiling Application...");

            var compiledApplication = compiler.Compile(numberProcesses: 1);

            Console.WriteLine("Building Host...");

            var deploymentTimestamp = DateTime.UtcNow;
            var deploymentId        = $"helloworld/emulator/{deploymentTimestamp:o}";

            var emulator = new EmulatorHost.Emulator(deploymentId, deploymentTimestamp);

            Console.WriteLine("Starting Host...");

            emulator.Run(compiledApplication);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #8
0
        static void Main(string[] args)
        {
            var configuration = new EmulatorHost.Configuration()
            {
                MultiThreaded                 = false,
                RoundTripMessages             = true,
                RoundTripProcessStateEvery    = int.MaxValue,
                DeliverStaleExternalsOneOutOf = 1,
                ApplicationLogLevel           = LogLevel.Trace,
                RuntimeLogLevel               = Debugger.IsAttached ? LogLevel.Trace : LogLevel.Warning,
                ConsoleLogLevel               = LogLevel.Trace,
                FileLogLevel = LogLevel.Trace,
            };

            var loggingConfig = new ReactiveMachine.LoggingConfiguration()
            {
                SendLogLevel     = LogLevel.Trace,
                LockLogLevel     = LogLevel.Trace,
                ProgressLogLevel = LogLevel.None,
            };

            Console.WriteLine("Building Application...");

            var application = new ApplicationCompiler()
                              .AddService <TestsService>()
                              .SetConfiguration <EmulatorHost.Configuration>(configuration)
                              .SetConfiguration <ReactiveMachine.LoggingConfiguration>(loggingConfig)
                              .Compile(5);

            Console.WriteLine("Building Host...");
            var deploymentTimestamp = DateTime.UtcNow;
            var emulator            = new EmulatorHost.Emulator($"localtests/{deploymentTimestamp:o}", deploymentTimestamp);

            Console.WriteLine($"Starting Test {deploymentTimestamp}...");
            emulator.Run(application);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #9
0
        public void RemoteCompile(ref ErrorSink /*!*/ errorSink, CompilationParameters /*!*/ ps)
        {
            lock (buildMutex)             // TODO: do we need thread-safety (if yes, there is a better way)?
            {
                //if (++buildCounter % 10 == 0) // TODO: is it possible to estimate size of memory allocated by the domain?
                //{
                //  // if a referenced assembly gets updated then we should reload the domain as well
                //  AppDomain.Unload(remoteCompiler.Domain);
                //  remoteCompiler = null;
                //}

                if (remoteCompiler != null)
                {
                    AppDomain.Unload(remoteCompiler.Domain);
                }

                remoteCompiler = ApplicationCompiler.CreateRemoteCompiler();

                remoteCompiler.RemoteCompile(ref errorSink, ps);
            }
        }
        protected override void EndProcessing()
        {
            Action <string, object> writeVerbose = (targetType, target) => WriteVerbose($"Exporting {CachedObjects.Objects.Count()} object(s) to {targetType} {target}");

            switch (ParameterSetName)
            {
            case "ToPath":
                var path = GetUnresolvedProviderPathFromPSPath(Path);
                writeVerbose("path", path);

                this.WriteObjectIf(!PassThru, Directory ? CachedObjects.WriteToFolder(path) : CachedObjects.WriteToFile(path).AsEnumerable());
                this.WriteObjectIf(PassThru, CachedObjects);

                break;

            case "ToTextWriter":
                writeVerbose("TextWriter", "");
                CachedObjects.WriteToTextWriter(TextWriter ?? Console.Out);
                this.WriteObjectIf(PassThru, CachedObjects);
                break;

            case "ToStream":
                writeVerbose("Stream", "");
                CachedObjects.WriteToStream(Stream);
                this.WriteObjectIf(PassThru, CachedObjects);
                break;

            case "ToDatabase":
                writeVerbose("database", Database);
                ApplicationImporter.Import(CachedObjects, DevClientPath ?? DefaultDevClientPath, ServerName, Database, ImportAction);

                if (AutoCompile)
                {
                    ApplicationCompiler.Compile(CachedObjects, DevClientPath ?? DefaultDevClientPath, ServerName, Database);
                }

                this.WriteObjectIf(PassThru, CachedObjects);
                break;
            }
        }
예제 #11
0
        /// <summary>
        /// Runs the compiler with specified options.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        /// <returns>Whether the compilation was successful.</returns>
        public bool Compile(List <string> /*!*/ args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            TextErrorSink errorSink = null;

            // processes arguments:
            try
            {
                try
                {
                    commandLineParser.Parse(args);
                }
                finally
                {
                    if (commandLineParser.Quiet)
                    {
                        output = errors = TextWriter.Null;
                    }
                    else if (commandLineParser.RedirectErrors)
                    {
                        output = errors = Console.Out;
                    }
                    else
                    {
                        output = Console.Out;
                        errors = Console.Error;
                    }

                    errorSink = new TextErrorSink(errors);

                    ShowLogo();

                    if (commandLineParser.ShowHelp)
                    {
                        ShowHelp();
                    }
                    else
                    {
                        DumpArguments(args);
                    }
                }
            }
            catch (InvalidCommandLineArgumentException e)
            {
                e.Report(errorSink);
                return(false);
            }

            if (commandLineParser.ShowHelp)
            {
                return(true);
            }

            // allow loading of all assemblies in /Bin directory by their FullName
            HandleAssemblies(Path.Combine(commandLineParser.Parameters.SourceRoot, "Bin"));

            //
            ApplicationContext.DefineDefaultContext(false, true, false);
            ApplicationContext app_context = ApplicationContext.Default;

            CompilerConfiguration compiler_config;

            // loads entire configuration:
            try
            {
                if (commandLineParser.Parameters.ConfigPaths.Count == 0)
                {
                    // Add config files for known targets
                    switch (commandLineParser.Parameters.Target)
                    {
                    case ApplicationCompiler.Targets.Web:
                        if (File.Exists("web.config"))
                        {
                            commandLineParser.Parameters.ConfigPaths.Add(new FullPath("web.config"));
                        }
                        break;

                    case ApplicationCompiler.Targets.WinApp:
                        if (File.Exists("app.config"))
                        {
                            commandLineParser.Parameters.ConfigPaths.Add(new FullPath("app.config"));
                        }
                        break;
                    }
                }
                compiler_config = ApplicationCompiler.LoadConfiguration(app_context,
                                                                        commandLineParser.Parameters.ConfigPaths, output);

                commandLineParser.Parameters.ApplyToConfiguration(compiler_config);
            }
            catch (ConfigurationErrorsException e)
            {
                if (commandLineParser.Verbose)
                {
                    output.WriteLine(CoreResources.GetString("reading_configuration") + ":");
                    output.WriteLine();

                    if (!String.IsNullOrEmpty(e.Filename))                     // Mono puts here null
                    {
                        output.WriteLine(FileSystemUtils.ReadFileLine(e.Filename, e.Line).Trim());
                        output.WriteLine();
                    }
                }

                errorSink.AddConfigurationError(e);
                return(false);
            }

            // load referenced assemblies:
            try
            {
                try
                {
                    app_context.AssemblyLoader.Load(commandLineParser.Parameters.References);
                }
                finally
                {
                    if (commandLineParser.Verbose)
                    {
                        DumpLoadedLibraries();
                    }
                }
            }
            catch (ConfigurationErrorsException e)
            {
                errorSink.AddConfigurationError(e);
                return(false);
            }

            output.WriteLine(CoreResources.GetString("performing_compilation") + " ...");

            try
            {
                CommandLineParser p = commandLineParser;
                Statistics.DrawGraph = p.DrawInclusionGraph;

                errorSink.DisabledGroups        = compiler_config.Compiler.DisabledWarnings;
                errorSink.DisabledWarnings      = compiler_config.Compiler.DisabledWarningNumbers;
                errorSink.TreatWarningsAsErrors = compiler_config.Compiler.TreatWarningsAsErrors;

                // initializes log:
                DebugUtils.ConsoleInitialize(Path.GetDirectoryName(p.Parameters.OutPath));

                new ApplicationCompiler().Compile(app_context, compiler_config, errorSink, p.Parameters);
            }
            catch (InvalidSourceException e)
            {
                e.Report(errorSink);
                return(false);
            }
            catch (Exception e)
            {
                errorSink.AddInternalError(e);
                return(false);
            }

            var errorscount  = errorSink.ErrorCount + errorSink.FatalErrorCount;
            var warningcount = errorSink.WarningCount + errorSink.WarningAsErrorCount;

            output.WriteLine();
            output.WriteLine("Build complete -- {0} error{1}, {2} warning{3}.",
                             errorscount, (errorscount == 1) ? "" : "s",
                             warningcount, (warningcount == 1) ? "" : "s");

            return(!errorSink.AnyError);
        }
예제 #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Building Application...");

            var appConfig = new CounterBenchmarkConfiguration()
            {
                NumberGeneratorProcesses = 4,
                NumberGenerators         = 4,
                NumberCounterProcesses   = 4,
                NumberCounters           = 4,
                Duration       = TimeSpan.FromSeconds(10),
                Cooldown       = TimeSpan.FromSeconds(5),
                Rate           = 4,
                Implementation = CounterImplementation.UpdateBased,
            };

            //var appConfig = new CounterBenchmarkConfiguration()
            //{
            //    NumberGeneratorProcesses = 2,
            //    NumberGenerators = 1000,
            //    NumberCounterProcesses = 2,
            //    NumberCounters = 1000,
            //    NumberRequests = 5000,
            //    Stagger = TimeSpan.FromSeconds(1),
            //    Implementation = CounterImplementation.UpdateBased,
            //};

            //var appConfig = new CounterBenchmarkConfiguration()
            //{
            //    NumberGeneratorProcesses = 1,
            //    NumberGenerators = 10000,
            //    NumberCounterProcesses = 1,
            //    NumberCounters = 1,
            //    NumberRequests = 200000,
            //    Stagger = TimeSpan.FromSeconds(1),
            //    Implementation = CounterImplementation.UpdateBased,
            //};

            var hostConfig = new EmulatorHost.Configuration()
            {
                MultiThreaded = true,

                RoundTripMessages             = true,
                RoundTripProcessStateEvery    = int.MaxValue,
                DeliverStaleExternalsOneOutOf = 1,

                ConsoleLogLevel   = LogLevel.Information,
                FileLogLevel      = Debugger.IsAttached ? LogLevel.Trace : LogLevel.None,
                LocalLogDirectory = "C:\\logs\\",

                ApplicationLogLevel = LogLevel.Trace, // log through runtime
                HostLogLevel        = LogLevel.Trace,
                RuntimeLogLevel     = LogLevel.Trace
            };

            var telemetryConfig = new ReactiveMachine.TelemetryBlobWriter.Configuration()
            {
                CollectHostEvents        = false,
                CollectApplicationEvents = (System.Diagnostics.Debugger.IsAttached || appConfig.IsFixedRateExperiment),
                CollectThroughput        = (System.Diagnostics.Debugger.IsAttached || appConfig.IsLoadLoopsExperiment),
            };


            var application = new ApplicationCompiler()
                              .SetConfiguration(appConfig)
                              .SetConfiguration(telemetryConfig)
                              .SetConfiguration(hostConfig)
                              .AddService <CounterBenchmarkService>()
                              .Compile(appConfig.NumberCounterProcesses + appConfig.NumberGeneratorProcesses);


            var experimentAndHost = "counter/emulator/";

            var localOrCloudDeployment =
                Environment.GetEnvironmentVariable("REACTIVE_MACHINE_DIR") == null ? "cloud" : "local";

            var deploymentTimestamp = DateTime.UtcNow;

            var deploymentId = string.Format("{1}{2}/{0:o}", deploymentTimestamp, experimentAndHost, localOrCloudDeployment);

            var emulator = new EmulatorHost.Emulator(deploymentId, deploymentTimestamp);

            Console.WriteLine("Starting Host...");
            emulator.Run(application);

            Console.WriteLine("Done (hit enter to terminate)...");
            Console.ReadLine();

            emulator.Shutdown();
        }
예제 #13
0
 /// <exlude/>
 protected override void ProcessRecord()
 {
     ApplicationCompiler.Compile(Application, DevClientPath ?? DefaultDevClientPath, ServerName, Database);
 }
예제 #14
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Normal, "Phalanger Compilation Task");

            CompilationParameters ps = new CompilationParameters();

            // source root (project directory by default):
            ps.SourceRoot = new FullPath(sourceRoot);

            // target type:
            string assembly_extension;

            switch (outputType.ToLowerInvariant())
            {
            case "dll":
            case "library":
                ps.Target          = ApplicationCompiler.Targets.Dll;
                assembly_extension = ".dll";
                break;

            case "exe":
            case "console":
                ps.Target          = ApplicationCompiler.Targets.Console;
                assembly_extension = ".exe";
                break;

            case "winexe":
            case "winapp":
                ps.Target          = ApplicationCompiler.Targets.WinApp;
                assembly_extension = ".exe";
                break;

            case "webapp":
                ps.Target          = ApplicationCompiler.Targets.Web;
                assembly_extension = ".dll";
                // TODO: precompile option
                return(true);

            default:
                Log.LogError("Invalid output type: '{0}'.", outputType);
                return(false);
            }

            if (Path.GetExtension(outputAssembly) != assembly_extension)
            {
                Log.LogError("Output assembly extension doesn't match project type.");
                return(false);
            }

            if (contentFiles != null)
            {
                foreach (string file in contentFiles)
                {
                    if (String.Compare(Path.GetExtension(file), ".config", true) == 0)
                    {
                        ps.ConfigPaths.Add(new FullPath(file, ps.SourceRoot));
                    }
                }
            }

            // debug symbols:
            ps.Debuggable = this.Debug;

            // compilation of executables in debug mode from VisualStudio/MSBuild will produce 32bit assembly to EE working properly
            ps.Force32Bit = this.Debug && assembly_extension.EqualsOrdinalIgnoreCase(".exe");

            // language features:
            ps.Pure = ApplicationCompiler.IsPureUnit(compilationMode);

            if (!String.IsNullOrEmpty(languageFeatures))
            {
                try
                {
                    ps.LanguageFeatures = (Core.LanguageFeatures)Enum.Parse(typeof(Core.LanguageFeatures),
                                                                            languageFeatures, true);
                }
                catch (Exception)
                {
                    Log.LogError("Invalid language features.");
                    return(false);
                }
            }
            else
            {
                ps.LanguageFeatures = (ps.Pure) ? Core.LanguageFeatures.PureModeDefault : Core.LanguageFeatures.Default;
            }

            // source paths:
            GetSourcePaths(ps.SourceRoot, ps.SourcePaths);

            // directories (TODO)
            // ps.SourceDirs
            // extensions (TODO)
            // ps.FileExtensions = null;

            if (ps.SourcePaths.Count == 0 && ps.SourceDirs.Count == 0)
            {
                Log.LogError("No source files to compile.");
                return(false);
            }

            // out path:
            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputAssembly));
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
                return(false);
            }

            ps.OutPath = new FullPath(outputAssembly);

            // doc path (TODO):
            ps.DocPath = FullPath.Empty;

            // startup file/class:
            ps.StartupFile = FullPath.Empty;
            // TODO: string startup_class = null;

            if (ps.Target == ApplicationCompiler.Targets.Console || ps.Target == ApplicationCompiler.Targets.WinApp)
            {
                if (ps.Pure)
                {
                    if (!String.IsNullOrEmpty(startupObject))
                    {
                        // TODO: startup_class = startupObject;

                        Log.LogWarning("Startup class is ignored -- the feature is not supported yet.");
                        return(false);
                    }
                    else
                    {
                        // TODO: startup_class = null;
                    }
                }
                else
                {
                    if (String.IsNullOrEmpty(startupObject))
                    {
                        if (ps.SourcePaths.Count > 1)
                        {
                            Log.LogError("The startup file must be specified in the project property pages.");
                            return(false);
                        }
                        else
                        {
                            ps.StartupFile = new FullPath(ps.SourcePaths[0], ps.SourceRoot);
                        }
                    }
                    else
                    {
                        try
                        {
                            ps.StartupFile = new FullPath(startupObject, ps.SourceRoot);
                        }
                        catch (Exception e)
                        {
                            Log.LogErrorFromException(e);
                            return(false);
                        }

                        // startup file is not in the list of compiled files:
                        if (ps.SourcePaths.IndexOf(ps.StartupFile) == -1)
                        {
                            Log.LogError("The startup file specified in the property pages must be included in the project.");
                            return(false);
                        }
                    }
                }
            }

            // icon:
            ps.Icon = null;
            try
            {
                if (applicationIcon != null)
                {
                    ps.Icon = new Win32IconResource(new FullPath(applicationIcon, ps.SourceRoot));
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
                return(false);
            }

            // strong name, version (TODO):
            try
            {
                ps.Version = new Version(1, 0, 0, 0);
                ps.Key     = null;
                if (!string.IsNullOrEmpty(keyFile))
                {
                    using (FileStream file = new FileStream(new FullPath(keyFile, ps.SourceRoot), FileMode.Open, FileAccess.Read))
                        ps.Key = new StrongNameKeyPair(file);
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
                return(false);
            }

            //Resources
            foreach (ITaskItem resource in this.ResourceFiles)
            {
                bool   publicVisibility = true;
                string access           = resource.GetMetadata("Access");
                if (String.CompareOrdinal("Private", access) == 0)
                {
                    publicVisibility = false;
                }
                string filename    = resource.ItemSpec;
                string logicalName = resource.GetMetadata("LogicalName");
                if (String.IsNullOrEmpty(logicalName))
                {
                    logicalName = Path.GetFileName(resource.ItemSpec);
                }
                ps.Resources.Add(new ResourceFileReference(filename, logicalName, publicVisibility));
            }

            // referenced assemblies:

            //if (referencedAssemblies != null)
            if (references != null)
            {
                foreach (ITaskItem assemblyReference in references /*referencedAssemblies*/)
                {
                    // script library root:
                    var scriptLibraryRoot = assemblyReference.GetMetadata("MSARoot");

                    if (scriptLibraryRoot != null)
                    {
                        scriptLibraryRoot = scriptLibraryRoot.Trim();
                    }

                    if (string.IsNullOrEmpty(scriptLibraryRoot))
                    {
                        scriptLibraryRoot = null;
                    }

                    // add the reference to CompilationParameters:
                    ps.References.Add(new CompilationParameters.ReferenceItem()
                    {
                        Reference   = assemblyReference.ItemSpec,
                        LibraryRoot = scriptLibraryRoot
                    });
                }
            }

            // errors, warnings:
            ErrorSink sink = new CompilerErrorSink(this.Log);

            if (!String.IsNullOrEmpty(disabledWarnings))
            {
                try
                {
                    ps.DisableWarningNumbers = ConfigUtils.ParseIntegerList(disabledWarnings, ',', 1, 10000, null);
                }
                catch (Exception)
                {
                    Log.LogError("Invalid list of disabled warnings.");
                    return(false);
                }
            }
            else
            {
                ps.DisableWarningNumbers = ArrayUtils.EmptyIntegers;
            }

            ps.EnableWarnings |= WarningGroups.DeferredToRuntime;   // enable deferred to runtime warnings

            ps.TreatWarningsAsErrors = this.TreatWarningsAsErrors;

            // compile

            try
            {
                //ApplicationCompiler.CompileInSeparateDomain(sink, ps);
                RemoteCompile(ref sink, ps);
            }
            catch (InvalidSourceException e)
            {
                e.Report(sink);
                return(false);
            }
            catch (Exception e)
            {
                sink.AddInternalError(e);
                return(false);
            }

            return(!sink.AnyError);
        }