public override string GetFileHash(string virtualPath, IEnumerable virtualPathDependencies) { HashCodeCombiner hashCodeCombiner = new HashCodeCombiner(); // Calculate the hash based on the time stamps of all the virtual paths foreach (string virtualDependency in virtualPathDependencies) { string physicalDependency = HostingEnvironment.MapPathInternal(virtualDependency); hashCodeCombiner.AddFile(physicalDependency); } return hashCodeCombiner.CombinedHashString; }
protected override void ComputeHashCode(HashCodeCombiner hashCodeCombiner) { base.ComputeHashCode(hashCodeCombiner); if (base.VirtualPath != null) { Assembly localResourcesAssembly = BuildManager.GetLocalResourcesAssembly(base.VirtualPath.Parent); if (localResourcesAssembly != null) { hashCodeCombiner.AddFile(localResourcesAssembly.Location); } } }
/* * Check if the top level files are up to date, and cleanup the codegendir * if they are not. */ private long CheckTopLevelFilesUpToDateInternal(long cachedHash) { Debug.Trace("BuildManager", "specialFilesCombinedHash=" + cachedHash); var specialFilesHashCodeCombiner = new HashCodeCombiner(); // Delete all the non essential files left over in the codegen dir, unless // specialFilesCombinedHash is 0, in which case we delete *everything* further down if (cachedHash != 0) { _codeGenCache.RemoveOldTempFiles(); } // Use a HashCodeCombiner object to handle the time stamps of all the 'special' // files and directories that all compilations depend on: // - System.Web.dll (in case there is a newer version of ASP.NET) // - ~\Bin directory // - ~\Resource directory // - ~\WebReferences directory // - ~\Code directory // - global.asax // Add a check for the app's physical path, in case it changes (ASURT 12975) specialFilesHashCodeCombiner.AddObject(HttpRuntime.AppDomainAppPathInternal); // Process System.Web.dll string aspBinaryFileName = typeof(HttpRuntime).Module.FullyQualifiedName; if (!AppSettings.PortableCompilationOutput) { specialFilesHashCodeCombiner.AddFile(aspBinaryFileName); } else { specialFilesHashCodeCombiner.AddExistingFileVersion(aspBinaryFileName); } // Process machine.config string machineConfigFileName = HttpConfigurationSystem.MachineConfigurationFilePath; if (!AppSettings.PortableCompilationOutput) { specialFilesHashCodeCombiner.AddFile(machineConfigFileName); } else { specialFilesHashCodeCombiner.AddFileContentHash(machineConfigFileName); } // Process root web.config string rootWebConfigFileName = HttpConfigurationSystem.RootWebConfigurationFilePath; if (!AppSettings.PortableCompilationOutput) { specialFilesHashCodeCombiner.AddFile(rootWebConfigFileName); } else { specialFilesHashCodeCombiner.AddFileContentHash(rootWebConfigFileName); } RuntimeConfig appConfig = RuntimeConfig.GetAppConfig(); CompilationSection compConfig = appConfig.Compilation; // Ignore the OptimizeCompilations flag in ClientBuildManager mode if (!BuildManagerHost.InClientBuildManager) { _optimizeCompilations = compConfig.OptimizeCompilations; } // In optimized compilation mode, we don't clean out all the compilations just because a top level // file changes. Instead, we let already compiled pages run against the newer top level binaries. // In can be incorrect in some cases (e.g. return type of method changes from int to short), which is // why the optimization is optional if (!OptimizeCompilations) { // Add a dependency of the bin, resources, webresources and code directories string binPhysicalDir = HttpRuntime.BinDirectoryInternal; specialFilesHashCodeCombiner.AddDirectory(binPhysicalDir); // Note that we call AddResourcesDirectory instead of AddDirectory, since we only want // culture neutral files to be taken into account (VSWhidbey 359029) specialFilesHashCodeCombiner.AddResourcesDirectory(HttpRuntime.ResourcesDirectoryVirtualPath.MapPathInternal()); specialFilesHashCodeCombiner.AddDirectory(HttpRuntime.WebRefDirectoryVirtualPath.MapPathInternal()); specialFilesHashCodeCombiner.AddDirectory(HttpRuntime.CodeDirectoryVirtualPath.MapPathInternal()); // Add a dependency on the global asax file. specialFilesHashCodeCombiner.AddFile(GlobalAsaxVirtualPath.MapPathInternal()); } // Add a dependency on the hash of the app level <compilation> section, since it // affects all compilations, including the code directory. It it changes, // we may as well, start all over. specialFilesHashCodeCombiner.AddObject(compConfig.RecompilationHash); ProfileSection profileSection = appConfig.Profile; specialFilesHashCodeCombiner.AddObject(profileSection.RecompilationHash); // Add a dependency on file encoding (DevDiv 4560) specialFilesHashCodeCombiner.AddObject(appConfig.Globalization.FileEncoding); // Also add a dependency on the <trust> config section TrustSection casConfig = appConfig.Trust; specialFilesHashCodeCombiner.AddObject(casConfig.Level); specialFilesHashCodeCombiner.AddObject(casConfig.OriginUrl); // Add a dependency on whether profile is enabled specialFilesHashCodeCombiner.AddObject(ProfileManager.Enabled); // Add a dependency to the force debug flag. specialFilesHashCodeCombiner.AddObject(PrecompilingWithDebugInfo); CheckCodeGenFiles(specialFilesHashCodeCombiner.CombinedHash, cachedHash); return specialFilesHashCodeCombiner.CombinedHash; }
protected override void ComputeHashCode(HashCodeCombiner hashCodeCombiner) { base.ComputeHashCode(hashCodeCombiner); // Make pages have a dependency on the main local resources assembly, so that they // get recompiled when it changes (but not when satellites change). VSWhidbey 277357 if (VirtualPath != null) { // Remove the file name to get its directory VirtualPath virtualDir = VirtualPath.Parent; Assembly localResAssembly = BuildManager.GetLocalResourcesAssembly(virtualDir); if (localResAssembly != null) { hashCodeCombiner.AddFile(localResAssembly.Location); } } }