From 4fe360e98206b907588340e96e2887dafb54913a Mon Sep 17 00:00:00 2001
From: Martin Tirion <mtirion@live.nl>
Date: Wed, 18 Jan 2023 17:09:16 +0100
Subject: [PATCH] Improved sample pipelines. Upgrade tools to .NET 6

---
 PipelineExamples/documentation-build.yml      | 22 +++++++--------
 PipelineExamples/documentation-validation.yml | 28 ++++++-------------
 .../DocFxTocGenerator.csproj                  |  2 +-
 .../DocLanguageTranslator.csproj              |  2 +-
 src/DocLinkChecker/DocLinkChecker.csproj      |  2 +-
 5 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/PipelineExamples/documentation-build.yml b/PipelineExamples/documentation-build.yml
index 47dbeeb..6bda838 100644
--- a/PipelineExamples/documentation-build.yml
+++ b/PipelineExamples/documentation-build.yml
@@ -1,9 +1,8 @@
 ###########################################################################
-# This is a sample pipeline that can be used for generating a documentation
-# website using DocFX. In this pipeline we use the DocFxTocGenerator tool
-# to generate the table of contents.
+# This is a sample Azure DevOps pipeline that can be used for generating 
+# a documentation website using DocFX. In this pipeline we use the 
+# DocFxTocGenerator tool to generate the table of contents.
 ###########################################################################
-
 trigger:
 - none
 
@@ -19,18 +18,17 @@ steps:
 - powershell: choco install docfx -y
   displayName: Install docfx
 
+# install the companion tools
+- powershell: choco install docfx-companion-tools -y
+  displayName: Install docfx companion tools
+
 # run the toc generator on /DocExamample folder
-- task: DotNetCoreCLI@2
-  displayName: 'Building automatically toc.yml'
-  inputs:
-    command: 'run'
-    projects: '$(System.DefaultWorkingDirectory)/src/DocFxTocGenerator'
-    arguments: '-d $(System.DefaultWorkingDirectory)\DocExample -si'
+- powershell: DocFxTocGenerator -d .\DocExamples -si
+  displayName: 'Generating TOC for .\DocExamples'
 
-# run docfx
+# run docfx to generate documentation website
 - powershell: |
       &docfx DocEample\docfx.json
-      
       if ($lastexitcode -ne 0)
       {
         throw [System.Exception] "docfx build failed with exit code $lastexitcode."
diff --git a/PipelineExamples/documentation-validation.yml b/PipelineExamples/documentation-validation.yml
index 1442862..d1af934 100644
--- a/PipelineExamples/documentation-validation.yml
+++ b/PipelineExamples/documentation-validation.yml
@@ -1,8 +1,7 @@
 ###########################################################################
-# This is a sample pipeline that can be used for validating documentation.
-# In this pipeline we use markdownlint and the DocLinkChecker tool.
+# This is a sample Azure DevOps pipeline that can be used for validating 
+# documentation. In this pipeline we use markdownlint and the DocLinkChecker tool.
 ###########################################################################
-
 trigger: none
 
 pool:
@@ -22,19 +21,10 @@ jobs:
         CONFIGFILE: $(System.DefaultWorkingDirectory)/.markdownlint.json
       displayName: 'Run markdownlint'
 
-# run DocLinkChecker to validate documentation links in \DocExample folder
-- job:
-  displayName: 'Documentation links check'
-  steps:
-  - task: DotNetCoreCLI@2
-    displayName: 'Restore for DocLinkChecker'
-    inputs:
-      command: 'restore'
-      projects: '$(System.DefaultWorkingDirectory)/src/DocLinkChecker/DocLinkChecker/*.csproj'
-      feedsToUse: 'select'
-  - task: DotNetCoreCLI@2
-    displayName: 'Checking documentation links with DocLinkChecker'
-    inputs:
-      command: 'run'
-      projects: '$(System.DefaultWorkingDirectory)/src/DocLinkChecker/DocLinkChecker'
-      arguments: '-d $(System.DefaultWorkingDirectory)\DocExample -a'
+# install the companion tools
+- powershell: choco install docfx-companion-tools -y
+  displayName: Install docfx companion tools
+
+# run the toc generator on /DocExamample folder
+- powershell: DocLinkChecker -d .\DocExamples -a
+  displayName: 'Checking links in .\DocExamples'
diff --git a/src/DocFxTocGenerator/DocFxTocGenerator.csproj b/src/DocFxTocGenerator/DocFxTocGenerator.csproj
index ba2dff5..42d1d00 100644
--- a/src/DocFxTocGenerator/DocFxTocGenerator.csproj
+++ b/src/DocFxTocGenerator/DocFxTocGenerator.csproj
@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
   </PropertyGroup>
diff --git a/src/DocLanguageTranslator/DocLanguageTranslator.csproj b/src/DocLanguageTranslator/DocLanguageTranslator.csproj
index a16122f..9760bb2 100644
--- a/src/DocLanguageTranslator/DocLanguageTranslator.csproj
+++ b/src/DocLanguageTranslator/DocLanguageTranslator.csproj
@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
   </PropertyGroup>
diff --git a/src/DocLinkChecker/DocLinkChecker.csproj b/src/DocLinkChecker/DocLinkChecker.csproj
index a74e7c3..2091c5b 100644
--- a/src/DocLinkChecker/DocLinkChecker.csproj
+++ b/src/DocLinkChecker/DocLinkChecker.csproj
@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <GenerateDocumentationFile>True</GenerateDocumentationFile>
   </PropertyGroup>