[英]How to collect all xml-documentation from projects in solution with docfx?
我有這樣的解決方案結構:
Solution
--Project.DAL
------bin
------obj
------Project.DAL.csproj
--Project.BLL
------bin
------obj
------Project.BLL.csproj
--Project.View
------bin
------obj
------Project.View.csproj
--Project.Documentaion
------_site
------another-files-of-docfx
我嘗試更改 docfx.json 的道具和值
{
"src": [
{
"files": [
"Project.DAL.csproj",
"Project.BLL.csproj",
"Project.View.csproj"
],
"src": "Project"
}
],
"dest": "api",
"disableGitFeatures": false,
"disableDefaultFilter": false
}
每個項目都有 nugetpackage docfx.console 。 構建解決方案后,我在每個項目中都有文檔。 我想將解決方案中項目的所有 xml 文檔收集到文件夾 Project.Documentation。 請告訴我,可能還是不可能? 如果是的話,你能幫我告訴我我做錯了什么,在哪里嗎?
看看以下是否有效。 我可以使用 xml linq 而不是使用正則表達式。 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string mainProject = @"c:\temp\myProject.csproj";
string projectName = mainProject.Substring(mainProject.LastIndexOf("\\") + 1);
string folder = mainProject.Substring(0, mainProject.LastIndexOf("\\") + 1);
GetProjectsRecursive(folder, projectName, 0);
Console.ReadLine();
}
static void GetProjectsRecursive(string folder, string project, int level)
{
string pattern = "<ProjectReference Include=\"(?'project'[^\"]+)";
if (File.Exists(folder + project))
{
string contents = File.ReadAllText(folder + project);
MatchCollection matches = Regex.Matches(contents, pattern, RegexOptions.Multiline);
if (matches.Count > 0)
{
foreach (Match match in matches)
{
string projectName = match.Groups["project"].Value;
string childProjectName = projectName.Substring(projectName.LastIndexOf("\\") + 1);
string childFolder = projectName.Substring(0, projectName.LastIndexOf("\\") + 1);
Console.WriteLine("{0}Project : '{1}', Refeference Project : '{2}'", new string(' ', level), project, projectName);
if (childFolder.StartsWith("..\\"))
{
childFolder = folder + childFolder;
}
GetProjectsRecursive(childFolder, childProjectName, level + 1);
}
}
}
else
{
Console.WriteLine("Project Does Not Exist : '{0}'", folder + project);
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.