Skip to content

Commit 0f4b318

Browse files
authored
Generate Az.Accounts.psm1 and add it as RootModule to Az.Accounts.psd… (#12461)
* Generate Az.Accounts.psm1 and add it as RootModule to Az.Accounts.psd1 during build Debug configuration * fix double quote on Linux * update Directory.Build.targets to include above items * move script variable to right location
1 parent 89057c7 commit 0f4b318

File tree

6 files changed

+1291
-1186
lines changed

6 files changed

+1291
-1186
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.targets))\Directory.Build.targets" />
3+
<Target Name="AddAccountsPsm1Dependency" AfterTargets="Build" Condition="'$(Configuration)' == 'Debug'">
4+
<Exec Command="pwsh -NonInteractive -NoLogo -NoProfile -Command &quot;. '$(OutDir)../../../tools/AddModulePsm1Dependency.ps1' -ModuleFolder '$(OutDir)' -IgnorePwshVersion &quot;" />
5+
</Target>
6+
</Project>

tools/AddModulePsm1Dependency.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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

Comments
 (0)