Azure / deployment-stacks

Contains Deployment Stacks CLI scripts and releases
MIT License
87 stars 6 forks source link

"Assembly with same name is already loaded" during PowerShell module installation #91

Closed janegilring closed 1 year ago

janegilring commented 1 year ago

Describe the bug The error "Assembly with same name is already loaded" is returned during PowerShell module installation, when selecting option 1 ("Install in current Powershell session").

To Reproduce Steps to reproduce the behavior:

  1. Download and unzip the latest release AzDeploymentStacksPrivatePreview_Powershell_9.1.8.zip
  2. Run AzDeploymentStacksPrivatePreview.ps1:
AzDeploymentStacks Private Preview
=============================================================
Manages installation of the cmdlets for the private preview 
build of Az.Resources which can be used to manage/deploy 
Deployment Stacks.

This script can perform multiple operations. Select the operation you'd like to perform:

   1. Install module in current Powershell session
   4. Install module system-wide
   5. Uninstall module (previous system-wide installs)

Note: When you install the preview module, the preview functionality 
      will override the official/public Az.Resources module functionality until 
      the Powershell session is closed (if option 1 is selected) or until the 
      preview module is uninstalled through this script (if installed through 
      option 2).

Which operation (1, 2, or 3)?: 1
This action will install the Deployment Stack cmdlet(s) to the current 
Powershell Session (prompt) so they can be previewed/tested.

Continue with install? (Y/N): Y
Verifying Azure Powershell module availability...
Azure Powershell module verified!

Verifying you're logged into Azure...
Login verified!

Installing demo module 'Az.Resources'... (current session only)
Import-Module: /home/vscode/downloads/AzDeploymentStacksPrivatePreview_Powershell_9.1.8/AzDeploymentStacksPrivatePreview.ps1:260:5
Line |
 260 |      Import-Module -Name $modulePsdPath
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Assembly with same name is already loaded

Expected behavior The operation should succeed when choosing option 1.

When choosing option 2, it works:

Installing demo module 'Az.Resources'... (system-wide installation)
Module installed!

Repro Environment

PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Linux 5.4.0-1101-azure #107~18.04.1-Ubuntu SMP Tue Jan 10 21:14:56 UTC 20…
Platform                       Unix

This environment is running inside GitHub Codespaces.

The latest version of the Az-module is also installed.

Update

The issue is also re-produced in a local VS Code dev container running the following versions:

PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Linux 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 20…
Platform                       Unix
dantedallag commented 1 year ago

Is this happening when you install system wide and then attempt to install in the current session? Does it give you an error if you uninstall system wide (option 3) and try local install again?

Also, we just released a new version of the cmdlets that you can give a try as well. The incremented version will hopefully solve this, but if it doesn't (or you want guidance on removing an old version that is not being removed correctly with script) I can help with that.

azcloudfarmer commented 1 year ago

@janegilring friendly ping on this issue. Are you still running into this?

janegilring commented 1 year ago

Sorry for the late response on this issue.

It works fine using AzDeploymentStacksPrivatePreview_Powershell_9.1.9.

Option 1:

Select the operation you'd like to perform:

   1. Install module in current Powershell session
   2. Install module system-wide
   3. Uninstall module (previous system-wide installs)

Note: When you install the preview module, the preview functionality 
      will override the official/public Az.Resources module functionality until 
      the Powershell session is closed (if option 1 is selected) or until the 
      preview module is uninstalled through this script (if installed through 
      option 2).

Which operation (1, 2, or 3)?: 1
This action will install the Deployment Stack cmdlet(s) to the current 
Powershell Session (prompt) so they can be previewed/tested.

Continue with install? (Y/N): y
Verifying Azure Powershell module availability...
Azure Powershell module verified!

Verifying you're logged into Azure...
Login verified!

Installing demo module 'Az.Resources'... (current session only)
Module installed!

Option 2:

Select the operation you'd like to perform:

   1. Install module in current Powershell session
   2. Install module system-wide
   3. Uninstall module (previous system-wide installs)

Note: When you install the preview module, the preview functionality 
      will override the official/public Az.Resources module functionality until 
      the Powershell session is closed (if option 1 is selected) or until the 
      preview module is uninstalled through this script (if installed through 
      option 2).

Which operation (1, 2, or 3)?: 2
This action will install the Deployment Stack cmdlet(s) to your system 
so they can be previewed/tested. To return to the non-preview cmdlets 
afterwards, you'll need to run this script again and select the uninstall 
option.

Continue with install? (Y/N): y
Verifying Azure Powershell module availability...
Azure Powershell module verified!

Verifying you're logged into Azure...
Login verified!

Installing demo module 'Az.Resources'... (system-wide installation)
Module installed!