Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-326) Remove ShimGen directors on upgrade
  • Loading branch information
ferventcoder committed Jun 13, 2015
2 parents 28eb680 + b2a1143 commit 021d61b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static class Environment
public static int DefaultWaitForExitInSeconds = 2700;

public static readonly string[] ConfigFileExtensions = new string[] {".autoconf",".config",".conf",".cfg",".jsc",".json",".jsonp",".ini",".xml",".yaml"};
public static readonly string[] ShimDirectorFileExtensions = new string[] {".gui",".ignore"};

public static readonly string HashProviderFileTooBig = "UnableToDetectChanges_FileTooBig";
public static readonly string HashProviderFileLocked = "UnableToDetectChanges_FileLocked";
Expand Down
38 changes: 38 additions & 0 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
{
rename_legacy_package_version(config, installedPackage, pkgInfo);
backup_existing_version(config, installedPackage, pkgInfo);
remove_shim_directors(config, installedPackage, pkgInfo);
if (config.Force && (installedPackage.Version == availablePackage.Version))
{
FaultTolerance.try_catch_with_logging_exception(
Expand Down Expand Up @@ -748,6 +749,43 @@ public void backup_changed_files(string packageInstallPath, ChocolateyConfigurat
}
}

/// <summary>
/// Remove the shimgen director files from the package.
/// These are .gui/.ignore files that may have been created during the installation
/// process and won't be pulled by the nuget package replacement.
/// This usually happens when package maintainers haven't been very good about how
/// they create the files in the past (not using force with new-item typically throws
/// an error if the file exists).
/// </summary>
/// <param name="config">The configuration.</param>
/// <param name="installedPackage">The installed package.</param>
/// <param name="pkgInfo">The package information.</param>
private void remove_shim_directors(ChocolateyConfiguration config, IPackage installedPackage, ChocolateyPackageInformation pkgInfo)
{
var pathResolver = NugetCommon.GetPathResolver(config, NugetCommon.GetNuGetFileSystem(config, _nugetLogger));
var pkgInstallPath = pathResolver.GetInstallPath(installedPackage);
if (!_fileSystem.directory_exists(pkgInstallPath))
{
var chocoPathResolver = pathResolver as ChocolateyPackagePathResolver;
if (chocoPathResolver != null)
{
chocoPathResolver.UseSideBySidePaths = !chocoPathResolver.UseSideBySidePaths;
pkgInstallPath = chocoPathResolver.GetInstallPath(installedPackage);
}
}

if (_fileSystem.directory_exists(pkgInstallPath))
{
var shimDirectorFiles = _fileSystem.get_files(pkgInstallPath, ApplicationParameters.ShimDirectorFileExtensions, SearchOption.AllDirectories);
foreach (var file in shimDirectorFiles.or_empty_list_if_null())
{
FaultTolerance.try_catch_with_logging_exception(
() => _fileSystem.delete_file(file),
"Error deleting shim director file");
}
}
}

public void uninstall_noop(ChocolateyConfiguration config, Action<PackageResult> continueAction)
{
var results = uninstall_run(config, continueAction, performAction: false);
Expand Down

0 comments on commit 021d61b

Please sign in to comment.