public static int execute(
            string command,
            IFileSystem fileSystem,
            int waitForExitSeconds,
            Action <object, DataReceivedEventArgs> stdOutAction,
            Action <object, DataReceivedEventArgs> stdErrAction
            )
        {
            if (string.IsNullOrWhiteSpace(_powershell))
            {
                _powershell = get_powershell_location(fileSystem);
            }
            //-NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%DIR%chocolatey.ps1' %PS_ARGS%"
            string arguments = "-NoProfile -NoLogo -ExecutionPolicy Bypass -Command \"{0}\"".format_with(command);

            return(CommandExecutor.execute_static(
                       _powershell,
                       arguments,
                       waitForExitSeconds,
                       workingDirectory: fileSystem.get_directory_name(fileSystem.get_current_assembly_path()),
                       stdOutAction: stdOutAction,
                       stdErrAction: stdErrAction,
                       updateProcessPath: true,
                       allowUseWindow: _allowUseWindow
                       ));
        }
Example #2
0
        public virtual void run(ChocolateyConfiguration configuration)
        {
            this.Log().Info("{0} is unpacking required files for use. Overwriting? {1}".format_with(ApplicationParameters.Name, configuration.Force));
            // refactor - thank goodness this is temporary, cuz manifest resource streams are dumb

            // unpack the manifest file as well
            AssemblyFileExtractor.extract_all_resources_to_relative_directory(_fileSystem, Assembly.GetAssembly(typeof(ChocolateyUnpackSelfCommand)), _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path()), new List <string>(), "chocolatey.console");

            IList <string> folders = new List <string>
            {
                "helpers",
                "functions",
                "redirects",
                "tools"
            };

            AssemblyFileExtractor.extract_all_resources_to_relative_directory(
                _fileSystem,
                assembly,
                _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path()),
                folders,
                ApplicationParameters.ChocolateyFileResources,
                overwriteExisting: configuration.Force,
                logOutput: true);
        }
Example #3
0
 private static void remove_old_chocolatey_exe(IFileSystem fileSystem)
 {
     try
     {
         fileSystem.delete_file(fileSystem.get_current_assembly_path() + ".old");
         fileSystem.delete_file(fileSystem.combine_paths(AppDomain.CurrentDomain.BaseDirectory, "choco.exe.old"));
     }
     catch (Exception ex)
     {
         "chocolatey".Log().Warn("Attempting to delete choco.exe.old ran into an issue:{0} {1}".format_with(Environment.NewLine, ex.Message));
     }
 }
Example #4
0
        public static int execute(
            string command,
            IFileSystem fileSystem,
            int waitForExitSeconds,
            Action<object, DataReceivedEventArgs> stdOutAction,
            Action<object, DataReceivedEventArgs> stdErrAction
            )
        {
            if (string.IsNullOrWhiteSpace(_powershell)) _powershell = get_powershell_location(fileSystem);
            //-NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%DIR%chocolatey.ps1' %PS_ARGS%"
            string arguments = "-NoProfile -NoLogo -ExecutionPolicy Bypass -Command \"{0}\"".format_with(command);

            return CommandExecutor.execute_static(
                _powershell,
                arguments,
                waitForExitSeconds,
                workingDirectory: fileSystem.get_directory_name(fileSystem.get_current_assembly_path()),
                stdOutAction: stdOutAction,
                stdErrAction: stdErrAction,
                updateProcessPath: true
                );
        }
Example #5
0
 private static void remove_old_chocolatey_exe(IFileSystem fileSystem)
 {
     try
     {
         fileSystem.delete_file(fileSystem.get_current_assembly_path() + ".old");
         fileSystem.delete_file(fileSystem.combine_paths(AppDomain.CurrentDomain.BaseDirectory, "choco.exe.old"));
     }
     catch (Exception ex)
     {
         "chocolatey".Log().Warn("Attempting to delete choco.exe.old ran into an issue:{0} {1}".format_with(Environment.NewLine, ex.Message));
     }
 }