private void RemoveAssemblyAndCleanupDependencies(string assemblyName) { bool gotLock = false; try { CompilationLock.GetLock(ref gotLock); lock (this._dependentAssemblies) { this.RemoveAssemblyAndCleanupDependenciesNoLock(assemblyName); } } finally { if (gotLock) { CompilationLock.ReleaseLock(); } DiskBuildResultCache.ShutDownAppDomainIfRequired(); } }
private void RemoveAssemblyAndCleanupDependencies(string assemblyName) { bool gotLock = false; try { // Grab the compilation mutex, since we will remove cached build result CompilationLock.GetLock(ref gotLock); // Protect the dependent assemblies table, as it's accessed/modified in the recursion lock (_dependentAssemblies) { RemoveAssemblyAndCleanupDependenciesNoLock(assemblyName); } } finally { // Always release the mutex if we had taken it if (gotLock) { CompilationLock.ReleaseLock(); } DiskBuildResultCache.ShutDownAppDomainIfRequired(); } }
/* * Delete an assembly and all its related files. The assembly is typically named * something like ASPNET.jnw_y10n.dll, while related files are simply jnw_y10n.*. */ internal virtual void RemoveAssemblyAndRelatedFiles(string assemblyName) { Debug.Trace("DiskBuildResultCache", "RemoveAssemblyAndRelatedFiles(" + assemblyName + ")"); // If the name doesn't start with the prefix, the cleanup code doesn't apply if (!assemblyName.StartsWith(BuildManager.WebAssemblyNamePrefix, StringComparison.Ordinal)) { return; } // Get rid of the prefix, since related files don't have it string baseName = assemblyName.Substring(BuildManager.WebAssemblyNamePrefix.Length); bool gotLock = false; try { // Grab the compilation mutex, since we will remove generated assembly CompilationLock.GetLock(ref gotLock); DirectoryInfo directory = new DirectoryInfo(_cacheDir); // Find all the files that contain the base name FileInfo[] files = directory.GetFiles("*" + baseName + ".*"); foreach (FileInfo f in files) { if (f.Extension == ".dll") { // Notify existing buildresults that result assembly will be removed. // This is required otherwise new components can be compiled // with obsolete build results whose assembly has been removed. string assemblyKey = GetAssemblyCacheKey(f.FullName); HttpRuntime.CacheInternal.Remove(assemblyKey); // Remove the assembly RemoveAssembly(f); // Also, remove satellite assemblies that may be associated with it StandardDiskBuildResultCache.RemoveSatelliteAssemblies(assemblyName); } else if (f.Extension == dotDelete) { CheckAndRemoveDotDeleteFile(f); } else { // Remove the file, or if not possible, rename it, so it'll get // cleaned up next time by RemoveOldTempFiles() TryDeleteFile(f); } } } finally { // Always release the mutex if we had taken it if (gotLock) { CompilationLock.ReleaseLock(); } DiskBuildResultCache.ShutDownAppDomainIfRequired(); } }