void ExtractBuiltArtifacts(CompilationPass2TaskInternal wrapper) { if (wrapper.GeneratedCodeFiles == null) { return; } foreach (string code in wrapper.GeneratedCodeFiles) { this.generatedCodeFiles.Add(new TaskItem(code)); } }
public override bool Execute() { AppDomain appDomain = null; try { ValidateRequiredDev11Properties(); appDomain = XamlBuildTaskServices.CreateAppDomain("CompilationPass2AppDomain_" + Guid.NewGuid(), BuildTaskPath); CompilationPass2TaskInternal wrapper = (CompilationPass2TaskInternal)appDomain.CreateInstanceAndUnwrap( Assembly.GetExecutingAssembly().FullName, typeof(CompilationPass2TaskInternal).FullName); PopulateBuildArtifacts(wrapper); bool ret = wrapper.Execute(); ExtractBuiltArtifacts(wrapper); if (!ret) { foreach (LogData logData in wrapper.LogData) { XamlBuildTaskServices.LogException( this.Log, logData.Message, logData.FileName, logData.LineNumber, logData.LinePosition); } } return(ret); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } XamlBuildTaskServices.LogException(this.Log, e.Message); return(false); } finally { if (appDomain != null) { AppDomain.Unload(appDomain); } } }
void PopulateBuildArtifacts(CompilationPass2TaskInternal wrapper) { if (!this.supportExtensions) { IList<string> applicationMarkup = new List<string>(this.ApplicationMarkup.Length); foreach (ITaskItem taskItem in this.ApplicationMarkup) { applicationMarkup.Add(taskItem.ItemSpec); } wrapper.ApplicationMarkup = applicationMarkup; } wrapper.SupportExtensions = this.supportExtensions; wrapper.BuildLogger = this.Log; wrapper.References = this.References .Select(i => new DelegatingTaskItem(i) as ITaskItem).ToList(); wrapper.LocalAssemblyReference = this.LocalAssemblyReference; wrapper.AssemblyName = this.AssemblyName; wrapper.RootNamespace = this.RootNamespace; wrapper.Language = this.Language; wrapper.OutputPath = this.OutputPath; wrapper.IsInProcessXamlMarkupCompile = this.IsInProcessXamlMarkupCompile; wrapper.MSBuildProjectDirectory = this.MSBuildProjectDirectory; IList<string> sourceCodeFiles = null; if (this.SourceCodeFiles != null) { sourceCodeFiles = new List<string>(this.SourceCodeFiles.Length); foreach (ITaskItem taskItem in this.SourceCodeFiles) { sourceCodeFiles.Add(taskItem.ItemSpec); } } wrapper.SourceCodeFiles = sourceCodeFiles; if (this.supportExtensions) { wrapper.XamlBuildTaskTypeInspectionExtensionNames = XamlBuildTaskServices.GetXamlBuildTaskExtensionNames(this.XamlBuildTypeInspectionExtensionNames); // Here we create a Dictionary of Type Full Name and corresponding TaskItem // This is passed to the extensions which enables them to look up // metadata about a type like file name. IDictionary<string, ITaskItem> applicationMarkupWithTypeName = null; if (this.ApplicationMarkupWithTypeName != null) { applicationMarkupWithTypeName = new Dictionary<string, ITaskItem>(); } foreach (ITaskItem taskItem in this.ApplicationMarkupWithTypeName) { string typeName = taskItem.GetMetadata("typeName"); if (!String.IsNullOrWhiteSpace(typeName)) { applicationMarkupWithTypeName.Add(typeName, new DelegatingTaskItem(taskItem)); } } wrapper.ApplicationMarkupWithTypeName = applicationMarkupWithTypeName; } }
void PopulateBuildArtifacts(CompilationPass2TaskInternal wrapper) { if (!this.supportExtensions) { IList <string> applicationMarkup = new List <string>(this.ApplicationMarkup.Length); foreach (ITaskItem taskItem in this.ApplicationMarkup) { applicationMarkup.Add(taskItem.ItemSpec); } wrapper.ApplicationMarkup = applicationMarkup; } wrapper.SupportExtensions = this.supportExtensions; wrapper.BuildLogger = this.Log; wrapper.References = this.References .Select(i => new DelegatingTaskItem(i) as ITaskItem).ToList(); wrapper.LocalAssemblyReference = this.LocalAssemblyReference; wrapper.AssemblyName = this.AssemblyName; wrapper.RootNamespace = this.RootNamespace; wrapper.Language = this.Language; wrapper.OutputPath = this.OutputPath; wrapper.IsInProcessXamlMarkupCompile = this.IsInProcessXamlMarkupCompile; wrapper.MSBuildProjectDirectory = this.MSBuildProjectDirectory; IList <string> sourceCodeFiles = null; if (this.SourceCodeFiles != null) { sourceCodeFiles = new List <string>(this.SourceCodeFiles.Length); foreach (ITaskItem taskItem in this.SourceCodeFiles) { sourceCodeFiles.Add(taskItem.ItemSpec); } } wrapper.SourceCodeFiles = sourceCodeFiles; if (this.supportExtensions) { wrapper.XamlBuildTaskTypeInspectionExtensionNames = XamlBuildTaskServices.GetXamlBuildTaskExtensionNames(this.XamlBuildTypeInspectionExtensionNames); // Here we create a Dictionary of Type Full Name and corresponding TaskItem // This is passed to the extensions which enables them to look up // metadata about a type like file name. IDictionary <string, ITaskItem> applicationMarkupWithTypeName = null; if (this.ApplicationMarkupWithTypeName != null) { applicationMarkupWithTypeName = new Dictionary <string, ITaskItem>(); } foreach (ITaskItem taskItem in this.ApplicationMarkupWithTypeName) { string typeName = taskItem.GetMetadata("typeName"); if (!String.IsNullOrWhiteSpace(typeName)) { applicationMarkupWithTypeName.Add(typeName, new DelegatingTaskItem(taskItem)); } } wrapper.ApplicationMarkupWithTypeName = applicationMarkupWithTypeName; } }