|
| 1 | +## Introduction |
| 2 | + |
| 3 | +### Input |
| 4 | + |
| 5 | +The input of mdoc is `dll`,`winmd` or `exe` which are organized in below folder structure. |
| 6 | + |
| 7 | +``` |
| 8 | +|_dependencies |
| 9 | +| |_version1 |
| 10 | +| |-A.dependent.dll |
| 11 | +| |-B.dependent.dll |
| 12 | +|_version1 |
| 13 | + |-A.dll |
| 14 | + |_B.dll |
| 15 | +``` |
| 16 | +In current production pipeline, not all the source repos have binaries in it. Some are the NuGet packages registered in csv file. |
| 17 | + |
| 18 | +Example sources: |
| 19 | +1. [binaries](https://apidrop.visualstudio.com/_git/binaries) |
| 20 | +2. [mrefconfig](https://apidrop.visualstudio.com/binaries/_git/mrefconfig?path=/bundlepackages) |
| 21 | +3. [content repo](https://github.com/Azure/azure-docs-sdk-dotnet/tree/main/bundlepackages) |
| 22 | + |
| 23 | +We may not always be able to use the source repo as the input so the best way is to download the pipeline artifact to local to debug. |
| 24 | +  |
| 25 | +  |
| 26 | + |
| 27 | +### Commands |
| 28 | + |
| 29 | +There are 2 commands used in current production pipelines. |
| 30 | + |
| 31 | +1. fx-bootstrap: generate `frameworks.xml` to the output folder |
| 32 | +```dotnetcli |
| 33 | +fx-bootstrap -fx {frameworks output folder} -importContent {true/false} |
| 34 | +``` |
| 35 | +2. update: generate ECMAXMLs to the output folder |
| 36 | +```dotnetcli |
| 37 | +update -o {mdoc output folder} -fx {frameworks path} --debug -index false -lang docid -lang vb.net -lang fsharp -L "C:\Program Files (x86)\Windows Kits\10\References" -L "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\msdatasrc.dll" -L "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\PublicAssemblies" -L "C:\Program Files\dotnet" --delete |
| 38 | +``` |
| 39 | + |
| 40 | +### Debug steps |
| 41 | +1. Clone https://github.com/mono/api-doc-tools repo to local. |
| 42 | +2. Open it in Visual Studio and make sure it is built successfully. |
| 43 | +3. Set `mdoc` as the startup project. |
| 44 | +4. Prepare the input folder in local disk. |
| 45 | +  |
| 46 | +5. Create two launch profiles, one for `fx-bootstrap` and one for `update`. |
| 47 | +  |
| 48 | +  |
| 49 | +6. Locate the problematic piece of code. |
| 50 | +7. Set a breakpoint and start to debug. |
| 51 | + |
| 52 | +## Example |
| 53 | +1. Partner reported a bug: https://ceapex.visualstudio.com/Engineering/_workitems/edit/896871 |
| 54 | +2. Analysis the bug and identify this is a mdoc issue. |
| 55 | +3. Located the impacted .NET content repo: [dotnet-api-docs](https://github.com/dotnet/dotnet-api-docs). |
| 56 | +4. Find the corresponding pipeline in the commit log. https://apidrop.visualstudio.com/Content%20CI/_build/results?buildId=422059&view=results |
| 57 | +  |
| 58 | +5. Since the source is not NuGet source, we can pull the source repo as our input. |
| 59 | +6. Go to `Run .NET CI Script` step and find the source repo in the `paramsJson` |
| 60 | +``` |
| 61 | +"https://apidrop.visualstudio.com/_git/binaries","branch":"master","folder":"dotnet" |
| 62 | +``` |
| 63 | +7. Clone the source repo to local. |
| 64 | +8. Select `fx-bootstrap` launch profile and run. |
| 65 | +```dotnetcli |
| 66 | +fx-bootstrap -fx "{local path}\binaries\dotnet" |
| 67 | +``` |
| 68 | +9. The entry class of mdoc is [mdoc.cs](https://github.com/mono/api-doc-tools/blob/main/mdoc/Mono.Documentation/mdoc.cs) and the update command is in [MDocUpdater.cs](https://github.com/mono/api-doc-tools/blob/main/mdoc/Mono.Documentation/MDocUpdater.cs). |
| 69 | +10. After analyzing the bug, you may want to set a breakpoint at: |
| 70 | +  |
| 71 | +11. Select `update` launch profile and start to debug. |
| 72 | + |
| 73 | +## Tips |
| 74 | +1. If you want to debug against a specific .dll, you can modify this line of [MDocUpdater.cs](https://github.com/mono/api-doc-tools/blob/f0bee064c5e018b82a39ec36a4c59d474fb154f9/mdoc/Mono.Documentation/MDocUpdater.cs#L367) |
| 75 | + |
| 76 | + From |
| 77 | + ``` |
| 78 | + var assemblyFiles = filters.Split('|').SelectMany(v => Directory.GetFiles(path, v)); |
| 79 | + ``` |
| 80 | + To |
| 81 | + ``` |
| 82 | + var assemblyFiles = filters.Split('|').SelectMany(v => Directory.GetFiles(path, v)).Where(x => x.Contains("name-of-dll")); |
| 83 | + ``` |
0 commit comments