コード例 #1
0
        public void ResolveDotnetTaskWithArguments()
        {
            ExecuteDotnetTask instance = Factory.Create <ExecuteDotnetTask>("compile");

            Assert.IsType <ExecuteDotnetTask>(instance);
            Assert.Equal("compile", instance.Command);
        }
コード例 #2
0
        public void ExecuteNonExistentCommand()
        {
            ExecuteDotnetTask task = Context.CoreTasks().ExecuteDotnetTask("nonexist")
                                     .Executable(PathToDotnetExecutable);

            TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.ExecuteVoid(Context));
        }
コード例 #3
0
        private void ConfigureDefaultProps(ITaskSession taskSession)
        {
            taskSession.SetBuildVersion(new Version(1, 0, 0, 0));
            taskSession.SetDotnetExecutable(ExecuteDotnetTask.FindDotnetExecutable());

            var        isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
            OSPlatform platform;

            if (!isWindows)
            {
                var isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
                platform = isLinux ? OSPlatform.Linux : OSPlatform.OSX;
            }
            else
            {
                platform = OSPlatform.Windows;
            }

            taskSession.SetOSPlatform(platform);
            taskSession.SetNodeExecutablePath(IOExtensions.GetNodePath());
            taskSession.SetProfileFolder(IOExtensions.GetUserProfileFolder());
            taskSession.SetNpmPath(IOExtensions.GetNpmPath());
            taskSession.SetBuildDir("build");
            taskSession.SetOutputDir("output");
            taskSession.SetProductRootDir(".");

            if (isWindows)
            {
                // do windows specific tasks
            }
        }
コード例 #4
0
        public void ExecuteCommandDotnetNotSet()
        {
            ExecuteDotnetTask task = new ExecuteDotnetTask("help");

            var e = Assert.Throws <TaskExecutionException>(() => task.Execute(Context));

            Assert.Equal(-1, e.ErrorCode);
        }
コード例 #5
0
        public void ExecuteCommand()
        {
            ExecuteDotnetTask task = Context.CoreTasks().ExecuteDotnetTask("help")
                                     .Executable(PathToDotnetExecutable);

            var res = task.Execute(Context);

            Assert.Equal(0, res);
        }
コード例 #6
0
        public void ExecuteCommandTargetTreeCreate()
        {
            ExecuteDotnetTask task = new ExecuteDotnetTask("help");

            task.Executable(PathToDotnetExecutable);

            int res = task.Execute(Context);

            Assert.Equal(0, res);
        }
コード例 #7
0
        public void ExecuteWrongArgsCommand()
        {
            ExecuteDotnetTask task = new ExecuteDotnetTask("build")
                                     .Executable(PathToDotnetExecutable)
                                     .WithArguments("Flubu.NonExtstProj");

            TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.Execute(Context));

            Assert.Equal(1, e.ErrorCode);
        }
コード例 #8
0
        private string GetExecutable()
        {
            if (!string.IsNullOrEmpty(_testExecutable))
            {
                return(_testExecutable);
            }

            switch (_provider)
            {
            case UnitTestProvider.DotnetCore:
                return(ExecuteDotnetTask.FindDotnetExecutable());

            default:
                throw new NotSupportedException($"Provider {_provider} not supported yet. Set test executable manually.");
            }
        }
コード例 #9
0
 private void RestoreNugetPackages(string csprojLocation)
 {
     try
     {
         var      dotnetExecutable = ExecuteDotnetTask.FindDotnetExecutable();
         ICommand command          = _commandFactory.Create(dotnetExecutable, new List <string>()
         {
             "restore", csprojLocation
         });
         command.CaptureStdErr().WorkingDirectory(Directory.GetCurrentDirectory()).Execute();
         _packagesRestored = true;
     }
     catch (InvalidOperationException e)
     {
         RestoreNugetPackagesMsBuildFallback(csprojLocation);
         if (!_packagesRestored)
         {
             throw new ScriptException("Can not restore nuget packages. dotnet core sdk/runtime not installed and msbuild 15 or higher not found. See for more information",
                                       e);
         }
     }
 }