Skip to content

Commit ca8f561

Browse files
authored
[Mono.Android] Improve generated API docs diff (#7427)
Updates the `<UpdateExternalDocumentation/>` target to run the mdoc `export-msxdoc` command for validation, and to include new files in the diff that it produces.
1 parent 82d6fdb commit ca8f561

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/Mono.Android/Mono.Android.targets

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
4+
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.Git" />
45
<UsingTask AssemblyFile="$(BootstrapTasksAssembly)" TaskName="Xamarin.Android.Tools.BootstrapTasks.CheckApiCompatibility" />
56
<Import Project="..\..\build-tools\scripts\XAVersionInfo.targets" />
67
<Import Project="..\..\bin\Build$(Configuration)\Mono.Android.Apis.projitems" Condition="Exists('..\..\bin\Build$(Configuration)\Mono.Android.Apis.projitems')"/>
@@ -292,7 +293,7 @@
292293
<DocsApiLevel Condition=" '$(DocsApiLevel)' == '' ">31</DocsApiLevel>
293294
<DocsPlatformId Condition=" '$(DocsPlatformId)' == '' ">31</DocsPlatformId>
294295
<DocsFxVersion Condition=" '$(DocsFxVersion)' == '' ">v12.0</DocsFxVersion>
295-
<_Binlog>$(MSBuildThisFileDirectory)../../bin/Build$(Configuration)/UpdateApiDocs-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss")).binlog</_Binlog>
296+
<_LogPrefix>$(MSBuildThisFileDirectory)../../bin/Build$(Configuration)/UpdateApiDocs-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss"))</_LogPrefix>
296297
</PropertyGroup>
297298

298299
<!-- Generate documentation using MDoc -->
@@ -312,7 +313,7 @@
312313
<_BuildProps Include="-p:AndroidFrameworkVersion=$(DocsFxVersion)" />
313314
</ItemGroup>
314315
<Exec
315-
Command="&quot;$(DotNetPreviewTool)&quot; build -v:n -c $(Configuration) -bl:$(_Binlog) @(_BuildProps, ' ')"
316+
Command="&quot;$(DotNetPreviewTool)&quot; build -v:n -c $(Configuration) -bl:$(_LogPrefix).binlog @(_BuildProps, ' ')"
316317
IgnoreStandardErrorWarningFormat="True"
317318
WorkingDirectory="$(MSBuildThisFileDirectory)"
318319
/>
@@ -365,15 +366,25 @@
365366
Command="$(ManagedRuntime) $(ManagedRuntimeArgs) $(_Mdoc) --debug update --use-docid --delete $(_Libdir) $(_ImportXml) $(_Output) $(_DocTypeArgs) $(_FxConfig) $(_Lang)"
366367
WorkingDirectory="$(MSBuildThisFileDirectory)"
367368
/>
369+
<!-- Ensure updated docs can also be exported to msxdoc format -->
370+
<Exec
371+
Command="$(ManagedRuntime) $(ManagedRuntimeArgs) $(_Mdoc) --debug export-msxdoc -o &quot;$(_LogPrefix)-Export.xml&quot; &quot;$(XamarinAndroidSourcePath)external/android-api-docs/docs/Mono.Android/en/&quot;"
372+
WorkingDirectory="$(MSBuildThisFileDirectory)"
373+
/>
368374
</Target>
369375

370376
<Target Name="_GenerateApiDocsDiff">
371-
<PropertyGroup>
372-
<_DiffFile>$(XamarinAndroidSourcePath)bin/Build$(Configuration)/UpdateApiDocs$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss")).diff</_DiffFile>
373-
</PropertyGroup>
374-
<Exec
375-
Command="git diff --output=&quot;$(_DiffFile)&quot;"
377+
<Git
378+
Arguments="add ."
379+
WorkingDirectory="$(XamarinAndroidSourcePath)external/android-api-docs"
380+
ToolPath="$(GitToolPath)"
381+
ToolExe="$(GitToolExe)"
382+
/>
383+
<Git
384+
Arguments="diff --cached --output=&quot;$(_LogPrefix).diff&quot;"
376385
WorkingDirectory="$(XamarinAndroidSourcePath)external/android-api-docs"
386+
ToolPath="$(GitToolPath)"
387+
ToolExe="$(GitToolExe)"
377388
/>
378389
</Target>
379390

0 commit comments

Comments
 (0)