public void ResolveDotnetTaskWithArguments()
        {
            ExecuteDotnetTask instance = Factory.Create <ExecuteDotnetTask>("compile");

            Assert.IsType <ExecuteDotnetTask>(instance);
            Assert.Equal("compile", instance.Command);
        }
        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
            }
        }
        public void ExecuteCommandDotnetNotSet()
        {
            ExecuteDotnetTask task = new ExecuteDotnetTask("help");

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

            Assert.Equal(-1, e.ErrorCode);
        }
        public void ExecuteCommand()
        {
            ExecuteDotnetTask task = Context.CoreTasks().ExecuteDotnetTask("help")
                                     .Executable(PathToDotnetExecutable);

            var res = task.Execute(Context);

            Assert.Equal(0, res);
        }
        public void ExecuteCommandTargetTreeCreate()
        {
            ExecuteDotnetTask task = new ExecuteDotnetTask("help");

            task.Executable(PathToDotnetExecutable);

            int res = task.Execute(Context);

            Assert.Equal(0, res);
        }
        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);
         }
     }
 }