task/Build/UpdateMetadata.ps1
BuildTask UpdateMetadata -Stage Build -Order 5 -Definition { # Update the psd1 document. try { $path = $buildInfo.Path.Build.Manifest # Version Update-Metadata $path -PropertyName ModuleVersion -Value $buildInfo.Version # RootModule if (Enable-Metadata $path -PropertyName RootModule) { Update-Metadata $path -PropertyName RootModule -Value $buildInfo.Path.Build.RootModule.Name } # FunctionsToExport $functionsToExport = Get-ChildItem (Join-Path $buildInfo.Path.Source.Module 'pub*') -Filter '*.ps1' -Recurse | Get-FunctionInfo | Select-Object -ExpandProperty Name if ($functionsToExport) { if (Enable-Metadata $path -PropertyName FunctionsToExport) { Update-Metadata $path -PropertyName FunctionsToExport -Value $functionsToExport } } # DscResourcesToExport $tokens = $parseErrors = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile( $buildInfo.Path.Build.RootModule, [Ref]$tokens, [Ref]$parseErrors ) $dscResourcesToExport = $ast.FindAll( { param ($ast) $ast -is [System.Management.Automation.Language.TypeDefinitionAst] -and $ast.IsClass -and $ast.Attributes.TypeName.FullName -contains 'DscResource' }, $true).Name if ($null -ne $dscResourcesToExport) { if (Enable-Metadata $path -PropertyName DscResourcesToExport) { Update-Metadata $path -PropertyName DscResourcesToExport -Value $dscResourcesToExport } } # RequiredAssemblies if (Test-Path (Join-Path $buildInfo.Path.Build.Module 'lib\*.dll')) { if (Enable-Metadata $path -PropertyName RequiredAssemblies) { Update-Metadata $path -PropertyName RequiredAssemblies -Value ( (Get-Item (Join-Path $buildInfo.Path.Package 'lib\*.dll')).Name | ForEach-Object { Join-Path 'lib' $_ } ) } } # FormatsToProcess if (Test-Path (Join-Path $buildInfo.Path.Build.Module '*.Format.ps1xml')) { if (Enable-Metadata $path -PropertyName FormatsToProcess) { Update-Metadata $path -PropertyName FormatsToProcess -Value (Get-Item (Join-Path $buildInfo.Path.Build.Module '*.Format.ps1xml')).Name } } # LicenseUri if ($build.Config.License -and $buildInfo.Config.License -ne 'None') { if (Enable-Metadata $path -PropertyName LicenseUri) { Update-Metadata $path -PropertyName LicenseUri -Value ('https://opensource.org/licenses/{0}' -f @( $buildInfo.Config.License )) } } } catch { throw } } |