c# - 如何使用docfx从解决方案中的项目中收集所有xml文档?
问题描述
我有这样的解决方案结构:
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);
}
}
}
}
推荐阅读
- svg - THREE.ExtrudeBufferGeometry 的多边形很少
- r - 将显着性星添加到优势比图 (ggplot)
- python - python sqlalchemy原始查询非常慢
- python - 无法将字符串转换为浮点数:'100.0000%'
- c++ - 使用 std::thread 时与 g++/OpenMP 相关的错误?
- javascript - 将值添加到队列并在显示它们之前等待
- reactjs - 如何在地图上显示3s平面中的一条线?
- rxjs - 如何在 Observable NestJS 中引发异常?
- html - 页面刷新后将数据保存在div中
- php - 如何使用 php 读取文件名?