diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index fa1352c8..442218d3 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -325,7 +325,9 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", - "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1" + "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", + "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -383,9 +385,7 @@ { "type": "powershell", "scripts":[ - "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", - "{{ template_dir }}/scripts/Installers/Post-Deployment.ps1" + "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1" ] }, { diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 351ea5b7..0e3d180b 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -324,7 +324,9 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1", - "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1" + "{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1", + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", + "{{ template_dir }}/scripts/Installers/Configure-Shell.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -383,9 +385,7 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", - "{{ template_dir }}/scripts/Installers/Run-NGen.ps1", - "{{ template_dir }}/scripts/Installers/Post-Deployment.ps1" + "{{ template_dir }}/scripts/Installers/Run-NGen.ps1" ] }, { diff --git a/images/win/scripts/Installers/Configure-Shell.ps1 b/images/win/scripts/Installers/Configure-Shell.ps1 new file mode 100644 index 00000000..6bb7bc50 --- /dev/null +++ b/images/win/scripts/Installers/Configure-Shell.ps1 @@ -0,0 +1,19 @@ +# Create shells folder +$shellPath = "C:\shells" +New-Item -Path $shellPath -ItemType Directory | Out-Null + +# sh and bash <--> C:\msys64\usr\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null +New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" | Out-Null + +# winbash <--> C:\Windows\System32\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null + +# git4bash <--> C:\Program Files\Git\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null + +# MSYS2 <--> C:\msys64\usr\bin\bash.exe +New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null + +# Add shells to PATH +Add-MachinePathItem $shellPath \ No newline at end of file diff --git a/images/win/scripts/Installers/Post-Deployment.ps1 b/images/win/scripts/Installers/Post-Deployment.ps1 deleted file mode 100644 index c514800d..00000000 --- a/images/win/scripts/Installers/Post-Deployment.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# Create shells folder -$shellPath = "C:\shells" -$null = New-Item -Path $shellPath -ItemType Directory - -# MSYS2 <--> C:\msys64\usr\bin\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" - -# sh and bash <--> C:\msys64\usr\bin\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" - -# winbash <--> C:\Windows\System32\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" - -# git4bash <--> C:\Program Files\Git\bin\bash.exe -$null = New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" - -# Add shells to PATH -Add-MachinePathItem $shellPath \ No newline at end of file diff --git a/images/win/scripts/Tests/Shell.Tests.ps1 b/images/win/scripts/Tests/Shell.Tests.ps1 new file mode 100644 index 00000000..e7645f2e --- /dev/null +++ b/images/win/scripts/Tests/Shell.Tests.ps1 @@ -0,0 +1,43 @@ +Describe "Shell" { + $shellTestCases = @( + @{Name = "C:\shells\bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"}, + @{Name = "C:\shells\sh.exe"; Target = "C:\msys64\usr\bin\sh.exe"}, + @{Name = "C:\shells\winbash.exe"; Target = "$env:SystemRoot\System32\bash.exe"}, + @{Name = "C:\shells\git4bash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"}, + @{Name = "C:\shells\msys2.exe"; Target = "C:\msys64\usr\bin\bash.exe"} + ) + + $pathTestCases = @( + @{Path = "C:\shells"}, + @{Path = "C:\msys64\mingw64\bin"}, + @{Path = "C:\msys64\usr\bin"} + ) + + It "Default bash.exe from MSYS2" { + (Get-Command bash).Path | Should -BeExactly "C:\shells\bash.exe" + } + + It "Default sh.exe from MSYS2" { + (Get-Command sh).Path | Should -BeExactly "C:\shells\sh.exe" + } + + It "Folder C:\shells exists" { + "C:\shells" | Should -Exist + } + + It "C:\Windows\System32 before C:\msys64\mingw64\bin and C:\msys64\usr\bin" { + $path = $env:Path.Split(";").ToLower() + $indexOfSystem32 = $path.IndexOf("c:\windows\system32") + + $path.IndexOf("c:\msys64\mingw64\bin") | Should -BeGreaterThan $indexOfSystem32 + $path.IndexOf("c:\msys64\usr\bin") | Should -BeGreaterThan $indexOfSystem32 + } + + It " target to " -TestCases $shellTestCases { + (Get-Item $Name).Target | Should -BeExactly $Target + } + + It " is in PATH" -TestCases $pathTestCases { + $env:Path.Split(";") | Should -Contain $Path + } +} \ No newline at end of file