internal void RemoveOldTempFiles()
        {
            this.RemoveCodegenResourceDir();
            string path = base._cacheDir + @"\";

            foreach (FileData data in (IEnumerable)FileEnumerator.Create(path))
            {
                if (!data.IsDirectory)
                {
                    string extension = Path.GetExtension(data.Name);
                    switch (extension)
                    {
                    case ".dll":
                    case ".pdb":
                    case ".web":
                    case ".ccu":
                    case ".compiled":
                    {
                        continue;
                    }
                    }
                    if (extension != ".delete")
                    {
                        int length = data.Name.LastIndexOf('.');
                        if (length <= 0)
                        {
                            goto Label_013A;
                        }
                        string str3  = data.Name.Substring(0, length);
                        int    index = str3.IndexOf('.');
                        int    num3  = str3.LastIndexOf('.');
                        if ((num3 > 0) && (index != num3))
                        {
                            str3 = str3.Substring(0, num3);
                        }
                        if (!FileUtil.FileExists(path + str3 + ".dll") && !FileUtil.FileExists(path + "App_Web_" + str3 + ".dll"))
                        {
                            goto Label_013A;
                        }
                    }
                    else
                    {
                        DiskBuildResultCache.CheckAndRemoveDotDeleteFile(new FileInfo(data.FullName));
                    }
                }
                continue;
Label_013A:
                Util.DeleteFileNoException(data.FullName);
            }
        }
コード例 #2
0
        /*
         * Delete all temporary files from the codegen directory (e.g. source files, ...)
         */
        internal void RemoveOldTempFiles()
        {
            Debug.Trace("BuildResultCache", "Deleting old temporary files from " + _cacheDir);

            RemoveCodegenResourceDir();

            string codegen = _cacheDir + "\\";

            // Go through all the files in the codegen dir
            foreach (FileData fileData in FileEnumerator.Create(codegen))
            {
                // Skip directories
                if (fileData.IsDirectory)
                {
                    continue;
                }

                // If it has a known extension, skip it
                string ext = Path.GetExtension(fileData.Name);
                if (ext == ".dll" || ext == ".pdb" || ext == ".web" || ext == ".ccu" || ext == ".prof" || ext == preservationFileExtension)
                {
                    continue;
                }

                // .delete files need to be removed.
                if (ext != dotDelete)
                {
                    // Don't delete the temp file if it's named after a dll that's still around
                    // since it could still be useful for debugging.
                    // Note that we can't use GetFileNameWithoutExtension here because
                    // some of the files are named 5hvoxl6v.0.cs, and it would return
                    // 5hvoxl6v.0 instead of just 5hvoxl6v
                    int periodIndex = fileData.Name.LastIndexOf('.');
                    if (periodIndex > 0)
                    {
                        string baseName = fileData.Name.Substring(0, periodIndex);

                        int secondPeriodIndex = baseName.LastIndexOf('.');
                        if (secondPeriodIndex > 0)
                        {
                            baseName = baseName.Substring(0, secondPeriodIndex);
                        }

                        // Generated source files uses assemblyname as prefix so we should keep them.
                        if (FileUtil.FileExists(codegen + baseName + ".dll"))
                        {
                            continue;
                        }

                        // other generated files, such as .cmdline, .err and .out need to add the
                        // WebAssemblyNamePrefix, since they do not use the assembly name as prefix.
                        if (FileUtil.FileExists(codegen + BuildManager.WebAssemblyNamePrefix + baseName + ".dll"))
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    // Additional logic for VSWhidbey 564168 / Visual Studio QFE 4710.
                    // Delete both original .dll and .delete if possible
                    DiskBuildResultCache.CheckAndRemoveDotDeleteFile(new FileInfo(fileData.FullName));
                    continue;
                }

                Debug.Trace("BuildResultCache", "Deleting old temporary files: " + fileData.FullName);
                try {
                    File.Delete(fileData.FullName);
                } catch { }
            }
        }