示例#1
0
文件: Program.cs 项目: wanglifeng/cli
        private static bool OnExecute(List <ProjectContext> contexts, CompilerCommandApp args)
        {
            var compileContexts = contexts.Select(context => new CompileContext(context, (BuilderCommandApp)args)).ToList();

            var incrementalSafe = compileContexts.All(c => c.IsSafeForIncrementalCompilation);

            return(compileContexts.All(c => c.Compile(incrementalSafe)));
        }
示例#2
0
        private ScriptVariablesFixture(string rid)
        {
            var projectJson = Path.Combine(TestAssetPath, "project.json");
            var command     = new Mock <ICommand>();

            command.Setup(c => c.Execute()).Returns(new CommandResult());
            command.Setup(c => c.OnErrorLine(It.IsAny <Action <string> >())).Returns(() => command.Object);
            command.Setup(c => c.OnOutputLine(It.IsAny <Action <string> >())).Returns(() => command.Object);
            var commandFactory = new Mock <ICommandFactory>();

            commandFactory.Setup(c => c
                                 .Create(
                                     It.IsAny <string>(),
                                     It.IsAny <IEnumerable <string> >(),
                                     It.IsAny <NuGetFramework>(),
                                     It.IsAny <string>()))
            .Returns(command.Object);

            var _args = new CompilerCommandApp("dotnet compile", ".NET Compiler", "Compiler for the .NET Platform");

            _args.ConfigValue = ConfigValue;

            PreCompileScriptVariables  = new Dictionary <string, string>();
            PostCompileScriptVariables = new Dictionary <string, string>();

            var _scriptRunner = new Mock <IScriptRunner>();

            _scriptRunner.Setup(
                s =>
                s.RunScripts(It.IsAny <ProjectContext>(), It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Callback <ProjectContext, string, Dictionary <string, string> >((p, n, v) =>
            {
                if (n.Equals(ScriptNames.PreCompile))
                {
                    PreCompileScriptVariables = v;
                }

                if (n.Equals(ScriptNames.PostCompile))
                {
                    PostCompileScriptVariables = v;
                }
            });

            var managedCompiler = new ManagedCompiler(_scriptRunner.Object, commandFactory.Object);

            var rids = new List <string>();

            if (!string.IsNullOrEmpty(rid))
            {
                rids.Add(rid);
            }

            var context = ProjectContext.Create(projectJson, new NuGetFramework("dnxcore", new Version(5, 0)), rids);

            managedCompiler.Compile(context, _args);

            RuntimeOutputDir = Path.Combine(OutputPath, rid);
        }
示例#3
0
        public GivenACompilationDriverController()
        {
            _projectJson =
                Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", "TestAppWithLibrary", "TestApp", "project.json");
            _managedCompilerMock = new Mock <ICompiler>();
            _managedCompilerMock.Setup(c => c
                                       .Compile(It.IsAny <ProjectContext>(), It.IsAny <CompilerCommandApp>()))
            .Returns(true);
            _nativeCompilerMock = new Mock <ICompiler>();
            _nativeCompilerMock.Setup(c => c
                                      .Compile(It.IsAny <ProjectContext>(), It.IsAny <CompilerCommandApp>()))
            .Returns(true);

            _contexts = new List <ProjectContext>
            {
                ProjectContext.Create(_projectJson, NuGetFramework.Parse("dnxcore50"))
            };

            _args = new CompilerCommandApp("dotnet compile", ".NET Compiler", "Compiler for the .NET Platform");
        }