diff --git a/recipe/chocolatey-package.cake b/recipe/chocolatey-package.cake index cfe1dd5..3c82da2 100644 --- a/recipe/chocolatey-package.cake +++ b/recipe/chocolatey-package.cake @@ -41,4 +41,12 @@ public class ChocolateyPackage : PackageDefinition ArgumentCustomization = args => args.Append($"BIN_DIR={BuildSettings.OutputDirectory}") }); } + + protected override bool IsRemovableExtension(string id) + { + return + id.StartsWith("nunit-extension-") && + !id.StartsWith(PackageId) && + !id.Contains("pluggable-agent"); + } } diff --git a/recipe/nuget-package.cake b/recipe/nuget-package.cake index 70f7794..2222795 100644 --- a/recipe/nuget-package.cake +++ b/recipe/nuget-package.cake @@ -99,4 +99,12 @@ public class NuGetPackage : PackageDefinition else throw new Exception("Verification failed!"); } + + protected override bool IsRemovableExtension(string id) + { + return + id.StartsWith("NUnit.Extension.") && + !id.StartsWith(PackageId) && + !id.Contains("PluggableAgent"); + } } diff --git a/recipe/package-definition.cake b/recipe/package-definition.cake index 0140618..6a197d3 100644 --- a/recipe/package-definition.cake +++ b/recipe/package-definition.cake @@ -210,7 +210,15 @@ public abstract class PackageDefinition // Ensure we start out each package with no extensions installed. // If any package test installs an extension, it remains available // for subsequent tests of the same package only. - RemoveExtensions(); + foreach (DirectoryPath dirPath in _context.GetDirectories(ExtensionInstallDirectory + "*")) + { + string dirName = dirPath.Segments.Last(); + if (IsRemovableExtension(dirName)) + { + _context.DeleteDirectory(dirPath, new DeleteDirectorySettings() { Recursive = true }); + _context.Information("Deleted directory " + dirPath.GetDirectoryName()); + } + } // Package was defined with one or more TestRunners. These // may or may not require installation. @@ -297,20 +305,7 @@ public abstract class PackageDefinition extension.InstallExtension(this); } - // Remove all extensions prior to starting a run. Note that we avoid removing the the - // package being developed, which may actually be an extension itself. - protected void RemoveExtensions() - { - foreach (DirectoryPath dirPath in _context.GetDirectories(ExtensionInstallDirectory + "*")) - { - string dirName = dirPath.Segments.Last(); - if ((dirName.StartsWith("NUnit.Extension.") || dirName.StartsWith("nunit-extension-")) && !dirName.StartsWith(PackageId)) - { - _context.DeleteDirectory(dirPath, new DeleteDirectorySettings() { Recursive = true }); - _context.Information("Deleted directory " + dirPath.GetDirectoryName()); - } - } - } + protected abstract bool IsRemovableExtension(string dirName); private void InstallRunners(IEnumerable runners) { diff --git a/recipe/zip-package.cake b/recipe/zip-package.cake index e1e524e..81d0845 100644 --- a/recipe/zip-package.cake +++ b/recipe/zip-package.cake @@ -65,4 +65,12 @@ public class ZipPackage : PackageDefinition _context.CopyDirectory(BuildSettings.ExtensionsDirectory, BuildSettings.ZipImageDirectory); } + + protected override bool IsRemovableExtension(string id) + { + return + id.StartsWith("NUnit.Extension.") && + !id.StartsWith(PackageId) && + !id.Contains("PluggableAgent"); + } }