Skip to content

Update installer to clean up gallery modules [#108777558] #1403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions setup/Setup/RemoveGalleryModules.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

function Remove-Modules
{
param([string]$basePath)
$paths = "Azure", "AzureRM", "AzureRM.*", "Azure.Storage"
$paths | ForEach-Object {
$modulePath = ([System.IO.Path]::Combine($basePath, $_))
try {
Write-Host Removing $_
if (Test-Path $modulePath)
{
Remove-Item -Recurse $modulePath -Force
}
}
catch {}
}
}

if (Test-Path 'Env:\ProgramFiles(x86)')
{
Remove-Modules ([System.IO.Path]::Combine(${env:ProgramFiles(x86)}, "WindowsPowerShell", "Modules"))
}

if (Test-Path Env:\ProgramFiles)
{
Remove-Modules ([System.IO.Path]::Combine($env:ProgramFiles, "WindowsPowerShell", "Modules"))
}

1 change: 0 additions & 1 deletion setup/Setup/SetExecutionPolicy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# limitations under the License.
# ----------------------------------------------------------------------------------


try
{
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force -ErrorAction "SilentlyContinue"
Expand Down
55 changes: 23 additions & 32 deletions setup/azurecmd.wxs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

<?define productName="Microsoft Azure PowerShell - November 2015" ?>
<?define sourceDir="$(var.SolutionDir)..\src\Package\$(var.Configuration)" ?>
Expand All @@ -8,7 +8,7 @@
<?define version="1.0.1" ?>
<?define versionedStartMenuFolder="Microsoft Azure" ?>
<?define staleStartMenuFolder="Windows Azure" ?>

<Product Id="*"
Name="$(var.productName)"
Language="1033"
Expand Down Expand Up @@ -40,27 +40,9 @@
</SetProperty>

<SetProperty Id="POWERSHELLEXE" Value="[WindowsFolder]System32\WindowsPowerShell\v1.0\powershell.exe" Before="AppSearch"/>

<Property Id="POWERSHELLGETMODULESINSTALLED" >
<DirectorySearch Id="PROGRAMFILESCONTAINER" Path="[BaseModulesFolder]">
<DirectorySearch Id= "PROFILEMODULE" Path="AzureRM.Profile"/>
</DirectorySearch>
</Property>

<Property Id="POWERSHELLGETAZUREINSTALLED" >
<DirectorySearch Id="AZURECONTAINER" Path="[BaseModulesFolder]">
<DirectorySearch Id= "AZUREMODULE" Path="Azure"/>
</DirectorySearch>
</Property>

<Condition Message="Azure Modules from the PowerShell Gallery are installed on this machine. Please remove these modules before installing this MSI.">
<![CDATA[Installed or NOT(POWERSHELLGETMODULESINSTALLED >< "AzureRM.Profile")]]>
</Condition>

<Condition Message="Azure Modules from the PowerShell Gallery are installed on this machine. Please remove these modules before installing this MSI.">
<![CDATA[Installed or NOT(POWERSHELLGETAZUREINSTALLED >< "Azure")]]>
</Condition>


<util:CloseApplication Id="ClosePowerShellExe" Target="powershell.exe" ElevatedCloseMessage="yes" CloseMessage="yes" PromptToContinue="yes" Description="PowerShell must be closed to continue with this installation. Please close any PowerShell windows and click 'Retry', or click 'Cancel' to stop installation. If you click 'Ignore' the installer will attempt to close any open PowerShell window."/>
<util:CloseApplication Id="ClosePowerShellIseExe" Target="powershell_ise.exe" ElevatedCloseMessage="yes" CloseMessage="yes" PromptToContinue="yes" Description="PowerShell ISE must be closed to continue with this installation. Please close any PowerShell ISE windows and click 'Retry', or click 'Cancel' to stop installation. If you click 'Ignore' the installer will attempt to close any open PowerShell ISE window."/>

<Condition Message="This setup requires the Windows PowerShell 3.0 or compatible version to be installed.">
<!-- This condition will break if PowerShell has version x3.0 and it is not compatible with 3.0 -->
Expand Down Expand Up @@ -88,19 +70,19 @@
</Directory>

<Property Id="POWERSHELLPATH">
<RegistrySearch Id="POWERSHELLPATH"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
Name="ApplicationBase" />
<RegistrySearch Id="POWERSHELLPATH"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
Name="ApplicationBase" />
</Property>

<DirectoryRef Id="PowerShellFolder">
<Component Id="PSModulePath.System" Guid="273525B9-7AAB-421A-90C8-8E50A1840B8D">
<CreateFolder />
<!-- Work around bug that PowerShell does not always consider default module paths. -->
<Environment Id="PSModulePath.SystemAppRoot" Action="set" Name="PSMODULEPATH" Part="last" Value="[BaseModulesFolder];[PowerShellFolder]ResourceManager\AzureResourceManager;[PowerShellFolder]ServiceManagement" System="yes" />
</Component>
</Component>
</DirectoryRef>

<DirectoryRef Id="PowerShellFolder">
Expand All @@ -109,6 +91,12 @@
</Component>
</DirectoryRef>

<DirectoryRef Id="PowerShellFolder">
<Component Id="AzureSdkRemoveModulesScript" Guid="7d75fe67-88e4-40da-bc3d-874cb0438d30">
<File Id="AzureSdkRemoveModulesScriptFile" KeyPath="yes" Source="$(var.SolutionDir)\Setup\RemoveGalleryModules.ps1" />
</Component>
</DirectoryRef>

<DirectoryRef Id="AzureSdkMenu">
<Component Id="AzureSdkShortcut" Guid="A9B58A22-F746-451D-8840-F887D8014C3C">
<Shortcut Id="AzureSdkStartMenuShortcut"
Expand All @@ -127,17 +115,20 @@
<ComponentRef Id="PSModulePath.System" />
<ComponentRef Id="AzureSdkShortcut" />
<ComponentRef Id="AzureSdkExecutionPolicyScript" />
</Feature>
<ComponentRef Id="AzureSdkRemoveModulesScript" />
</Feature>

<Binary Id="CustomActions" SourceFile="$(var.caSourceDir)\Microsoft.WindowsAzure.Setup.CA.dll"/>
<CustomAction Id="UpdatePSShortcut" BinaryKey="CustomActions" DllEntry="UpdatePSShortcut" Execute ="deferred" Impersonate="no"/>
<CustomAction Id="SetCustomActionDataValue" Return="check" Property="UpdatePSShortcut"
Value="ShortcutPath=[AzureSdkMenu]Microsoft Azure PowerShell.lnk;DefaultShortcutPath=[ProgramMenuFolder]System Tools\Windows PowerShell.lnk" />
<CustomAction Id="SetExecutionPolicy" Property="POWERSHELLEXE" ExeCommand="-NoLogo -NoProfile -ExecutionPolicy Bypass -Command &quot;. \&quot;[PowerShellFolder]SetExecutionPolicy.ps1\&quot;&quot;" Execute="deferred" Impersonate="no" Return="check"/>
<CustomAction Id="SetExecutionPolicy" Property="POWERSHELLEXE" ExeCommand="-NoLogo -NoProfile -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -Command &quot;. \&quot;[PowerShellFolder]SetExecutionPolicy.ps1\&quot;&quot;" Execute="deferred" Impersonate="no" Return="check"/>
<CustomAction Id="RemoveGalleryModules" Property="POWERSHELLEXE" ExeCommand="-NoLogo -NoProfile -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -Command &quot;. \&quot;[PowerShellFolder]RemoveGalleryModules.ps1\&quot;&quot;" Execute="deferred" Impersonate="no" Return="check"/>

<InstallExecuteSequence>
<Custom Action="SetCustomActionDataValue" After="CreateShortcuts">NOT Installed</Custom>
<Custom Action="UpdatePSShortcut" After="SetCustomActionDataValue">NOT Installed</Custom>
<Custom Action="RemoveGalleryModules" After="SetCustomActionDataValue">NOT Installed</Custom>
<Custom Action="UpdatePSShortcut" After="RemoveGalleryModules">NOT Installed</Custom>
<Custom Action="SetExecutionPolicy" After="UpdatePSShortcut">NOT Installed</Custom>
</InstallExecuteSequence>

Expand Down