示例#1
0
        protected override ScriptExecution PrepareExecution(Script script, CalamariVariableDictionary variables,
                                                            StringDictionary environmentVars = null)
        {
            var workingDirectory = Path.GetDirectoryName(script.File);

            var executable             = PowerShellBootstrapper.PathToPowerShellExecutable();
            var bootstrapFile          = PowerShellBootstrapper.PrepareBootstrapFile(script, variables);
            var debuggingBootstrapFile = PowerShellBootstrapper.PrepareDebuggingBootstrapFile(script);
            var arguments =
                PowerShellBootstrapper.FormatCommandArguments(bootstrapFile, debuggingBootstrapFile, variables);

            var userName = variables.Get(SpecialVariables.Action.PowerShell.UserName);
            var password = ToSecureString(variables.Get(SpecialVariables.Action.PowerShell.Password));

            return(new ScriptExecution(
                       new CommandLineInvocation(
                           executable,
                           arguments,
                           workingDirectory,
                           environmentVars,
                           userName,
                           password),
                       new[] { bootstrapFile, debuggingBootstrapFile }
                       ));
        }
示例#2
0
        public CommandResult Execute(string scriptFile, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner)
        {
            var workingDirectory = Path.GetDirectoryName(scriptFile);

            var executable   = PowerShellBootstrapper.PathToPowerShellExecutable();
            var boostrapFile = PowerShellBootstrapper.PrepareBootstrapFile(scriptFile, variables);
            var arguments    = PowerShellBootstrapper.FormatCommandArguments(boostrapFile);

            using (new TemporaryFile(boostrapFile))
            {
                var invocation = new CommandLineInvocation(executable, arguments, workingDirectory);
                return(commandLineRunner.Execute(invocation));
            }
        }
        public CommandResult Execute(Script script, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner)
        {
            var workingDirectory = Path.GetDirectoryName(script.File);

            var executable             = PowerShellBootstrapper.PathToPowerShellExecutable();
            var bootstrapFile          = PowerShellBootstrapper.PrepareBootstrapFile(script, variables);
            var debuggingBootstrapFile = PowerShellBootstrapper.PrepareDebuggingBootstrapFile(script);
            var arguments = PowerShellBootstrapper.FormatCommandArguments(bootstrapFile, debuggingBootstrapFile, variables);

            var userName = variables.Get(SpecialVariables.Action.PowerShell.UserName);
            var password = ToSecureString(variables.Get(SpecialVariables.Action.PowerShell.Password));

            using (new TemporaryFile(bootstrapFile))
            {
                using (new TemporaryFile(debuggingBootstrapFile))
                {
                    var invocation = new CommandLineInvocation(executable, arguments, workingDirectory, userName, password);
                    return(commandLineRunner.Execute(invocation));
                }
            }
        }