Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-8) Host PowerShell #517

Closed
wants to merge 11 commits into from

Conversation

ferventcoder
Copy link
Member

No description provided.

@ferventcoder ferventcoder force-pushed the ticket/posh-runner branch 2 times, most recently from c898efc to 89847f2 Compare December 24, 2015 16:20
`Write-Debug` / `Write-Verbose` messages are not being logged when
coming from the `chocolateyInstall`/`chocolateyUninstall` scripts. This
is due to `DebugPreference` / `VerbosePreference` being only set to
script level in the module and not global.

Instead of changing a global variable, also set the Debug and Verbose
preferences in the script runner. It is thought that changing a global
variable could have other unintended consequences if someone was
running these scripts directly from PowerShell. So prefer the script
level change.
Implement a Console.ReadLine with a timeout so that when confirmation is
selected it doesn't block the thread eternally. This allows folks to
put prompts in chocolatey automation scripts with a default selection
and other fun prompting actions.
Implement Execute.with_timeout.command chain. This allows running
commands with timeouts, so that the CommandExecution timeout can be
observed.
Similar to ReadLine timeout, implement a readkey with an optional
timeout so that a process will block only for a limited amount of time
before failing when running actions that require user input.
Add extension for converting a string to a SecureString. This should
return an empty securestring if the value passed in is null or empty.
Add SMA and reference it appropriately. Through research it has been
found to take a dependency on the v1 version of SMA and set the
reference in the visual studio projects to not use a specific version
and not copy it local. This means it depends on being available in the
GAC, which should be if .NET Framework 4+ is installed.

The reference to v1 allows it to work across all versions of Windows
that have at least PowerShell v2 installed.
Implement a custom PowerShell host. This allows for the following:

* Read-Host timeouts when running with confirm prompts so that the host
   doesn't block forever. It also allows the default to automatically be
   selected.
* ReadKey timeouts when running with confirm prompts.
* Write-* values all get logged with the choco log all in the proper
   location instead of needing to parse the values to determine which
   log they should go to.
* Write-Progress shows up inline.
By default use the internal PowerShell host. Allow using the system
host either by shutting off the feature or by using a switch
`--use-system-powershell`.
When running PowerShell operations, use a built-in PowerShell host by
default, allowing fallback to the older method of running Posh
by calling an external process. By building against the oldest version
of System.Management.Automation that aligns with the oldest Windows
Operating Systems supported, we can guarantee this will work on every
version of Windows where Chocolatey is supported.

In case we do run into issues, attempt to resolve the PowerShell
assemblies starting from the newest version and falling down to the
older versions until one is resolved or no version is resolved. There
is a known assembly that will go through this process every time -
System.Management.Automation.resources, en-US. To see those assemblies
go through, one must ask for both debug and verbose output.

This reverts the changes for chocolateyGH-249 in 9936876 and the changes
from chocolateyGH-349 in 344268b so that both paths (system powershell
and choco's built-in PowerShell) run with similar output and because by
default in d523e7b (chocolateyGH-445) choco no longer fails on the
presence of stderr output.
@ferventcoder ferventcoder changed the title {WIP}(GH-8) Host PowerShell (GH-8) Host PowerShell Jan 1, 2016
@ferventcoder
Copy link
Member Author

targeted against wrong branch.

@ferventcoder ferventcoder deleted the ticket/posh-runner branch January 1, 2016 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant