@@ -210,7 +210,15 @@ public abstract class PackageDefinition
210210 // Ensure we start out each package with no extensions installed.
211211 // If any package test installs an extension, it remains available
212212 // for subsequent tests of the same package only.
213- RemoveExtensions ( ) ;
213+ foreach ( DirectoryPath dirPath in _context . GetDirectories ( ExtensionInstallDirectory + "*" ) )
214+ {
215+ string dirName = dirPath . Segments . Last ( ) ;
216+ if ( IsRemovableExtension ( dirName ) )
217+ {
218+ _context . DeleteDirectory ( dirPath , new DeleteDirectorySettings ( ) { Recursive = true } ) ;
219+ _context . Information ( "Deleted directory " + dirPath . GetDirectoryName ( ) ) ;
220+ }
221+ }
214222
215223 // Package was defined with one or more TestRunners. These
216224 // may or may not require installation.
@@ -297,20 +305,7 @@ public abstract class PackageDefinition
297305 extension . InstallExtension ( this ) ;
298306 }
299307
300- // Remove all extensions prior to starting a run. Note that we avoid removing the the
301- // package being developed, which may actually be an extension itself.
302- protected void RemoveExtensions ( )
303- {
304- foreach ( DirectoryPath dirPath in _context . GetDirectories ( ExtensionInstallDirectory + "*" ) )
305- {
306- string dirName = dirPath . Segments . Last ( ) ;
307- if ( ( dirName . StartsWith ( "NUnit.Extension." ) || dirName . StartsWith ( "nunit-extension-" ) ) && ! dirName . StartsWith ( PackageId ) )
308- {
309- _context . DeleteDirectory ( dirPath , new DeleteDirectorySettings ( ) { Recursive = true } ) ;
310- _context . Information ( "Deleted directory " + dirPath . GetDirectoryName ( ) ) ;
311- }
312- }
313- }
308+ protected abstract bool IsRemovableExtension ( string dirName ) ;
314309
315310 private void InstallRunners ( IEnumerable < IPackageTestRunner > runners )
316311 {
0 commit comments