MkDocsAliases.

MkDocsServeAsync(ICakeContext, DirectoryPath, MkDocsServeAsyncSettings) Method

Summary

Run the builtin development server async.
Assembly
Cake.MkDocs.dll
Namespace
Cake.MkDocs
Containing Type
MkDocsAliases

Syntax

public static Task MkDocsServeAsync(this ICakeContext context, DirectoryPath projectDirectory, MkDocsServeAsyncSettings settings)

Examples

 using (var tokenSource = new CancellationTokenSource())
 {
     var task = MkDocsServeAsync("./docs-project", new MkDocsServeAsyncSettings()
     {
         Token = tokenSource.Token
     });

     // Do work...
     tokenSource.Cancel();

     try
     {
         task.Wait();
     }
     catch (OperationCanceledException)
     {
     }
 }
 using (var tokenSource = new CancellationTokenSource())
 {
     var task = MkDocsServeAsync(new DirectoryPath("./docs-project"), new MkDocsServeAsyncSettings()
     {
         Token = tokenSource.Token
     });

     // Do work...
     tokenSource.Cancel();

     try
     {
         task.Wait();
     }
     catch (OperationCanceledException)
     {
     }
 }
 using (var tokenSource = new CancellationTokenSource())
 {
     var task = MkDocsServeAsync(new DirectoryPath("./docs-project"), new MkDocsServeAsyncSettings()
     {
         ToolTimeout = new TimeSpan(0, 0, 1, 0)
     });

     // Do work...

     try
     {
         task.Wait();
     }
     catch (TimeoutException)
     {
         // Kill tool process after 1 minute
     }
 }

Remarks

This method will block build process. Use Ctrl+C in console to quit or use System.Threading.CancellationToken to cancel task programmatically.

Attributes

Type Description
CakeMethodAliasAttribute
CakeAliasCategoryAttribute
CakeNamespaceImportAttribute

Parameters

Name Type Description
context ICakeContext The context.
projectDirectory DirectoryPath Project directory path to serve.
settings MkDocsServeAsyncSettings The settings.

Return Value

Type Description
Task Long running task.