77using Cake . Common . Build . AppVeyor ;
88using Cake . Common . Diagnostics ;
99using Cake . Common . IO ;
10- using Cake . Common . Net ;
1110using Cake . Common . Tools . DotNet ;
1211using Cake . Common . Tools . DotNet . Build ;
1312using Cake . Common . Tools . DotNet . MSBuild ;
@@ -40,8 +39,6 @@ public class BuildContext : FrostingContext
4039 public DirectoryPath ArtifactsDirectory { get ; }
4140 public DirectoryPath ToolsDirectory { get ; }
4241 public DirectoryPath DocsDirectory { get ; }
43- public DirectoryPath DocfxDirectory { get ; }
44- public FilePath DocfxExeFile { get ; }
4542 public FilePath DocfxJsonFile { get ; }
4643 public DirectoryPath TestOutputDirectory { get ; }
4744
@@ -79,8 +76,6 @@ public BuildContext(ICakeContext context)
7976 ArtifactsDirectory = RootDirectory . Combine ( "artifacts" ) ;
8077 ToolsDirectory = RootDirectory . Combine ( "tools" ) ;
8178 DocsDirectory = RootDirectory . Combine ( "docs" ) ;
82- DocfxDirectory = ToolsDirectory . Combine ( "docfx" ) ;
83- DocfxExeFile = DocfxDirectory . CombineWithFilePath ( "docfx.exe" ) ;
8479 DocfxJsonFile = DocsDirectory . CombineWithFilePath ( "docfx.json" ) ;
8580 TestOutputDirectory = RootDirectory . Combine ( "TestResults" ) ;
8681
@@ -194,14 +189,14 @@ public void DocfxChangelogGenerate(string version)
194189 this . FileWriteText ( release , content . ToString ( ) ) ;
195190 }
196191
197- public void RunDocfx ( FilePath docfxJson , string args = "" )
192+ public void RunDocfx ( FilePath docfxJson )
198193 {
199- this . Information ( $ "Running docfx for '{ docfxJson } ' with args ' { args } ' ") ;
200- if ( ! this . IsRunningOnWindows ( ) )
201- this . StartProcess ( "mono" ,
202- new ProcessSettings { Arguments = DocfxExeFile . FullPath + " " + docfxJson + " " + args } ) ;
203- else
204- this . StartProcess ( DocfxExeFile . FullPath , new ProcessSettings { Arguments = docfxJson + " " + args } ) ;
194+ this . Information ( $ "Running docfx for '{ docfxJson } '") ;
195+
196+ var currentDirectory = Directory . GetCurrentDirectory ( ) ;
197+ Directory . SetCurrentDirectory ( docfxJson . GetDirectory ( ) . FullPath ) ;
198+ Microsoft . DocAsCode . Docset . Build ( docfxJson . FullPath ) . Wait ( ) ;
199+ Directory . SetCurrentDirectory ( currentDirectory ) ;
205200 }
206201
207202 public void GenerateRedirects ( )
@@ -222,8 +217,6 @@ public void GenerateRedirects()
222217
223218public static class DocumentationHelper
224219{
225- public const string DocFxVersion = "2.59.4" ;
226-
227220 public static readonly string [ ] BdnAllVersions =
228221 {
229222 "v0.7.0" ,
@@ -419,24 +412,8 @@ public class DefaultTask : FrostingTask
419412{
420413}
421414
422- [ TaskName ( "DocFX_Install" ) ]
423- public class DocfxInstallTask : FrostingTask < BuildContext >
424- {
425- public override void Run ( BuildContext context )
426- {
427- if ( ! context . FileExists ( context . DocfxExeFile . FullPath ) )
428- {
429- var url =
430- $ "https://github.com/dotnet/docfx/releases/download/v{ DocumentationHelper . DocFxVersion } /docfx.zip";
431- var docfxZip = context . ToolsDirectory . CombineWithFilePath ( "docfx.zip" ) ;
432- context . DownloadFile ( url , docfxZip ) ;
433- context . Unzip ( docfxZip , context . DocfxDirectory ) ;
434- }
435- }
436- }
437415
438416[ TaskName ( "DocFX_Changelog_Download" ) ]
439- [ IsDependentOn ( typeof ( DocfxInstallTask ) ) ]
440417public class DocFxChangelogDownloadTask : FrostingTask < BuildContext >
441418{
442419 public override void Run ( BuildContext context )
@@ -468,7 +445,6 @@ public override void Run(BuildContext context)
468445}
469446
470447[ TaskName ( "DocFX_Changelog_Generate" ) ]
471- [ IsDependentOn ( typeof ( DocfxInstallTask ) ) ]
472448public class DocfxChangelogGenerateTask : FrostingTask < BuildContext >
473449{
474450 public override void Run ( BuildContext context )
@@ -498,26 +474,12 @@ public override void Run(BuildContext context)
498474// side effects (CleanTask).
499475// TODO: Define dependencies when a CI workflow scenario for using the "DocFX_Build" target exists.
500476[ TaskName ( "DocFX_Build" ) ]
501- [ IsDependentOn ( typeof ( DocfxInstallTask ) ) ]
502477[ IsDependentOn ( typeof ( DocfxChangelogGenerateTask ) ) ]
503- public class DocfxChangelogBuildTask : FrostingTask < BuildContext >
478+ public class DocfxBuildTask : FrostingTask < BuildContext >
504479{
505480 public override void Run ( BuildContext context )
506481 {
507482 context . RunDocfx ( context . DocfxJsonFile ) ;
508483 context . GenerateRedirects ( ) ;
509484 }
510- }
511-
512- [ TaskName ( "DocFX_Serve" ) ]
513- [ IsDependentOn ( typeof ( DocfxInstallTask ) ) ]
514- [ IsDependentOn ( typeof ( DocfxChangelogGenerateTask ) ) ]
515- public class DocfxChangelogServeTask : FrostingTask < BuildContext >
516- {
517- public override void Run ( BuildContext context )
518- {
519- context . RunDocfx ( context . DocfxJsonFile ) ;
520- context . GenerateRedirects ( ) ;
521- context . RunDocfx ( context . DocfxJsonFile , "--serve" ) ;
522- }
523- }
485+ }
0 commit comments