DSInternals/Scripts/Pack-PSModule.ps1

30 lines
1.2 KiB
PowerShell
Raw Normal View History

2015-12-27 17:18:31 +00:00
<#
.SYNOPSIS
Creates a ZIP file distribution of the DSInternals module.
2019-05-08 17:19:05 +00:00
It is presumed that the module has already been compiled.
2015-12-27 17:18:31 +00:00
#>
2019-05-08 17:19:05 +00:00
#Requires -Version 5
2015-12-27 17:18:31 +00:00
# Set paths
$rootDir = Split-Path $PSScriptRoot -Parent
2019-05-08 17:19:05 +00:00
$moduleDir = Join-Path $rootDir 'Build\bin\Release\DSInternals'
$targetDir = Join-Path $rootDir 'Build\packages\Module'
# Generate file catalog
$catalogPath = Join-Path $moduleDir '..\DSInternals.cat'
$catalogIsValid = (Test-Path -Path $catalogPath) -and
(Test-FileCatalog -CatalogFilePath $catalogPath -Path $moduleDir) -eq [System.Management.Automation.CatalogValidationStatus]::Valid
if(-not $catalogIsValid)
{
New-FileCatalog -CatalogFilePath $catalogPath -Path $moduleDir -CatalogVersion 1.0 -ErrorAction Stop | Out-Null
}
2015-12-27 17:18:31 +00:00
2019-05-08 17:19:05 +00:00
# Retrieve module version from the manifest
$manifestPath = Join-Path $moduleDir 'DSInternals.psd1'
2015-12-27 17:18:31 +00:00
$moduleVersion = Test-ModuleManifest -Path $manifestPath -ErrorAction Stop | select -ExpandProperty Version
$archiveName = 'DSInternals_v{0}.zip' -f $moduleVersion
# Create the target ZIP archive
2019-05-08 17:19:05 +00:00
New-Item -Path $targetDir -ItemType Directory -Force | Out-Null
Compress-Archive -Path $moduleDir,$catalogPath -DestinationPath $targetDir\$archiveName -Force -ErrorAction Stop