param( [Parameter(Mandatory = $true)] [string]$TemplateDir, [Parameter(Mandatory = $true)] [string]$AssembliesDir, [Parameter(Mandatory = $true)] [string]$OutputRoot, [Parameter(Mandatory = $true)] [string]$PackageName, [Parameter(Mandatory = $true)] [string]$PackageVersion ) $ErrorActionPreference = 'Stop' function Normalize-FullPath { param([string]$Path) return [System.IO.Path]::GetFullPath($Path) } function Normalize-TextFileLineEndings { param([string]$Path) $content = [System.IO.File]::ReadAllText($Path) $content = [regex]::Replace($content, '(?[^<]+', "$PackageVersion", 1) [System.IO.File]::WriteAllText($configurationDataPath, $configurationData, [System.Text.UTF8Encoding]::new($true)) } $textFileExtensions = @('.json', '.xml', '.dat', '.type', '.class', '.config', '.host') Get-ChildItem -LiteralPath $packageDir -Recurse -File | Where-Object { $textFileExtensions -contains $_.Extension.ToLowerInvariant() } | ForEach-Object { Normalize-TextFileLineEndings $_.FullName } Compress-Archive -Path (Join-Path $packageDir '*') -DestinationPath $zipPath -Force Write-Host "Matrix42 package folder: $packageDir" Write-Host "Matrix42 package zip: $zipPath"