Ejemplo n.º 1
0
        private int Run()
        {
            var compiler = new CompositeCompiler(serviceMessages)
            {
                AdditionalNamespaces = namespaces,
                AdditionalReferences = references
            };

            CompilerResults results;

            try
            {
                results = compiler.Compile(program);
            }
            catch (CannotCompileException e)
            {
                Out.WriteLine(e.Message);
                return(-1);
            }

            if (results.Errors.HasErrors)
            {
                foreach (CompilerError compilerError in results.Errors)
                {
                    Error.WriteLine(compilerError.ToString());
                }

                return(results.NativeCompilerReturnValue);
            }

            var executor = new ArtifactPublisherExecutorDecorator(artifactsPath, reportName, new Executor(artifactsPath, serviceMessages), serviceMessages);

            try
            {
                executor.Execute(results, references);
            }
            catch (TargetInvocationException e)
            {
                Error.WriteLine(e.InnerException);
                return(-1);
            }
            catch (Exception e)
            {
                Error.WriteLine(e);
                return(-1);
            }

            return(0);
        }
Ejemplo n.º 2
0
        private int Run()
        {
            var compiler = new CompositeCompiler(serviceMessages)
                           {
                               AdditionalNamespaces = namespaces,
                               AdditionalReferences = references
                           };

            CompilerResults results;

            try
            {
                results = compiler.Compile(program);
            }
            catch (CannotCompileException e)
            {
                Out.WriteLine(e.Message);
                return -1;
            }

            if (results.Errors.HasErrors)
            {
                foreach (CompilerError compilerError in results.Errors)
                    Error.WriteLine(compilerError.ToString());

                return results.NativeCompilerReturnValue;
            }

            var executor = new ArtifactPublisherExecutorDecorator(artifactsPath, reportName, new Executor(artifactsPath, serviceMessages), serviceMessages);

            try
            {
                executor.Execute(results, references);
            }
            catch (TargetInvocationException e)
            {
                Error.WriteLine(e.InnerException);
                return -1;
            }
            catch (Exception e)
            {
                Error.WriteLine(e);
                return -1;
            }

            return 0;
        }