Skip to content

Commit

Permalink
Resolve module dependency issue for Publish-Module
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Rowlandson committed Aug 19, 2020
1 parent 13cc29c commit ceb9954
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
8 changes: 2 additions & 6 deletions AzureState/AzureState.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ PowerShellVersion = '7.0'
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @(
# 'AzureState.ps1'
# )
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
Expand All @@ -86,9 +84,7 @@ AliasesToExport = @()
# DscResourcesToExport = @()

# List of all modules packaged with this module
ModuleList = @(
@("AzureState", @{ ModuleName = "AzureState"; ModuleVersion = "0.0.1" } )
)
# ModuleList = @()

# List of all files packaged with this module
FileList = @(
Expand Down
19 changes: 8 additions & 11 deletions AzureStateManager.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ PowerShellVersion = '7.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(
@("Az.Accounts", @{ ModuleName = "Az.Accounts"; ModuleVersion = "1.9.1" } )
)
# RequiredModules = @(
# @("Az.Accounts", @{ ModuleName = "Az.Accounts"; ModuleVersion = "1.9.1" } )
# )

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
Expand All @@ -69,7 +69,7 @@ RequiredModules = @(

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @(
@("AzureState/AzureState.psm1", @{ ModuleName = "AzureState"; ModuleVersion = "0.0.1" } )
'AzureState/AzureState.psm1'
)

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
Expand All @@ -90,10 +90,7 @@ AliasesToExport = @()
# DscResourcesToExport = @()

# List of all modules packaged with this module
ModuleList = @(
@("AzureStateManager", @{ ModuleName = "AzureStateManager"; ModuleVersion = "0.0.1" } )
@("AzureState", @{ ModuleName = "AzureState"; ModuleVersion = "0.0.1" } )
)
# ModuleList = @()

# List of all files packaged with this module
FileList = @(
Expand All @@ -110,10 +107,10 @@ PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
Tags = 'Azure','ResourceManager','ARM','State','AzState','AzureState'

# A URL to the license for this module.
# LicenseUri = ''
LicenseUri = 'https://github.com/krowlandson/AzureStateManager/blob/master/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/krowlandson/AzureStateManager'
Expand All @@ -138,7 +135,7 @@ PrivateData = @{
} # End of PrivateData hashtable

# HelpInfo URI of this module
HelpInfoURI = 'https://github.com/krowlandson/AzureStateManager/README.md'
HelpInfoURI = 'https://github.com/krowlandson/AzureStateManager/blob/master/README.md'

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
Expand Down
10 changes: 10 additions & 0 deletions AzureStateManager.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 3.0

$module = Get-Module Az.Accounts
if ($null -ne $module -and $module.Version -lt [System.Version]"1.9.1")
{
Write-Error "This module requires Az.Accounts version 1.9.1. An earlier version of Az.Accounts is imported in the current PowerShell session. Please open a new session before importing this module. This error could indicate that multiple incompatible versions of the Azure PowerShell cmdlets are installed on your system. Please see https://aka.ms/azps-version-error for troubleshooting information." -ErrorAction Stop
}
elseif ($null -eq $module)
{
Import-Module Az.Accounts -MinimumVersion 1.9.1 -Scope Global
}

# Dot source all functions in all ps1 files located in the module
# Excludes tests and profiles

Expand Down

0 comments on commit ceb9954

Please sign in to comment.