# Builds the NTFSSecurity module from source, checks that the cmdlet # documentation in Docs/Cmdlets and the help file generated from it match the # cmdlets of that build, and runs the Pester tests against the build. image: Visual Studio 2022 init: - ps: git config --global core.autocrlf true install: - ps: | [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null Install-Module -Name platyPS -RequiredVersion 0.14.2 -Force Install-Module -Name MarkdownLinkCheck -RequiredVersion 0.2.0 -Force # The image includes Pester 3.4.0, which is signed by a different publisher. Install-Module -Name Pester -RequiredVersion 5.7.1 -Force -SkipPublisherCheck before_build: - nuget restore NTFSSecurity\packages.config -PackagesDirectory packages -NonInteractive - nuget restore Security2\packages.config -PackagesDirectory packages -NonInteractive # Provides the .NET Framework 4.5.2 reference assemblies, so the build does # not depend on a targeting pack installed on the build image. - nuget install Microsoft.NETFramework.ReferenceAssemblies.net452 -Version 1.0.3 -OutputDirectory packages -NonInteractive build_script: - ps: | $referenceAssemblies = "$env:APPVEYOR_BUILD_FOLDER\packages\Microsoft.NETFramework.ReferenceAssemblies.net452.1.0.3\build" msbuild NTFSSecurity\NTFSSecurity.csproj /nologo /verbosity:minimal /p:Configuration=Release "/p:TargetFrameworkRootPath=$referenceAssemblies" "/p:FrameworkPathOverride=$referenceAssemblies\.NETFramework\v4.5.2" if ($LASTEXITCODE -ne 0) { throw "MSBuild failed with exit code $LASTEXITCODE." } test_script: - ps: | $ErrorActionPreference = 'Stop' Import-Module -Name platyPS Import-Module -Name MarkdownLinkCheck Import-Module -Name .\NTFSSecurity\bin\Release\NTFSSecurity.psd1 -Force # 01. Test that the documentation matches the cmdlets built from source Update-MarkdownHelp -Path ./Docs/Cmdlets | Out-Null $diff = git diff -- Docs/Cmdlets if ($diff) { throw "Help is not up-to-date, run Update-MarkdownHelp: $diff" } # 02. Verify hyperlinks $brokenLinks = Get-MarkdownLink -Path .\Docs\ -BrokenOnly if ($brokenLinks) { throw "Found broken hyperlinks $brokenLinks" } # 03. Test that the help file of the module matches the documentation New-ExternalHelp -Path ./Docs/Cmdlets -OutputPath ./NTFSSecurity/en-US -Force | Out-Null $helpChanges = git status --porcelain -- NTFSSecurity/en-US if ($helpChanges) { throw "The help file is not up-to-date, run New-ExternalHelp -Path .\Docs\Cmdlets -OutputPath .\NTFSSecurity\en-US -Force: $helpChanges" } # 04. Run the Pester tests against the module build Import-Module -Name Pester -RequiredVersion 5.7.1 $configuration = New-PesterConfiguration $configuration.Run.Path = '.\Tests' $configuration.Run.PassThru = $true $configuration.Output.Verbosity = 'Detailed' $configuration.TestResult.Enabled = $true $configuration.TestResult.OutputFormat = 'NUnitXml' $configuration.TestResult.OutputPath = "$env:TEMP\PesterResults.xml" $result = Invoke-Pester -Configuration $configuration if ($env:APPVEYOR_JOB_ID) { $webClient = New-Object -TypeName System.Net.WebClient $webClient.UploadFile("https://ci.appveyor.com/api/testresults/nunit/$env:APPVEYOR_JOB_ID", "$env:TEMP\PesterResults.xml") } if ($result.FailedCount -gt 0) { throw "$($result.FailedCount) Pester tests failed." }