|
| 1 | +# ---------------------------------------------------------------------------------- |
| 2 | +# |
| 3 | +# Copyright Microsoft Corporation |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# Unless required by applicable law or agreed to in writing, software |
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +# See the License for the specific language governing permissions and |
| 12 | +# limitations under the License. |
| 13 | +# ---------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +<# |
| 16 | +.SYNOPSIS |
| 17 | + Generate Az.xxx.psm1 and add Az.xxx.psm1 as RootModue in Az.xxx.psd1. |
| 18 | +
|
| 19 | +.PARAMETER ModuleFolder |
| 20 | + The folder for Az.Accounts module, e.g. C:\azure-powershell\artifacts\Debug\Az.Accounts |
| 21 | +
|
| 22 | +.PARAMETER IgnorePwshVersion |
| 23 | + Whether ignore pwsh version check |
| 24 | +
|
| 25 | +#> |
| 26 | +param( |
| 27 | + [Parameter(Mandatory = $true)] |
| 28 | + [string]$ModuleFolder, |
| 29 | + |
| 30 | + [Parameter(Mandatory = $false)] |
| 31 | + [switch]$IgnorePwshVersion |
| 32 | +) |
| 33 | + |
| 34 | +$script:TemplateLocation = "$PSScriptRoot\AzureRM.Example.psm1" |
| 35 | + |
| 36 | +Import-Module "$PSScriptRoot\UpdateModules.psm1" |
| 37 | +Import-Module "$PSScriptRoot\PublishModules.psm1" |
| 38 | + |
| 39 | +Write-Host "ModuleFolder: $ModuleFolder" |
| 40 | + |
| 41 | +$ModuleFolder = $ModuleFolder.Trim() |
| 42 | + |
| 43 | +New-ModulePsm1 -ModulePath $ModuleFolder -TemplatePath $script:TemplateLocation -IsRMModule -IsNetcore -IgnorePwshVersion:$IgnorePwshVersion |
| 44 | + |
| 45 | +$moduleName = (Get-Item -Path $ModuleFolder).Name |
| 46 | +$moduleManifest = $moduleName + ".psd1" |
| 47 | +$moduleSourcePath = Join-Path -Path $ModuleFolder -ChildPath $moduleManifest |
| 48 | +$file = Get-Item $moduleSourcePath |
| 49 | + |
| 50 | +Import-LocalizedData -BindingVariable ModuleMetadata -BaseDirectory $file.DirectoryName -FileName $file.Name |
| 51 | + |
| 52 | +if ($ModuleMetadata.RootModule) { |
| 53 | + Write-Output "Adding PSM1 dependency is skipped because root module is found" |
| 54 | +} else { |
| 55 | + Write-Output "Adding PSM1 dependency to $moduleSourcePath" |
| 56 | + Add-PSM1Dependency -Path $moduleSourcePath |
| 57 | +} |
| 58 | + |
| 59 | +Remove-ModuleDependencies -Path $moduleSourcePath |
0 commit comments