public CommandResult Execute(string scriptFile, VariableDictionary variables, ICommandLineRunner commandLineRunner)
        {
            var workingDirectory = Path.GetDirectoryName(scriptFile);

            var configurationFile = ScriptCSBootstrapper.PrepareConfigurationFile(workingDirectory, variables);
            var boostrapFile      = ScriptCSBootstrapper.PrepareBootstrapFile(scriptFile, configurationFile, workingDirectory);

            using (new TemporaryFile(configurationFile))
                using (new TemporaryFile(boostrapFile))
                {
                    return(commandLineRunner.Execute(new CommandLineInvocation(ScriptCSBootstrapper.FindScriptCSExecutable(), ScriptCSBootstrapper.FormatCommandArguments(boostrapFile), workingDirectory)));
                }
        }
        protected override ScriptExecution PrepareExecution(Script script, CalamariVariableDictionary variables,
                                                            StringDictionary environmentVars = null)
        {
            var workingDirectory  = Path.GetDirectoryName(script.File);
            var executable        = ScriptCSBootstrapper.FindExecutable();
            var configurationFile = ScriptCSBootstrapper.PrepareConfigurationFile(workingDirectory, variables);
            var bootstrapFile     = ScriptCSBootstrapper.PrepareBootstrapFile(script.File, configurationFile, workingDirectory);
            var arguments         = ScriptCSBootstrapper.FormatCommandArguments(bootstrapFile, script.Parameters);

            return(new ScriptExecution(
                       new CommandLineInvocation(executable, arguments, workingDirectory, environmentVars),
                       new[] { bootstrapFile, configurationFile }
                       ));
        }
        protected override IEnumerable <ScriptExecution> PrepareExecution(Script script, CalamariVariableDictionary variables,
                                                                          Dictionary <string, string> environmentVars = null)
        {
            var workingDirectory  = Path.GetDirectoryName(script.File);
            var executable        = ScriptCSBootstrapper.FindExecutable();
            var configurationFile = ScriptCSBootstrapper.PrepareConfigurationFile(workingDirectory, variables);

            var(bootstrapFile, otherTemporaryFiles) = ScriptCSBootstrapper.PrepareBootstrapFile(script.File, configurationFile, workingDirectory, variables);
            var arguments = ScriptCSBootstrapper.FormatCommandArguments(bootstrapFile, script.Parameters);

            yield return(new ScriptExecution(
                             new CommandLineInvocation(executable, arguments, workingDirectory, environmentVars),
                             otherTemporaryFiles.Concat(new[] { bootstrapFile, configurationFile })
                             ));
        }
Exemple #4
0
        public CommandResult Execute(
            Script script,
            CalamariVariableDictionary variables,
            ICommandLineRunner commandLineRunner,
            StringDictionary environmentVars = null)
        {
            var workingDirectory = Path.GetDirectoryName(script.File);

            var executable        = ScriptCSBootstrapper.FindExecutable();
            var configurationFile = ScriptCSBootstrapper.PrepareConfigurationFile(workingDirectory, variables);
            var boostrapFile      = ScriptCSBootstrapper.PrepareBootstrapFile(script.File, configurationFile, workingDirectory);
            var arguments         = ScriptCSBootstrapper.FormatCommandArguments(boostrapFile, script.Parameters);

            using (new TemporaryFile(configurationFile))
                using (new TemporaryFile(boostrapFile))
                {
                    return(commandLineRunner.Execute(new CommandLineInvocation(executable, arguments, workingDirectory, environmentVars)));
                }
        }