CreateIMOfficialReleasePSDFile.ps1
|
Param( [Parameter(Mandatory=$true, HelpMessage="Enter the location of the Release Notes files.")] [string] $ReleaseNotesFile, [Parameter(Mandatory=$true, HelpMessage="Enter the version of this release.")] [string] $ReleaseVersion, [Parameter(Mandatory=$false, HelpMessage="Preview string to use.")] [string] $PreviewString, [Parameter(Mandatory=$false, HelpMessage="Enter the location where release dlls are present.")] [string] $DllPath = ".", [Parameter(Mandatory=$false, HelpMessage="Enter the file which contains the list of the cmdlets to publish.")] [string] $CmdletPublishFile = ".", [Parameter(Mandatory=$true, HelpMessage="Set to true to create a preview release")] [switch] $PreviewRelease, [Parameter(Mandatory=$true, HelpMessage="Enter the location where you need to create the psd1 file.")] [string] $OutputPath ) if ((Test-Path -Path $ReleaseNotesFile) -eq $false) { Write-Error "ReleaseNotes file : $ReleaseNotesFile not found." } if ((Test-Path -Path $OutputPath) -eq $false) { Write-Host "Creating folder : $OutputPath" New-Item -Path $OutputPath -ItemType Directory } $ReleaseNotesString = Get-Content $ReleaseNotesFile -Raw $FileList = Get-ChildItem -Path $DllPath\ -Name -Filter *.dll $FileListString = "" foreach($file in $FileList) { $FileListString += "'.\$file', " } # Need to remove all at the end to allow for no extra commas and enters to be before license.txt $FileListString = $FileListString.Substring(0,$FileListString.Length-11) $FilesListOutputString = "@($FileListString, '.\LICENSE.txt', '.\NOTICE.txt')" $Description = 'This is a pre-release module used by a private preview program. Support will only be granted to those in the program. For detailed information on how to install and run this module from the PowerShell Gallery including prerequisites, please refer to https://docs.microsoft.com/en-us/powershell/scripting/gallery/overview' $CmdletSupported = @(Get-Content $CmdletPublishFile) $CmdletSupportedString = "" foreach($cmdlet in $CmdletSupported) { $CmdletSupportedString += "'$cmdlet'," } $CmdletSupportedString = $CmdletSupportedString.Substring(0,$CmdletSupportedString.Length-1) if ($PreviewRelease) { $psdFileContent = "@{ RootModule = 'Microsoft.CrossTenant.IdentityMapping.IMCmdlets.dll' ModuleVersion = '$ReleaseVersion' GUID = 'f1e0a93a-9a08-42f6-a564-61dfa63fdca9' Author = 'Microsoft Corporation' CompanyName = 'Microsoft Corporation' Copyright = '(c) 2022 Microsoft Corporation. All rights reserved.' Description = '$Description' PowerShellVersion = '5.1' DotNetFrameworkVersion = '4.7.2' VariablesToExport = '*' AliasesToExport = @() CmdletsToExport = @($CmdletSupportedString) FileList = $FilesListOutputString PrivateData = @{ PSData = @{ # Set to a prerelease string value if the release should be a prerelease. Prerelease = '$PreviewString' LicenseUri = 'https://aka.ms/CTIMPSModuleLicense' ReleaseNotes = '$ReleaseNotesString' } } }" } else { $psdFileContent = "@{ RootModule = 'Microsoft.CrossTenant.IdentityMapping.IMCmdlets.dll' ModuleVersion = '$ReleaseVersion' GUID = 'f1e0a93a-9a08-42f6-a564-61dfa63fdca9' Author = 'Microsoft Corporation' CompanyName = 'Microsoft Corporation' Copyright = '(c) 2022 Microsoft Corporation. All rights reserved.' Description = '$Description' PowerShellVersion = '5.1' DotNetFrameworkVersion = '4.7.2' VariablesToExport = '*' AliasesToExport = @() CmdletsToExport = @($CmdletSupportedString) FileList = $FilesListOutputString PrivateData = @{ PSData = @{ LicenseUri = 'https://aka.ms/CTIMPSModuleLicense' ReleaseNotes = '$ReleaseNotesString' } } }" } $psdFileContent | Out-File $OutputPath\CrossTenantIdentityMapping.psd1 |