diff --git a/CHANGELOG.md b/CHANGELOG.md index b0c7a88..422c7f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,10 +56,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Output message if `$GitHubToken` not specified which skips this task. Fixes [Issue 75](https://github.com/dsccommunity/DscResource.DocGenerator/issues/75) - Change working folder for the call to `git` with the argument `remote`. + - Added optional debug configuration option in `build.yml`. - `Invoke-Git` - Set `$TimeOut` to Milliseconds Fixes [Issue 84](https://github.com/dsccommunity/DscResource.DocGenerator/issues/84) - Calls `git` so it works on both Windows and Linux. + - Output properties in return value if called with the `Debug` optional + common parameter. - `Publish-WikiContent` - Remove a unnecessary `Set-Location` so it is possible to remove the temporary folder. diff --git a/README.md b/README.md index 25d04c3..30baec3 100644 --- a/README.md +++ b/README.md @@ -378,3 +378,12 @@ BuildWorkflow: - publish_module_to_gallery - Publish_GitHub_Wiki_Content ``` + +It is also possible to enable debug output information for the task when +it is run by adding this to the build configuration: + +```yaml +DscResource.DocGenerator: + Publish_GitHub_Wiki_Content: + Debug: true +``` diff --git a/build.yaml b/build.yaml index dd75b96..4eff62d 100644 --- a/build.yaml +++ b/build.yaml @@ -113,3 +113,7 @@ GitHubConfig: GitHubConfigUserName: dscbot GitHubConfigUserEmail: dsccommunity@outlook.com UpdateChangelogOnPrerelease: false + +DscResource.DocGenerator: + Publish_GitHub_Wiki_Content: + Debug: true diff --git a/source/Public/Invoke-Git.ps1 b/source/Public/Invoke-Git.ps1 index b01a75a..fe52909 100644 --- a/source/Public/Invoke-Git.ps1 +++ b/source/Public/Invoke-Git.ps1 @@ -94,5 +94,9 @@ function Invoke-Git } } + Write-Debug -Message ('{0}: {1}' -f $MyInvocation.MyCommand.Name, ($localizedData.InvokeGitExitCodeMessage -f $returnValue.ExitCode)) + Write-Debug -Message ('{0}: {1}' -f $MyInvocation.MyCommand.Name, ($localizedData.InvokeGitStandardOutputMessage -f $returnValue.StandardOutput)) + Write-Debug -Message ('{0}: {1}' -f $MyInvocation.MyCommand.Name, ($localizedData.InvokeGitStandardErrorMessage -f $returnValue.StandardError)) + return $returnValue } diff --git a/source/tasks/Publish_GitHub_Wiki_Content.build.ps1 b/source/tasks/Publish_GitHub_Wiki_Content.build.ps1 index 0fdf9cb..25def75 100644 --- a/source/tasks/Publish_GitHub_Wiki_Content.build.ps1 +++ b/source/tasks/Publish_GitHub_Wiki_Content.build.ps1 @@ -106,8 +106,21 @@ task Publish_GitHub_Wiki_Content { } else { + $debugTask = $BuildInfo.'DscResource.DocGenerator'.Publish_GitHub_Wiki_Content.Debug + + # Only show debug information if Debug was set to 'true' in build configuration. + if ($debugTask) + { + "Running task with debug information." + + $local:VerbosePreference = 'Continue' + $local:DebugPreference = 'Continue' + } + $OutputDirectory = Get-SamplerAbsolutePath -Path $OutputDirectory -RelativeTo $BuildRoot + "`tOutputDirectory = '$OutputDirectory'" + $BuiltModuleSubdirectory = Get-SamplerAbsolutePath -Path $BuiltModuleSubdirectory -RelativeTo $OutputDirectory if ($VersionedOutputDirectory) @@ -137,10 +150,12 @@ task Publish_GitHub_Wiki_Content { $builtModuleManifest = Get-SamplerBuiltModuleManifest @GetBuiltModuleManifestParams $builtModuleManifest = [string](Get-Item -Path $builtModuleManifest).FullName + "`tBuilt Module Manifest = '$builtModuleManifest'" $builtModuleBase = Get-SamplerBuiltModuleBase @GetBuiltModuleManifestParams $builtModuleBase = [string](Get-Item -Path $builtModuleBase).FullName + "`tBuilt Module Base = '$builtModuleBase'" $moduleVersion = Get-BuiltModuleVersion @GetBuiltModuleManifestParams @@ -170,8 +185,18 @@ task Publish_GitHub_Wiki_Content { } } - $gitRemoteResult = Invoke-Git -WorkingDirectory $ProjectPath ` - -Arguments @( 'remote', 'get-url', 'origin' ) + $invokeGitParameters = @{ + WorkingDirectory = $ProjectPath + Arguments = @('remote', 'get-url', 'origin') + } + + if ($debugTask) + { + $invokeGitParameters.Verbose = $true + $invokeGitParameters.Debug = $true + } + + $gitRemoteResult = Invoke-Git @invokeGitParameters if ($gitRemoteResult.ExitCode -eq 0) { @@ -189,6 +214,7 @@ task Publish_GitHub_Wiki_Content { } $wikiOutputPath = Join-Path -Path $OutputDirectory -ChildPath $WikiContentFolderName + "`tWiki Output Path = $wikiOutputPath" $publishWikiContentParameters = @{ @@ -202,6 +228,12 @@ task Publish_GitHub_Wiki_Content { GitUserName = $GitHubConfigUserName } + if ($debugTask) + { + $publishWikiContentParameters.Verbose = $true + $publishWikiContentParameters.Debug = $true + } + Write-Build Magenta "Publishing Wiki content." Publish-WikiContent @publishWikiContentParameters