/// <overloads> /// Initializes a new instance of the <see cref="ReferenceDirectorySource"/> class. /// </overloads> /// <summary> /// Initializes a new instance of the <see cref="ReferenceDirectorySource"/> class /// with the default parameters. /// </summary> public ReferenceDirectorySource() { _isRecursive = false; _searchPattern = "*.dll"; _frameworkType = BuildFrameworkType.Null; _excludeSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase); }
private void ReadPropertyGroup(XmlReader reader) { string startElement = reader.Name; Debug.Assert(String.Equals(startElement, "propertyGroup")); Debug.Assert(String.Equals(reader.GetAttribute("name"), "General")); if (reader.IsEmptyElement) { return; } while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, "property", StringComparison.OrdinalIgnoreCase)) { string tempText = null; switch (reader.GetAttribute("name").ToLower()) { case "title": this.Title = reader.ReadString(); break; case "searchrecursive": tempText = reader.ReadString(); if (!String.IsNullOrEmpty(tempText)) { _isRecursive = Convert.ToBoolean(tempText); } break; case "searchpattern": _searchPattern = reader.ReadString(); break; case "frameworktype": tempText = reader.ReadString(); if (!String.IsNullOrEmpty(tempText)) { _frameworkType = BuildFrameworkType.Parse(tempText); } break; default: // Should normally not reach here... throw new NotImplementedException(reader.GetAttribute("name")); } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase)) { break; } } } }
/// <overloads> /// Initializes a new instance of the <see cref="ReferenceLinkSource"/> class. /// </overloads> /// <summary> /// Initializes a new instance of the <see cref="ReferenceLinkSource"/> class /// with the default parameters. /// </summary> public ReferenceLinkSource() { _sourceId = Guid.NewGuid().ToString(); _linkType = BuildLinkType.Local; _listItems = new BuildList <ReferenceItem>(); _dependencies = new DependencyContent(); _frameworkType = BuildFrameworkType.None; }
/// <summary> /// Initializes a new instance of the <see cref="ReferenceDirectorySource"/> class /// with parameters copied from the specified instance of the /// <see cref="ReferenceDirectorySource"/> class, a copy constructor. /// </summary> /// <param name="source"> /// An instance of the <see cref="ReferenceDirectorySource"/> class from which the /// initialization parameters or values will be copied. /// </param> /// <exception cref="ArgumentNullException"> /// If the parameter <paramref name="source"/> is <see langword="null"/>. /// </exception> public ReferenceDirectorySource(ReferenceDirectorySource source) : base(source) { _excludeSet = source._excludeSet; _sourcePath = source._sourcePath; _isRecursive = source._isRecursive; _searchPattern = source._searchPattern; _frameworkType = source._frameworkType; }
/// <summary> /// Initializes a new instance of the <see cref="ReferenceLinkSource"/> class /// with parameters copied from the specified instance of the /// <see cref="ReferenceLinkSource"/> class, a copy constructor. /// </summary> /// <param name="source"> /// An instance of the <see cref="ReferenceLinkSource"/> class from which the /// initialization parameters or values will be copied. /// </param> /// <exception cref="ArgumentNullException"> /// If the parameter <paramref name="source"/> is <see langword="null"/>. /// </exception> public ReferenceLinkSource(ReferenceLinkSource source) : base(source) { _linkType = source._linkType; _sourceId = source._sourceId; _listItems = source._listItems; _dependencies = source._dependencies; _frameworkType = source._frameworkType; }
public ReferenceContent() { _contentVersion = new Version(1, 0, 0, 0); _contentId = Guid.NewGuid().ToString(); _frameworkType = BuildFrameworkType.Framework20; _dependencies = new DependencyContent(); _tocContent = new HierarchicalTocContent(); _commentContent = new CommentContent(); _typeFilters = new ReferenceRootFilter(false); _attributeFilters = new ReferenceRootFilter(true); }
public ReferenceContent(ReferenceContent source) : base(source) { _isLoaded = source._isLoaded; _contentId = source._contentId; _contentVersion = source._contentVersion; _contentFile = source._contentFile; _contentDir = source._contentDir; _frameworkType = source._frameworkType; _tocContent = source._tocContent; _dependencies = source._dependencies; _commentContent = source._commentContent; _typeFilters = source._typeFilters; _attributeFilters = source._attributeFilters; }
private void ReadPropertyGroup(XmlReader reader) { string startElement = reader.Name; Debug.Assert(String.Equals(startElement, "propertyGroup")); Debug.Assert(String.Equals(reader.GetAttribute("name"), "General")); if (reader.IsEmptyElement) { return; } while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, "property", StringComparison.OrdinalIgnoreCase)) { switch (reader.GetAttribute("name").ToLower()) { case "id": _contentId = reader.ReadString(); break; case "frameworktype": string tempText = reader.ReadString(); if (!String.IsNullOrEmpty(tempText)) { _frameworkType = (BuildFrameworkType) BuildFrameworkType.Parse(tempText); } break; default: // Should normally not reach here... throw new NotImplementedException(reader.GetAttribute("name")); } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase)) { break; } } } }
private void CreateLinkGroups(BuildContext context) { context["$EmbeddedScriptSharp"] = Boolean.FalseString; if (_listGroups == null || _listGroups.Count == 0) { return; } BuildLogger logger = context.Logger; List <ReferenceGroup> buildGroups = new List <ReferenceGroup>(); IList <BuildGroupContext> groupContexts = context.GroupContexts; bool hasScriptSharp = false; BuildFrameworkType latestScriptSharp = BuildFrameworkType.None; int itemCount = _listGroups.Count; int index = 0; for (int i = 0; i < itemCount; i++) { ReferenceGroup group = _listGroups[i]; ReferenceContent content = group.Content; if (content != null) { BuildFrameworkType frameworkType = content.FrameworkType; if (frameworkType.Kind == BuildFrameworkKind.ScriptSharp) { hasScriptSharp = true; if (frameworkType > latestScriptSharp) { latestScriptSharp = frameworkType; } } } } // Include contents from the Script# framework for correct // linking, since there is MSDN links for the Script#... if (hasScriptSharp && _engineSettings.EmbedScriptSharpFramework && latestScriptSharp.Kind == BuildFrameworkKind.ScriptSharp) { BuildFramework framework = BuildFrameworks.GetFramework(latestScriptSharp); if (framework == null) { framework = BuildFrameworks.LatestScriptSharp; } if (framework != null) { ReferenceGroup buildGroup = new ReferenceGroup( "Embedded ScriptSharp - " + ReferenceGroup.NextGroupName(), Guid.NewGuid().ToString()); ReferenceContent content = buildGroup.Content; string[] assemblies = Directory.GetFiles(framework.AssemblyDir, "*.dll", SearchOption.AllDirectories); for (int i = 0; i < assemblies.Length; i++) { string assembly = assemblies[i]; string comments = Path.ChangeExtension(assembly, ".xml"); if (File.Exists(comments)) { content.AddItem(comments, assembly); } } buildGroup.ExcludeToc = true; buildGroup.SyntaxType = BuildSyntaxType.CSharp | BuildSyntaxType.JavaScript; buildGroups.Add(buildGroup); // Create the group context... ReferenceGroupContext buildGroupContext = new ReferenceGroupContext(buildGroup); buildGroupContext.IsEmbeddedGroup = true; groupContexts.Add(buildGroupContext); string indexText = (itemCount + index + 1).ToString(); // Create the build dynamic properties... buildGroupContext.CreateProperties(indexText); // This has no effect, since the newly created group will // not have any content source. buildGroup.BeginSources(context); context["$EmbeddedScriptSharp"] = Boolean.TrueString; } } if (buildGroups.Count != 0) { _listGroups.Add(buildGroups); } // Process the user-provided link sources... List <ReferenceLinkSource> linkSources = null; IList <ReferenceLinkSource> listSources = _engineSettings.LinkSources as IList <ReferenceLinkSource>; if (listSources != null && listSources.Count != 0) { for (int i = 0; i < listSources.Count; i++) { ReferenceLinkSource linkSource = listSources[i]; if (linkSource == null || !linkSource.IsValid) { if (logger != null) { string title = linkSource.Title; if (title == null) { title = String.Empty; } logger.WriteLine(String.Format( "A provided reference link source titled = '{0}', at index = '{1}' is invalid.", title, i), BuildLoggerLevel.Warn); } continue; } if (linkSources == null) { linkSources = new List <ReferenceLinkSource>(); } linkSources.Add(linkSource); } } // Process the automatic link sources... BuildSpecialSdkType webMvcSdkType = _engineSettings.WebMvcSdkType; if (webMvcSdkType != BuildSpecialSdkType.None && webMvcSdkType != BuildSpecialSdkType.Null) { BuildSpecialSdk webSdk = BuildSpecialSdks.GetSdk(webMvcSdkType, BuildFrameworkKind.DotNet); if (webSdk != null) { ReferenceLinkSource linkSource = new ReferenceLinkSource(); linkSource.LinkType = BuildLinkType.Msdn; linkSource.Title = webMvcSdkType.Label; linkSource.FrameworkType = BuildFrameworks.LatestFramework.FrameworkType; string aspMVCDir = webSdk.AssemblyDir; string[] assemblyFiles = Directory.GetFiles( webSdk.AssemblyDir, "*.dll", SearchOption.TopDirectoryOnly); for (int i = 0; i < assemblyFiles.Length; i++) { string assemblyFile = assemblyFiles[i]; string commentFile = Path.ChangeExtension(assemblyFile, ".xml"); if (File.Exists(commentFile)) { ReferenceItem refItem = new ReferenceItem( commentFile, assemblyFile); refItem.XamlSyntax = false; linkSource.Add(refItem); } } if (linkSource.IsValid) { if (linkSources == null) { linkSources = new List <ReferenceLinkSource>(); } linkSources.Add(linkSource); } } } if (linkSources != null && linkSources.Count != 0) { context.SetValue("$ReferenceLinkSources", linkSources); itemCount = linkSources.Count; if (_linkGroups == null) { _linkGroups = new BuildList <ReferenceGroup>(); } for (int i = 0; i < itemCount; i++) { ReferenceLinkSource linkSource = linkSources[i]; ReferenceGroup linkGroup = new ReferenceGroup( "Reference Links - " + ReferenceGroup.NextGroupName(), linkSource.SourceId, linkSource); linkGroup.ExcludeToc = true; _linkGroups.Add(linkGroup); // Create the group context... ReferenceGroupContext linkGroupContext = new ReferenceGroupContext(linkGroup); linkGroupContext.IsLinkGroup = true; groupContexts.Add(linkGroupContext); string indexText = String.Empty; if (itemCount > 1) { indexText = (i + 1).ToString(); } // Create the build dynamic properties... linkGroupContext.CreateProperties(indexText); // This has no effect, since the newly created group will // not have any content source. linkGroup.BeginSources(context); } } }
private bool OnExecuteMultiple(BuildContext context) { ReferenceGroupContext groupContext = context.GroupContexts[_group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } BuildLogger logger = context.Logger; for (int v = 0; v < _listVersions.Count; v++) { ReferenceVersions versions = _listVersions[v]; for (int j = 0; j < versions.Count; j++) { ReferenceVersionSource source = versions[j]; ReferenceGroupContext versionsContext = groupContext.Contexts[source.SourceId]; string workingDir = versionsContext["$WorkingDir"]; ReferenceContent content = source.Content; if (content == null) { if (logger != null) { logger.WriteLine("StepReferenceInit: There is no content associated with the reference group.", BuildLoggerLevel.Error); } return(false); } BuildFrameworkType frameworkType = content.FrameworkType; if (frameworkType == BuildFrameworkType.Null || frameworkType == BuildFrameworkType.None) { if (logger != null) { logger.WriteLine("StepReferenceInit: There is no valid framework type specified for this reference group.", BuildLoggerLevel.Error); } return(false); } BuildFramework framework = BuildFrameworks.GetFramework(frameworkType); if (framework == null) { if (logger != null) { logger.WriteLine("StepReferenceInit: The specified framework type for this reference group is not installed.", BuildLoggerLevel.Error); } return(false); } versionsContext.Framework = framework; string commentDir = versionsContext.CommentFolder; string assemblyDir = versionsContext.AssemblyFolder; if (String.IsNullOrEmpty(commentDir)) { commentDir = "Comments"; } if (!Path.IsPathRooted(commentDir)) { commentDir = Path.Combine(workingDir, commentDir); } if (!Directory.Exists(commentDir)) { Directory.CreateDirectory(commentDir); } if (String.IsNullOrEmpty(assemblyDir)) { assemblyDir = "Assemblies"; } if (!Path.IsPathRooted(assemblyDir)) { assemblyDir = Path.Combine(workingDir, assemblyDir); } if (!Directory.Exists(assemblyDir)) { Directory.CreateDirectory(assemblyDir); } string dependencyDir = versionsContext.DependencyFolder; if (String.IsNullOrEmpty(dependencyDir)) { dependencyDir = "Dependencies"; } if (!Path.IsPathRooted(dependencyDir)) { dependencyDir = Path.Combine(workingDir, dependencyDir); } if (!Directory.Exists(dependencyDir)) { Directory.CreateDirectory(dependencyDir); } versionsContext.CommentDir = commentDir; versionsContext.AssemblyDir = assemblyDir; versionsContext.DependencyDir = dependencyDir; // Copy the comments to the expected directory... int itemCount = content.Count; List <string> commentFiles = new List <string>(itemCount); for (int i = 0; i < itemCount; i++) { ReferenceItem item = content[i]; if (item == null || item.IsEmpty) { continue; } string commentsFile = item.Comments; if (!String.IsNullOrEmpty(commentsFile)) { string fileName = Path.GetFileName(commentsFile); fileName = Path.Combine(commentDir, fileName); if (commentsFile.Length != fileName.Length || String.Equals(commentsFile, fileName, StringComparison.OrdinalIgnoreCase) == false) { File.Copy(commentsFile, fileName, true); File.SetAttributes(fileName, FileAttributes.Normal); commentFiles.Add(fileName); } } string assemblyFile = item.Assembly; if (!String.IsNullOrEmpty(assemblyFile)) { string fileName = Path.GetFileName(assemblyFile); fileName = Path.Combine(assemblyDir, fileName); if (assemblyFile.Length != fileName.Length || String.Equals(assemblyFile, fileName, StringComparison.OrdinalIgnoreCase) == false) { File.Copy(assemblyFile, fileName, true); File.SetAttributes(fileName, FileAttributes.Normal); } } } //TODO--PAUL: Should the project/namespace summary be included? // Finally, store the list of extracted comment file to its context... versionsContext.CommentFiles = commentFiles; // 1. Copy the dependencies to the expected directory... ReferenceProjectVisitor dependencyResolver = new ReferenceProjectVisitor(source.SourceId, content); dependencyResolver.Initialize(context); dependencyResolver.Visit(_group); dependencyResolver.Uninitialize(); } } return(true); }
private bool OnExecuteSingle(BuildContext context) { BuildLogger logger = context.Logger; ReferenceGroupContext groupContext = context.GroupContexts[_group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceContent content = _group.Content; if (content == null) { if (logger != null) { logger.WriteLine("StepReferenceInit: There is no content associated with the reference group.", BuildLoggerLevel.Error); } return(false); } BuildFrameworkType frameworkType = content.FrameworkType; if (frameworkType == BuildFrameworkType.Null || frameworkType == BuildFrameworkType.None) { if (logger != null) { logger.WriteLine("StepReferenceInit: There is no valid framework type specified for this reference group.", BuildLoggerLevel.Error); } return(false); } BuildFramework framework = BuildFrameworks.GetFramework(frameworkType); if (framework == null) { if (logger != null) { logger.WriteLine("StepReferenceInit: The specified framework type for this reference group is not installed.", BuildLoggerLevel.Error); } return(false); } string workingDir = context.WorkingDirectory; groupContext.Framework = framework; string commentDir = groupContext.CommentFolder; string assemblyDir = groupContext.AssemblyFolder; if (String.IsNullOrEmpty(commentDir)) { commentDir = "Comments"; } if (!Path.IsPathRooted(commentDir)) { commentDir = Path.Combine(workingDir, commentDir); } if (!Directory.Exists(commentDir)) { Directory.CreateDirectory(commentDir); } if (String.IsNullOrEmpty(assemblyDir)) { assemblyDir = "Assemblies"; } if (!Path.IsPathRooted(assemblyDir)) { assemblyDir = Path.Combine(workingDir, assemblyDir); } if (!Directory.Exists(assemblyDir)) { Directory.CreateDirectory(assemblyDir); } string dependencyDir = groupContext.DependencyFolder; if (String.IsNullOrEmpty(dependencyDir)) { dependencyDir = "Dependencies"; } if (!Path.IsPathRooted(dependencyDir)) { dependencyDir = Path.Combine(workingDir, dependencyDir); } if (!Directory.Exists(dependencyDir)) { Directory.CreateDirectory(dependencyDir); } groupContext.CommentDir = commentDir; groupContext.AssemblyDir = assemblyDir; groupContext.DependencyDir = dependencyDir; // Copy the comments to the expected directory... int itemCount = content.Count; List <string> commentFiles = new List <string>(itemCount); CommentContent commentContent = content.Comments; if (commentContent != null && !commentContent.IsEmpty) { string commentFile = Path.Combine(commentDir, groupContext["$CommentsFile"]); // If there is a valid file or there is an attached file... BuildFilePath filePath = commentContent.ContentFile; if (filePath != null && filePath.Exists) { if (commentContent.IsLoaded) { commentContent.Save(); } File.Copy(filePath.Path, commentFile); } else { commentContent.SaveCopyAs(commentFile); } File.SetAttributes(commentFile, FileAttributes.Normal); commentFiles.Add(commentFile); } for (int i = 0; i < itemCount; i++) { ReferenceItem item = content[i]; if (item == null || item.IsEmpty) { continue; } string commentsFile = item.Comments; if (!String.IsNullOrEmpty(commentsFile)) { string fileName = Path.GetFileName(commentsFile); fileName = Path.Combine(commentDir, fileName); if (commentsFile.Length != fileName.Length || String.Equals(commentsFile, fileName, StringComparison.OrdinalIgnoreCase) == false) { File.Copy(commentsFile, fileName, true); File.SetAttributes(fileName, FileAttributes.Normal); commentFiles.Add(fileName); } } string assemblyFile = item.Assembly; if (!String.IsNullOrEmpty(assemblyFile)) { string fileName = Path.GetFileName(assemblyFile); fileName = Path.Combine(assemblyDir, fileName); if (assemblyFile.Length != fileName.Length || String.Equals(assemblyFile, fileName, StringComparison.OrdinalIgnoreCase) == false) { File.Copy(assemblyFile, fileName, true); File.SetAttributes(fileName, FileAttributes.Normal); } } } // Finally, store the list of extracted comment file to its context... groupContext.CommentFiles = commentFiles; // 1. Copy the dependencies to the expected directory... ReferenceProjectVisitor dependencyResolver = new ReferenceProjectVisitor(); dependencyResolver.Initialize(context); dependencyResolver.Visit(_group); dependencyResolver.Uninitialize(); return(true); }