From e67c085e0154d8966ea93acb83bf8ca4e345814b Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 20 Mar 2019 16:40:13 -0700 Subject: [PATCH 1/3] Changing back to non-zipped compatibility profiles The size savings aren't there, as the gallery stores modules as nuget files. Also, there was an issue that if you installed into the public location as administrator and then ran as a regular user, a catastrophic failure in analyzer occurred. --- Rules/CompatibilityRules/CompatibilityRule.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/Rules/CompatibilityRules/CompatibilityRule.cs b/Rules/CompatibilityRules/CompatibilityRule.cs index 59215b478..0d4b52bd3 100644 --- a/Rules/CompatibilityRules/CompatibilityRule.cs +++ b/Rules/CompatibilityRules/CompatibilityRule.cs @@ -24,15 +24,9 @@ public abstract class CompatibilityRule : ConfigurableRule // The name of the directory where compatibility profiles are looked for by default. private const string PROFILE_DIR_NAME = "compatibility_profiles"; - // The name of the file to hydrate the compatibility profile assets from. - private const string PROFILE_ZIP_NAME = "compatibility_profiles.zip"; - // The full path of the directory where compatiblity profiles are looked for by default. private static readonly string s_defaultProfileDirPath; - // The full path of the file where the zipped compatibility profiles are. - private static readonly string s_profileZipPath; - // Memoized path to the module root of PSScriptAnalyzer. private static readonly Lazy s_moduleRootDirPath; @@ -45,10 +39,6 @@ static CompatibilityRule() { s_moduleRootDirPath = new Lazy(() => GetModuleRootDirPath()); s_defaultProfileDirPath = Path.Combine(s_moduleRootDirPath.Value, PROFILE_DIR_NAME); - s_profileZipPath = Path.Combine(s_moduleRootDirPath.Value, PROFILE_ZIP_NAME); - - // On first run, we need to make sure the profile assets have been hydrated from the zip - ExpandZipToDirectory(s_profileZipPath, s_defaultProfileDirPath); } private readonly CompatibilityProfileLoader _profileLoader; @@ -238,18 +228,6 @@ private static string GetModuleRootDirPath() return Path.GetFullPath(nonNormalizedRoot); } - private static void ExpandZipToDirectory(string zipPath, string destinationDirectoryPath) - { - // Assume that if the directory already exists, there is nothing to do. - // Profile unzipping can be forced by deleting the directory. - if (Directory.Exists(destinationDirectoryPath)) - { - return; - } - - // Note: This method will throw if the directory already exists - ZipFile.ExtractToDirectory(zipPath, destinationDirectoryPath, Encoding.UTF8); - } } /// From 85774a2c76090e00ed97dedd6747e39826d6dac8 Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 20 Mar 2019 19:21:19 -0700 Subject: [PATCH 2/3] Update build script to copy profiles into place --- build.psm1 | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/build.psm1 b/build.psm1 index 3267ed04c..4b50cb163 100644 --- a/build.psm1 +++ b/build.psm1 @@ -118,24 +118,9 @@ function Copy-CompatibilityProfiles } $profileDir = [System.IO.Path]::Combine($PSScriptRoot, 'PSCompatibilityAnalyzer', 'profiles') - $destinationDir = [System.IO.Path]::Combine($PSScriptRoot, 'out', 'PSScriptAnalyzer') - $destination = Join-Path $destinationDir 'compatibility_profiles.zip' + $destinationDir = [System.IO.Path]::Combine($PSScriptRoot, 'out', 'PSScriptAnalyzer', "compatability_profiles") - if (Test-Path -LiteralPath $destinationDir -PathType Container) - { - Remove-Item -Force -Recurse $destination -ErrorAction Ignore - } - else - { - $null = New-Item -Path $destinationDir -ItemType Directory - } - - [System.IO.Compression.ZipFile]::CreateFromDirectory( - $profileDir, - $destination, - [System.IO.Compression.CompressionLevel]::Optimal, - <# includeBaseDirectory #> $false, - [System.Text.Encoding]::UTF8) + Copy-Item -Recurse $profileDir $destinationDir } # build script analyzer (and optionally build everything with -All) From b6c1cc8e7734ec7af82e3a2d5eeb6b58794b7818 Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Thu, 21 Mar 2019 05:57:19 +0000 Subject: [PATCH 3/3] Fix build by correcting typo in compatibility_profiles directory --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index 4b50cb163..38b80d4a0 100644 --- a/build.psm1 +++ b/build.psm1 @@ -118,7 +118,7 @@ function Copy-CompatibilityProfiles } $profileDir = [System.IO.Path]::Combine($PSScriptRoot, 'PSCompatibilityAnalyzer', 'profiles') - $destinationDir = [System.IO.Path]::Combine($PSScriptRoot, 'out', 'PSScriptAnalyzer', "compatability_profiles") + $destinationDir = [System.IO.Path]::Combine($PSScriptRoot, 'out', 'PSScriptAnalyzer', "compatibility_profiles") Copy-Item -Recurse $profileDir $destinationDir }