//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods // // Initialze the local xaml cache file. // // return value: // // If cache doesn't exist, or both LocalAppDef and LocallXaml Pages do not exist, return false // to indicate no further work required. // otherwise, return true. // private bool InitLocalXamlCache() { bool hasLocalFiles = false; _compilerLocalRefCache = new CompilerLocalReference( OutputPath + AssemblyName + (TaskFileService.IsRealBuild? SharedStrings.LocalTypeCacheFile : SharedStrings.IntellisenseLocalTypeCacheFile), _taskFileService); if (_compilerLocalRefCache.CacheFileExists()) { _compilerLocalRefCache.LoadCacheFile(); _localApplicationFile = _compilerLocalRefCache.LocalApplicationFile; _localMarkupPages = _compilerLocalRefCache.LocalMarkupPages; if (_localApplicationFile != null || (_localMarkupPages != null && _localMarkupPages.Length > 0)) { hasLocalFiles = true; // // Initialize InternalTypeHelper file from the cache file first. // Further handling will be taken after the xaml file compilation is done. // // If InternalTypeHelperFile is set in the Cache file, it means Pass1 cannot // detect whether or not to keep the InternalTypeHelper File until the Pass2 // xaml file compilation is done. // _internalTypeHelperFile = _compilerLocalRefCache.InternalTypeHelperFile; } } return hasLocalFiles; }
// // Generate new list of files that require to recompile for incremental build based on _analyzeResult // private void UpdateFileListForIncrementalBuild(List <FileUnit> modifiedXamlFiles) { List <FileUnit> recompiledXaml = new List <FileUnit>(); bool recompileApp = false; int numLocalTypeXamls = 0; if ((_analyzeResult & RecompileCategory.ContentFiles) == RecompileCategory.ContentFiles) { RecompileContentFiles(); } if ((_analyzeResult & RecompileCategory.ApplicationFile) == RecompileCategory.ApplicationFile) { recompileApp = true; } if ((_analyzeResult & RecompileCategory.PagesWithLocalType) == RecompileCategory.PagesWithLocalType && TaskFileService.IsRealBuild) { CompilerLocalReference.LoadCacheFile(); if (CompilerLocalReference.LocalApplicationFile != null) { // Application file contains local types, it will be recompiled. recompileApp = true; } if (ListIsNotEmpty(CompilerLocalReference.LocalMarkupPages)) { numLocalTypeXamls = CompilerLocalReference.LocalMarkupPages.Length; for (int i = 0; i < CompilerLocalReference.LocalMarkupPages.Length; i++) { LocalReferenceFile localRefFile = CompilerLocalReference.LocalMarkupPages[i]; recompiledXaml.Add(new FileUnit( localRefFile.FilePath, localRefFile.LinkAlias, localRefFile.LogicalName)); } } } if ((_analyzeResult & RecompileCategory.ModifiedPages) == RecompileCategory.ModifiedPages) { // If the xaml is already in the local-type-ref xaml file list, don't add a duplicate file path to recompiledXaml list. for (int i = 0; i < modifiedXamlFiles.Count; i++) { FileUnit xamlfile = modifiedXamlFiles[i]; bool addToList; addToList = true; if (numLocalTypeXamls > 0) { for (int j = 0; j < numLocalTypeXamls; j++) { if (String.Compare(xamlfile.Path, CompilerLocalReference.LocalMarkupPages[j].FilePath, StringComparison.OrdinalIgnoreCase) == 0) { addToList = false; break; } } } if (addToList) { recompiledXaml.Add(xamlfile); } } } if (recompiledXaml.Count > 0) { _recompileMarkupPages = recompiledXaml.ToArray(); } // Set ApplicationFile appropriatelly for this incremental build. ProcessApplicationFile(recompileApp); }
// // Generate new list of files that require to recompile for incremental build based on _analyzeResult // private void UpdateFileListForIncrementalBuild(List <FileUnit> modifiedXamlFiles) { List <FileUnit> recompiledXaml = new List <FileUnit>(); bool recompileApp = false; int numLocalTypeXamls = 0; if ((_analyzeResult & RecompileCategory.ContentFiles) == RecompileCategory.ContentFiles) { RecompileContentFiles(); } if ((_analyzeResult & RecompileCategory.ApplicationFile) == RecompileCategory.ApplicationFile) { recompileApp = true; } if ((_analyzeResult & RecompileCategory.PagesWithLocalType) == RecompileCategory.PagesWithLocalType && TaskFileService.IsRealBuild) { CompilerLocalReference.LoadCacheFile(); if (CompilerLocalReference.LocalApplicationFile != null) { // Application file contains local types, it will be recompiled. recompileApp = true; } if (ListIsNotEmpty(CompilerLocalReference.LocalMarkupPages)) { numLocalTypeXamls = CompilerLocalReference.LocalMarkupPages.Length; // Under incremental builds of SDK projects, we can have a state where the cache contains some XAML files but the Page blob // no longer contains them. To avoid attempting to recompile a file that no longer exists, ensure that any cached XAML file // still exists in the Page blob prior to queuing it up for recompilation. HashSet <string> localMarkupPages = new HashSet <string>(_mcPass1.PageMarkup.Select(x => x.GetMetadata(SharedStrings.FullPath)), StringComparer.OrdinalIgnoreCase); for (int i = 0; i < numLocalTypeXamls; i++) { LocalReferenceFile localRefFile = CompilerLocalReference.LocalMarkupPages[i]; if (localMarkupPages.Contains(localRefFile.FilePath)) { recompiledXaml.Add(new FileUnit( localRefFile.FilePath, localRefFile.LinkAlias, localRefFile.LogicalName)); } } } } if ((_analyzeResult & RecompileCategory.ModifiedPages) == RecompileCategory.ModifiedPages) { // If the xaml is already in the local-type-ref xaml file list, don't add a duplicate file path to recompiledXaml list. for (int i = 0; i < modifiedXamlFiles.Count; i++) { FileUnit xamlfile = modifiedXamlFiles[i]; bool addToList; addToList = true; if (numLocalTypeXamls > 0) { for (int j = 0; j < numLocalTypeXamls; j++) { if (String.Compare(xamlfile.Path, CompilerLocalReference.LocalMarkupPages[j].FilePath, StringComparison.OrdinalIgnoreCase) == 0) { addToList = false; break; } } } if (addToList) { recompiledXaml.Add(xamlfile); } } } if (recompiledXaml.Count > 0) { _recompileMarkupPages = recompiledXaml.ToArray(); } // Set ApplicationFile appropriatelly for this incremental build. ProcessApplicationFile(recompileApp); }