Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (doc) update Changelog
  (GH-8) Use Custom PowerShell Host
  (GH-8) Configuration for PowerShell Host
  (GH-8) Implement Custom PowerShell Host
  (GH-8) Add System.Management.Automation binary
  (GH-8) Convert to SecureString
  (GH-8) ReadKey Timeout
  (GH-8) Run commands with timeout
  (maint) add messages to package installers
  (GH-8) ReadLine Timeout
  (GH-445) Scenario docs update
  (GH-520) Fix: Debug/Verbose messages not logged
  • Loading branch information
ferventcoder committed Jan 1, 2016
2 parents 01ea40d + 6765dcb commit 8ba0c8e
Show file tree
Hide file tree
Showing 23 changed files with 1,169 additions and 74 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
## [0.9.10](https://github.com/chocolatey/choco/issues?q=milestone%3A0.9.10+is%3Aclosed) (unreleased)

Alternative sources (webpi, windowsfeature, cygwin, etc) are back (finally, right?)!
Alternative sources (webpi, windowsfeature, cygwin, etc) are back (finally, right?)! Use an internal PowerShell host to take advantage of quite a few improvements!

### BREAKING CHANGES

* Only fail automation scripts (chocolateyInstall.ps1) if the script returns non-zero exit code - see [#445](https://github.com/chocolatey/choco/issues/445)

### FEATURES

* Alternative sources - see [#14](https://github.com/chocolatey/choco/issues/14)
* Alternative Sources - see [#14](https://github.com/chocolatey/choco/issues/14)
* Use Internal PowerShell Host - see [#8](https://github.com/chocolatey/choco/issues/8)
* Support for custom headers - see [#332](https://github.com/chocolatey/choco/issues/332)

### BUG FIXES

* Fix - Debug/Verbose messages not logged in install scripts (chocolateyInstall.ps1) - see [#520](https://github.com/chocolatey/choco/issues/520)
* Fix - Logger doesn't clear cached NullLoggers - see [#516](https://github.com/chocolatey/choco/issues/516)
* Fix - DISM "/All" argument in the wrong position - see [#480](https://github.com/chocolatey/choco/issues/480)
* Fix - Merging assemblies on a machine running .net 4.5 or higher produces binaries incompatible with .net 4 - see [#392](https://github.com/chocolatey/choco/issues/392)
* Fix - API - Incorrect log4net version in chocolatey.lib dependencies - see [#390](https://github.com/chocolatey/choco/issues/390)

Expand Down
25 changes: 24 additions & 1 deletion Scenarios.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Chocolatey Usage Scenarios

### ChocolateyInstallCommand [ 32 Scenario(s), 270 Observation(s) ]
### ChocolateyInstallCommand [ 34 Scenario(s), 287 Observation(s) ]

#### when force installing a package that depends on an unavailable newer version of an installed dependency forcing dependencies

Expand Down Expand Up @@ -223,6 +223,29 @@
* should not have warning package result
* should not install a package in the lib directory

#### when installing a package that has nonterminating errors

* config should match package result name
* should contain a message that it installed successfully
* should have a successful package result
* should have a version of one dot zero
* should install the expected version of the package
* should install the package in the lib directory
* should install where install location reports
* should not have inconclusive package result
* should not have warning package result

#### when installing a package that has nonterminating errors with fail on stderr

* should contain a warning message that it was unable to install a package
* should have an error package result
* should have expected error in package result
* should not have a successful package result
* should not have inconclusive package result
* should not have warning package result
* should not install a package in the lib directory
* should put a package in the lib bad directory

#### when installing a package with a dependent package that also depends on a less constrained but still valid dependency of the same package

* [PENDING] should contain a message that everything installed successfully
Expand Down
Binary file added lib/PowerShell/System.Management.Automation.dll
Binary file not shown.
15 changes: 11 additions & 4 deletions nuget/chocolatey/chocolatey.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,27 @@ We have some great guidance on how to do that. Where? I'll give you a hint, it r
In that mess there is a link to the [Helper Reference](https://github.com/chocolatey/choco/wiki/HelpersReference).
</description>
<releaseNotes>
See all - https://github.com/chocolatey/choco/blob/master/CHANGELOG.md
See all - https://github.com/chocolatey/choco/blob/stable/CHANGELOG.md

## 0.9.10
## 0.9.10

Alternative sources (webpi, windowsfeature, cygwin, etc) are back (finally, right?)! Use an internal PowerShell host to take advantage of quite a few improvements!

Alternative sources (webpi, windowsfeature, cygwin, etc) are back (finally, right?)!
### BREAKING CHANGES

* Only fail automation scripts (chocolateyInstall.ps1) if the script returns non-zero exit code - see [#445](https://github.com/chocolatey/choco/issues/445)

### FEATURES

* Alternative sources - see [#14](https://github.com/chocolatey/choco/issues/14)
* Alternative Sources - see [#14](https://github.com/chocolatey/choco/issues/14)
* Use Internal PowerShell Host - see [#8](https://github.com/chocolatey/choco/issues/8)
* Support for custom headers - see [#332](https://github.com/chocolatey/choco/issues/332)

### BUG FIXES

* Fix - Debug/Verbose messages not logged in install scripts (chocolateyInstall.ps1) - see [#520](https://github.com/chocolatey/choco/issues/520)
* Fix - Logger doesn't clear cached NullLoggers - see [#516](https://github.com/chocolatey/choco/issues/516)
* Fix - DISM "/All" argument in the wrong position - see [#480](https://github.com/chocolatey/choco/issues/480)
* Fix - Merging assemblies on a machine running .net 4.5 or higher produces binaries incompatible with .net 4 - see [#392](https://github.com/chocolatey/choco/issues/392)
* Fix - API - Incorrect log4net version in chocolatey.lib dependencies - see [#390](https://github.com/chocolatey/choco/issues/390)

Expand Down
4 changes: 4 additions & 0 deletions src/chocolatey.console/chocolatey.console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Management.Automation">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\PowerShell\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
Expand Down
5 changes: 5 additions & 0 deletions src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
[string]$packageScript
)

$DebugPreference = "SilentlyContinue"
if ($env:ChocolateyEnvironmentDebug -eq 'true') { $DebugPreference = "Continue"; }
$VerbosePreference = "SilentlyContinue"
if ($env:ChocolateyEnvironmentVerbose -eq 'true') { $VerbosePreference = "Continue"; $verbosity = $true }

Write-Debug "Running 'ChocolateyScriptRunner' for $($env:packageName) v$($env:packageVersion) with packageScript `'$packageScript`', packageFolder:`'$($env:packageFolder)`', installArguments: `'$installArguments`', packageParameters: `'$packageParameters`',"

## Set the culture to invariant
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
$packageName = 'badpackage'
try {

try {

Write-Host "Ya!"
Write-Debug "A debug message"
Write-Output "This is $packageName v$packageVersion being installed to `n '$packageFolder'."
Write-Host "PowerShell Version is '$($PSVersionTable.PSVersion)' and CLR Version is '$($PSVersionTable.CLRVersion)'."
Write-Host "Execution Policy is '$(Get-ExecutionPolicy)'."
Write-Host "PSScriptRoot is '$PSScriptRoot'."
Write-Debug "A debug message."
Write-Verbose "Yo!"
Write-Warning "A warning!"
Write-Error "Oh no! An error"
throw "We had an error captain!"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
$packageName = 'badpackage'
try {

try {

Write-Host "Ya!"
Write-Debug "A debug message"
Write-Output "This is $packageName v$packageVersion being installed to `n '$packageFolder'."
Write-Host "PowerShell Version is '$($PSVersionTable.PSVersion)' and CLR Version is '$($PSVersionTable.CLRVersion)'."
Write-Host "Execution Policy is '$(Get-ExecutionPolicy)'."
Write-Host "PSScriptRoot is '$PSScriptRoot'."
Write-Debug "A debug message."
Write-Verbose "Yo!"
Write-Warning "A warning!"
Write-Error "Oh no! An error"
throw "We had an error captain!"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
"simple file" | Out-File "$toolsDir\simplefile.txt" -force

Write-Output "$env:PackageName $env:PackageVersion Installed"
Write-Output "This is $packageName v$packageVersion being installed to `n $packageFolder"
Write-Host "Ya!"
Write-Debug "A debug message"
Write-Verbose "Yo!"
Write-Warning "A warning!"

Write-Output "$packageName v$packageVersion has been installed to `n $packageFolder"
21 changes: 21 additions & 0 deletions src/chocolatey/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace chocolatey
{
using System;
using System.Globalization;
using System.Security;
using System.Text.RegularExpressions;
using infrastructure.app;
using infrastructure.logging;
Expand Down Expand Up @@ -83,6 +84,26 @@ public static string to_string(this string input)
return input;
}

/// <summary>
/// Takes a string and returns a secure string
/// </summary>
/// <param name="input">The input.</param>
/// <returns></returns>
public static SecureString to_secure_string(this string input)
{
var secureString = new SecureString();

if (string.IsNullOrWhiteSpace(input)) return secureString;

foreach (char character in input)
{
secureString.AppendChar(character);
}

return secureString;
}


private static readonly Regex _spacePattern = new Regex(@"\s", RegexOptions.Compiled);

/// <summary>
Expand Down
12 changes: 11 additions & 1 deletion src/chocolatey/chocolatey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\PowerShell\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Core">
<HintPath>..\packages\Rx-Core.2.1.30214.0\lib\Net40\System.Reactive.Core.dll</HintPath>
</Reference>
Expand All @@ -78,6 +82,8 @@
<Link>Properties\SolutionVersion.cs</Link>
</Compile>
<Compile Include="AssemblyExtensions.cs" />
<Compile Include="infrastructure\commandline\ReadKeyTimeout.cs" />
<Compile Include="infrastructure\commands\Execute.cs" />
<Compile Include="GetChocolatey.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyConfigCommand.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyFeatureCommand.cs" />
Expand Down Expand Up @@ -116,6 +122,9 @@
<Compile Include="infrastructure.app\services\IConfigTransformService.cs" />
<Compile Include="infrastructure.app\services\IFilesService.cs" />
<Compile Include="infrastructure.app\services\ISourceRunner.cs" />
<Compile Include="infrastructure\powershell\PoshHost.cs" />
<Compile Include="infrastructure\powershell\PoshHostRawUserInterface.cs" />
<Compile Include="infrastructure\powershell\PoshHostUserInterface.cs" />
<Compile Include="infrastructure.app\templates\ChocolateyReadMeTemplate.cs" />
<Compile Include="infrastructure.app\services\PythonService.cs" />
<Compile Include="infrastructure.app\services\RubyGemsService.cs" />
Expand Down Expand Up @@ -203,6 +212,7 @@
<Compile Include="infrastructure.app\domain\CommandNameType.cs" />
<Compile Include="infrastructure\events\EventManager.cs" />
<Compile Include="infrastructure\events\IEvent.cs" />
<Compile Include="infrastructure\commandline\ReadLineTimeout.cs" />
<Compile Include="infrastructure\registration\SimpleInjectorContainer.cs" />
<Compile Include="infrastructure\results\IResult.cs" />
<Compile Include="infrastructure\results\PackageResult.cs" />
Expand Down Expand Up @@ -288,4 +298,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static class Features
public static readonly string FailOnAutoUninstaller = "failOnAutoUninstaller";
public static readonly string AllowGlobalConfirmation = "allowGlobalConfirmation";
public static readonly string FailOnStandardError = "failOnStandardError";
public static readonly string UsePowerShellHost = "powershellHost";
}

public static class Messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private static void set_feature_flags(ChocolateyConfiguration config, ConfigFile
config.Features.AutoUninstaller = set_feature_flag(ApplicationParameters.Features.AutoUninstaller, configFileSettings, defaultEnabled: true, description: "Uninstall from programs and features without requiring an explicit uninstall script.");
config.Features.FailOnAutoUninstaller = set_feature_flag(ApplicationParameters.Features.FailOnAutoUninstaller, configFileSettings, defaultEnabled: false, description: "Fail if automatic uninstaller fails.");
config.Features.FailOnStandardError = set_feature_flag(ApplicationParameters.Features.FailOnStandardError, configFileSettings, defaultEnabled: false, description: "Fail if install provider writes to stderr.");
config.Features.UsePowerShellHost = set_feature_flag(ApplicationParameters.Features.UsePowerShellHost, configFileSettings, defaultEnabled: true, description: "Use Chocolatey's built-in PowerShell host.");
config.PromptForConfirmation = !set_feature_flag(ApplicationParameters.Features.AllowGlobalConfirmation, configFileSettings, defaultEnabled: false, description: "Prompt for confirmation in scripts or bypass.");
}

Expand Down Expand Up @@ -264,6 +265,9 @@ private static void set_global_options(IList<string> args, ChocolateyConfigurati
.Add("failstderr|failonstderr|fail-on-stderr|fail-on-standard-error|fail-on-error-output",
"FailOnStandardError - Fail on standard error output (stderr), typically received when running external commands during install providers. This overrides the feature failOnStandardError.",
option => config.Features.FailOnStandardError = option != null)
.Add("use-system-powershell",
"UseSystemPowerShell - Execute PowerShell using an external process instead of the built-in PowerShell host.",
option => config.Features.UsePowerShellHost = option == null)
;
},
(unparsedArgs) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public sealed class FeaturesConfiguration
public bool CheckSumFiles { get; set; }
public bool FailOnAutoUninstaller { get; set; }
public bool FailOnStandardError { get; set; }
public bool UsePowerShellHost { get; set; }
}

//todo: retrofit other command configs this way
Expand Down
Loading

0 comments on commit 8ba0c8e

Please sign in to comment.