diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index d87970a7f..f614bd0e3 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -123,7 +123,7 @@ ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-PowerShellModules.ps1", - "{{ template_dir }}/scripts/Installers/Windows2016/Initialize-VM.ps1" + "{{ template_dir }}/scripts/Installers/Initialize-VM.ps1" ], "execution_policy": "unrestricted" }, @@ -183,7 +183,7 @@ { "type": "powershell", "scripts":[ - "{{ template_dir }}/scripts/Installers/Windows2016/Update-DockerImages.ps1" + "{{ template_dir }}/scripts/Installers/Update-DockerImages.ps1" ] }, { @@ -196,7 +196,7 @@ "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ], "scripts":[ - "{{ template_dir }}/scripts/Installers/Windows2016/Install-VS2017.ps1" + "{{ template_dir }}/scripts/Installers/Install-VS.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 4c3c09e32..b7437cd74 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -123,7 +123,7 @@ ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-PowerShellModules.ps1", - "{{ template_dir }}/scripts/Installers/Windows2019/Initialize-VM.ps1" + "{{ template_dir }}/scripts/Installers/Initialize-VM.ps1" ], "execution_policy": "unrestricted" }, @@ -191,7 +191,7 @@ { "type": "powershell", "scripts":[ - "{{ template_dir }}/scripts/Installers/Windows2019/Update-DockerImages.ps1" + "{{ template_dir }}/scripts/Installers/Update-DockerImages.ps1" ] }, { @@ -204,7 +204,7 @@ "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ], "scripts":[ - "{{ template_dir }}/scripts/Installers/Windows2019/Install-VS2019.ps1" + "{{ template_dir }}/scripts/Installers/Install-VS.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index c8cba0a0d..e150e1a12 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -5,6 +5,7 @@ param() . $PSScriptRoot\InstallHelpers.ps1 . $PSScriptRoot\ChocoHelpers.ps1 . $PSScriptRoot\TestsHelpers.ps1 +. $PSScriptRoot\VisualStudioHelpers.ps1 Export-ModuleMember -Function @( 'Test-MachinePath' diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index c36d31c50..282c03762 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -63,68 +63,6 @@ function Install-Binary } } -Function Install-VisualStudio -{ - <# - .SYNOPSIS - A helper function to install Visual Studio. - - .DESCRIPTION - Prepare system environment, and install Visual Studio bootstrapper with selected workloads. - - .PARAMETER BootstrapperUrl - The URL from which the bootstrapper will be downloaded. Required parameter. - - .PARAMETER WorkLoads - The string that contain workloads that will be passed to the installer. - #> - - Param - ( - [Parameter(Mandatory)] - [String] $BootstrapperUrl, - [String] $WorkLoads - ) - - Write-Host "Downloading Bootstrapper ..." - $BootstrapperName = [IO.Path]::GetFileName($BootstrapperUrl) - $bootstrapperFilePath = Start-DownloadWithRetry -Url $BootstrapperUrl -Name $BootstrapperName - - try - { - Write-Host "Enable short name support on Windows needed for Xamarin Android AOT, defaults appear to have been changed in Azure VMs" - $shortNameEnableProcess = Start-Process -FilePath fsutil.exe -ArgumentList ('8dot3name', 'set', '0') -Wait -PassThru - - $shortNameEnableExitCode = $shortNameEnableProcess.ExitCode - if ($shortNameEnableExitCode -ne 0) - { - Write-Host "Enabling short name support on Windows failed. This needs to be enabled prior to VS 2017 install for Xamarin Andriod AOT to work." - exit $shortNameEnableExitCode - } - - Write-Host "Starting Install ..." - $bootstrapperArgumentList = ('/c', $bootstrapperFilePath, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache' ) - $process = Start-Process -FilePath cmd.exe -ArgumentList $bootstrapperArgumentList -Wait -PassThru - - $exitCode = $process.ExitCode - if ($exitCode -eq 0 -or $exitCode -eq 3010) - { - Write-Host "Installation successful" - return $exitCode - } - else - { - Write-Host "Non zero exit code returned by the installation process : $exitCode" - exit $exitCode - } - } - catch - { - Write-Host "Failed to install Visual Studio; $($_.Exception.Message)" - exit -1 - } -} - function Stop-SvcWithErrHandling { <# @@ -464,36 +402,6 @@ function Extract-7Zip { } } -function Get-VsCatalogJsonPath { - $instanceFolder = Get-Item "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\*" | Select-Object -First 1 - return Join-Path $instanceFolder.FullName "catalog.json" -} - -function Get-VisualStudioPath { - Param - ( - [Parameter(Mandatory=$true)] - [string]$Version, - [Parameter(Mandatory=$true)] - [string]$Edition - ) - - return "${env:ProgramFiles(x86)}\Microsoft Visual Studio\${Version}\${Edition}" -} - -function Get-VisualStudioPackages -{ - $packagePath = "$env:ProgramData\Microsoft\VisualStudio\Packages\_Instances\*\state.packages.json" - $instanceFolders = Get-ChildItem -Path $packagePath - (Get-Content -Path $instanceFolders | ConvertFrom-Json).packages -} - -function Get-VisualStudioComponents { - $vsPackages = Get-VisualStudioPackages | Where-Object type -in 'Component', 'Workload' - $vsPackages | Sort-Object Id | Select-Object @{n = 'Package'; e = {$_.Id}} | - Where-Object { $_.Package -notmatch "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}" } -} - function Install-AndroidSDKPackages { Param ( diff --git a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 new file mode 100644 index 000000000..5ab9ad0d9 --- /dev/null +++ b/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 @@ -0,0 +1,76 @@ +Function Install-VisualStudio +{ + <# + .SYNOPSIS + A helper function to install Visual Studio. + + .DESCRIPTION + Prepare system environment, and install Visual Studio bootstrapper with selected workloads. + + .PARAMETER BootstrapperUrl + The URL from which the bootstrapper will be downloaded. Required parameter. + + .PARAMETER WorkLoads + The string that contain workloads that will be passed to the installer. + #> + + Param + ( + [Parameter(Mandatory)] + [String] $BootstrapperUrl, + [String] $WorkLoads + ) + + Write-Host "Downloading Bootstrapper ..." + $BootstrapperName = [IO.Path]::GetFileName($BootstrapperUrl) + $bootstrapperFilePath = Start-DownloadWithRetry -Url $BootstrapperUrl -Name $BootstrapperName + + try + { + Write-Host "Enable short name support on Windows needed for Xamarin Android AOT, defaults appear to have been changed in Azure VMs" + $shortNameEnableProcess = Start-Process -FilePath fsutil.exe -ArgumentList ('8dot3name', 'set', '0') -Wait -PassThru + + $shortNameEnableExitCode = $shortNameEnableProcess.ExitCode + if ($shortNameEnableExitCode -ne 0) + { + Write-Host "Enabling short name support on Windows failed. This needs to be enabled prior to VS 2017 install for Xamarin Andriod AOT to work." + exit $shortNameEnableExitCode + } + + Write-Host "Starting Install ..." + $bootstrapperArgumentList = ('/c', $bootstrapperFilePath, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache' ) + $process = Start-Process -FilePath cmd.exe -ArgumentList $bootstrapperArgumentList -Wait -PassThru + + $exitCode = $process.ExitCode + if ($exitCode -eq 0 -or $exitCode -eq 3010) + { + Write-Host "Installation successful" + return $exitCode + } + else + { + Write-Host "Non zero exit code returned by the installation process : $exitCode" + exit $exitCode + } + } + catch + { + Write-Host "Failed to install Visual Studio; $($_.Exception.Message)" + exit -1 + } +} + +function Get-VsCatalogJsonPath { + $instanceFolder = Get-Item "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\*" | Select-Object -First 1 + return Join-Path $instanceFolder.FullName "catalog.json" +} + +function Get-VisualStudioPath { + return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath +} + +function Get-VisualStudioComponents { + $vsPackages = (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages.Id + $vsPackages | Select-Object @{n = 'Package'; e = {$_}} | + Where-Object { $_.Package -notmatch "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}" } +} diff --git a/images/win/scripts/Installers/Windows2019/Initialize-VM.ps1 b/images/win/scripts/Installers/Initialize-VM.ps1 similarity index 95% rename from images/win/scripts/Installers/Windows2019/Initialize-VM.ps1 rename to images/win/scripts/Installers/Initialize-VM.ps1 index 376349866..27efea2b5 100644 --- a/images/win/scripts/Installers/Windows2019/Initialize-VM.ps1 +++ b/images/win/scripts/Installers/Initialize-VM.ps1 @@ -30,6 +30,9 @@ function Disable-UserAccessControl { Write-Host "User Access Control (UAC) has been disabled." } +# Set TLS1.2 +[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" + Write-Host "Disable Antivirus" Set-MpPreference -DisableRealtimeMonitoring $true @@ -44,10 +47,15 @@ else { } # Install .NET Framework 3.5 (required by Chocolatey) -Install-WindowsFeature -Name NET-Framework-Features -IncludeAllSubFeature # Explicitly install all 4.7 sub features to include ASP.Net. # As of 1/16/2019, WinServer 19 lists .Net 4.7 as NET-Framework-45-Features +Install-WindowsFeature -Name NET-Framework-Features -IncludeAllSubFeature Install-WindowsFeature -Name NET-Framework-45-Features -IncludeAllSubFeature +if (Test-IsWin16) { + Install-WindowsFeature -Name BITS -IncludeAllSubFeature + Install-WindowsFeature -Name DSC-Service +} + # Install FS-iSCSITarget-Server $fsResult = Install-WindowsFeature -Name FS-iSCSITarget-Server -IncludeAllSubFeature -IncludeManagementTools if ( $fsResult.Success ) { @@ -97,7 +105,6 @@ else { } # Run the installer -[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) # Turn off confirmation @@ -110,6 +117,11 @@ Remove-Item -Path $env:ChocolateyInstall\bin\cpack.exe -Force # Install webpi Choco-Install -PackageName webpicmd +if (Test-IsWin16) { + # Install vcredist140 + Choco-Install -PackageName vcredist140 +} + # Expand disk size of OS drive New-Item -Path d:\ -Name cmds.txt -ItemType File -Force Add-Content -Path d:\cmds.txt "SELECT VOLUME=C`r`nEXTEND" @@ -119,4 +131,3 @@ Write-Host $expandResult Write-Host "Disk sizes after expansion" wmic logicaldisk get size,freespace,caption - diff --git a/images/win/scripts/Installers/Windows2019/Install-VS2019.ps1 b/images/win/scripts/Installers/Install-VS.ps1 similarity index 72% rename from images/win/scripts/Installers/Windows2019/Install-VS2019.ps1 rename to images/win/scripts/Installers/Install-VS.ps1 index 3d1cb205e..ed4fca73f 100644 --- a/images/win/scripts/Installers/Windows2019/Install-VS2019.ps1 +++ b/images/win/scripts/Installers/Install-VS.ps1 @@ -1,6 +1,6 @@ ################################################################################ -## File: Install-VS2019.ps1 -## Desc: Install Visual Studio 2019 +## File: Install-VS.ps1 +## Desc: Install Visual Studio ################################################################################ $ErrorActionPreference = "Stop" @@ -15,7 +15,8 @@ $workLoads = @( $workLoadsArgument = [String]::Join(" ", $workLoads) $releaseInPath = $toolset.visualStudio.edition -$bootstrapperUrl = "https://aka.ms/vs/16/release/vs_${releaseInPath}.exe" +$subVersion = $toolset.visualStudio.subversion +$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_${releaseInPath}.exe" # Install VS Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument @@ -31,8 +32,7 @@ if ($instanceFolders -is [array]) exit 1 } -$visualStudioVersion = $toolset.visualStudio.version -$vsInstallRoot = Get-VisualStudioPath -Version $visualStudioVersion -Edition $releaseInPath +$vsInstallRoot = Get-VisualStudioPath # Initialize Visual Studio Experimental Instance & "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit @@ -41,11 +41,12 @@ $vsInstallRoot = Get-VisualStudioPath -Version $visualStudioVersion -Edition $re $newContent = '{"Extensions":[{"Key":"1e906ff5-9da8-4091-a299-5c253c55fdc9","Value":{"ShouldAutoUpdate":false}},{"Key":"Microsoft.VisualStudio.Web.AzureFunctions","Value":{"ShouldAutoUpdate":false}}],"ShouldAutoUpdate":false,"ShouldCheckForUpdates":false}' Set-Content -Path "$vsInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent -# Install Windows 10 SDK version 10.0.14393.795 -$sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkId=838916" -$sdkFileName = "sdksetup14393.exe" -$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit") - -Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList +if (Test-IsWin19) { + # Install Windows 10 SDK version 10.0.14393.795 + $sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkId=838916" + $sdkFileName = "sdksetup14393.exe" + $argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit") + Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList +} Invoke-PesterTests -TestFile "VisualStudio" \ No newline at end of file diff --git a/images/win/scripts/Installers/Update-DockerImages.ps1 b/images/win/scripts/Installers/Update-DockerImages.ps1 new file mode 100644 index 000000000..d1a689d45 --- /dev/null +++ b/images/win/scripts/Installers/Update-DockerImages.ps1 @@ -0,0 +1,33 @@ +################################################################################ +## File: Update-DockerImages.ps1 +## Desc: Pull some standard docker images. +## Must be run after docker is installed. +################################################################################ + +function DockerPull { + Param ([string]$image) + + Write-Host Installing $image ... + docker pull $image + + if (!$?) { + Write-Host "Docker pull failed with a non-zero exit code" + exit 1 + } +} + +if (Test-IsWin16) { + DockerPull mcr.microsoft.com/windows/servercore:ltsc2016 + DockerPull mcr.microsoft.com/windows/nanoserver:10.0.14393.953 + DockerPull mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2016 + DockerPull mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016 +} + +if (Test-IsWin19) { + DockerPull mcr.microsoft.com/windows/servercore:ltsc2019 + DockerPull mcr.microsoft.com/windows/nanoserver:1809 + DockerPull mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 + DockerPull mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 +} + +DockerPull microsoft/aspnetcore-build:1.0-2.0 diff --git a/images/win/scripts/Installers/Windows2016/Initialize-VM.ps1 b/images/win/scripts/Installers/Windows2016/Initialize-VM.ps1 deleted file mode 100644 index 81b2ae1b6..000000000 --- a/images/win/scripts/Installers/Windows2016/Initialize-VM.ps1 +++ /dev/null @@ -1,129 +0,0 @@ -################################################################################ -## File: Initialize-VM.ps1 -## Desc: VM initialization script, machine level configuration -################################################################################ - -function Disable-InternetExplorerESC { - $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" - $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" - Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force - Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force - - $ieProcess = Get-Process -Name Explorer -ErrorAction SilentlyContinue - - if ($ieProcess){ - Stop-Process -Name Explorer -Force -ErrorAction Continue - } - - Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -} - -function Disable-InternetExplorerWelcomeScreen { - $AdminKey = "HKLM:\Software\Policies\Microsoft\Internet Explorer\Main" - New-Item -Path $AdminKey -Value 1 -Force - Set-ItemProperty -Path $AdminKey -Name "DisableFirstRunCustomize" -Value 1 -Force - Write-Host "Disabled IE Welcome screen" -} - -function Disable-UserAccessControl { - Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 -Force - Write-Host "User Access Control (UAC) has been disabled." -} - -# Set TLS1.2 -[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" - -Write-Host "Disable Antivirus" -Set-MpPreference -DisableRealtimeMonitoring $true - -# Disable Windows Update -$AutoUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -If (Test-Path -Path $AutoUpdatePath) { - Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 1 - Write-Host "Disabled Windows Update" -} -else { - Write-Host "Windows Update key does not exist" -} - -# Install Windows .NET Features -Install-WindowsFeature -Name NET-Framework-Features -IncludeAllSubFeature -Install-WindowsFeature -Name NET-Framework-45-Features -IncludeAllSubFeature -Install-WindowsFeature -Name BITS -IncludeAllSubFeature -Install-WindowsFeature -Name DSC-Service - -# Install FS-iSCSITarget-Server -$fsResult = Install-WindowsFeature -Name FS-iSCSITarget-Server -IncludeAllSubFeature -IncludeManagementTools -if ( $fsResult.Success ) { - Write-Host "FS-iSCSITarget-Server has been successfully installed" -} else { - Write-Host "Failed to install FS-iSCSITarget-Server" - exit 1 -} - -Write-Host "Disable UAC" -Disable-UserAccessControl - -Write-Host "Disable IE Welcome Screen" -Disable-InternetExplorerWelcomeScreen - -Write-Host "Disable IE ESC" -Disable-InternetExplorerESC - -Write-Host "Setting local execution policy" -Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope MachinePolicy -ErrorAction Continue | Out-Null -Get-ExecutionPolicy -List - -Write-Host "Enable long path behavior" -# See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation -Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 - -Write-Host "Install chocolatey" -$chocoExePath = 'C:\ProgramData\Chocolatey\bin' - -if ($($env:Path).ToLower().Contains($($chocoExePath).ToLower())) { - Write-Host "Chocolatey found in PATH, skipping install..." - Exit -} - -# Add to system PATH -$systemPath = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine) -$systemPath += ';' + $chocoExePath -[Environment]::SetEnvironmentVariable("PATH", $systemPath, [System.EnvironmentVariableTarget]::Machine) - -# Update local process' path -$userPath = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User) -if ($userPath) { - $env:Path = $systemPath + ";" + $userPath -} -else { - $env:Path = $systemPath -} - -# Run the installer -Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) - -# Turn off confirmation -choco feature enable -n allowGlobalConfirmation - -# https://github.com/chocolatey/choco/issues/89 -# Remove some of the command aliases, like `cpack` #89 -Remove-Item -Path $env:ChocolateyInstall\bin\cpack.exe -Force - -# Install webpi -Choco-Install -PackageName webpicmd - -# Install vcredist140 -Choco-Install -PackageName vcredist140 - -# Expand disk size of OS drive -New-Item -Path d:\ -Name cmds.txt -ItemType File -Force -Add-Content -Path d:\cmds.txt "SELECT VOLUME=C`r`nEXTEND" - -$expandResult = (diskpart /s 'd:\cmds.txt') -Write-Host $expandResult - -Write-Host "Disk sizes after expansion" -wmic logicaldisk get size,freespace,caption - - diff --git a/images/win/scripts/Installers/Windows2016/Install-VS2017.ps1 b/images/win/scripts/Installers/Windows2016/Install-VS2017.ps1 deleted file mode 100644 index e906f4eea..000000000 --- a/images/win/scripts/Installers/Windows2016/Install-VS2017.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -################################################################################ -## File: Install-VS2017.ps1 -## Desc: Install Visual Studio 2017 -################################################################################ - -$ErrorActionPreference = "Stop" - -$toolset = Get-ToolsetContent -$requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" } -$workLoads = @( - "--allWorkloads --includeRecommended" - $requiredComponents - "--remove Component.CPython3.x64" -) -$workLoadsArgument = [String]::Join(" ", $workLoads) - -$releaseInPath = $toolset.visualStudio.edition -$bootstrapperUrl = "https://aka.ms/vs/15/release/vs_${releaseInPath}.exe" - -# Install VS -Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument - -# Find the version of VS installed for this instance -# Only supports a single instance -$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances" -$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName - -if ($instanceFolders -is [array]) -{ - Write-Host "More than one instance installed" - exit 1 -} - -$visualStudioVersion = $toolset.visualStudio.version -$vsInstallRoot = Get-VisualStudioPath -Version $visualStudioVersion -Edition $releaseInPath - -# Initialize Visual Studio Experimental Instance for integration testing -& "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit | Wait-Process - -# Updating content of MachineState.json file to disable autoupdate of VSIX extensions -$newContent = '{"Extensions":[{"Key":"1e906ff5-9da8-4091-a299-5c253c55fdc9","Value":{"ShouldAutoUpdate":false}},{"Key":"Microsoft.VisualStudio.Web.AzureFunctions","Value":{"ShouldAutoUpdate":false}}],"ShouldAutoUpdate":false,"ShouldCheckForUpdates":false}' -Set-Content -Path "$vsInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent - -Invoke-PesterTests -TestFile "VisualStudio" \ No newline at end of file diff --git a/images/win/scripts/Installers/Windows2016/Update-DockerImages.ps1 b/images/win/scripts/Installers/Windows2016/Update-DockerImages.ps1 deleted file mode 100644 index bd032ea30..000000000 --- a/images/win/scripts/Installers/Windows2016/Update-DockerImages.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -################################################################################ -## File: Update-DockerImages.ps1 -## Desc: Pull some standard docker images. -## Must be run after docker is installed. -################################################################################ - -function DockerPull { - Param ([string]$image) - - Write-Host Installing $image ... - docker pull $image - - if (!$?) { - Write-Host "Docker pull failed with a non-zero exit code" - exit 1 - } -} - -DockerPull mcr.microsoft.com/windows/servercore:ltsc2016 -DockerPull mcr.microsoft.com/windows/nanoserver:10.0.14393.953 -DockerPull microsoft/aspnetcore-build:1.0-2.0 -DockerPull mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2016 -DockerPull mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016 - diff --git a/images/win/scripts/Installers/Windows2019/Update-DockerImages.ps1 b/images/win/scripts/Installers/Windows2019/Update-DockerImages.ps1 deleted file mode 100644 index bc50a9bc5..000000000 --- a/images/win/scripts/Installers/Windows2019/Update-DockerImages.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -################################################################################ -## File: Update-DockerImages.ps1 -## Desc: Pull some standard docker images. -## Must be run after docker is installed. -################################################################################ - -function DockerPull { - Param ([string]$image) - - Write-Host Installing $image ... - docker pull $image - - if (!$?) { - Write-Host "Docker pull failed with a non-zero exit code" - exit 1 - } -} - -DockerPull mcr.microsoft.com/windows/servercore:ltsc2019 -DockerPull mcr.microsoft.com/windows/nanoserver:1809 -DockerPull microsoft/aspnetcore-build:1.0-2.0 -DockerPull mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 -DockerPull mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 - diff --git a/images/win/scripts/Tests/VisualStudio.Tests.ps1 b/images/win/scripts/Tests/VisualStudio.Tests.ps1 index 77449de8f..142a9917e 100644 --- a/images/win/scripts/Tests/VisualStudio.Tests.ps1 +++ b/images/win/scripts/Tests/VisualStudio.Tests.ps1 @@ -5,9 +5,7 @@ Describe "Visual Studio" { } It "Devenv.exe" { - $visualStudioEdition = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty edition - $visualStudioVersion = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty version - $vsInstallRoot = Get-VisualStudioPath -Version $visualStudioVersion -Edition $visualStudioEdition + $vsInstallRoot = Get-VisualStudioPath $devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe" $devenvexePath | Should -Exist } diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index 96f09bd11..3525f0c78 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -81,7 +81,8 @@ {"name": "Pester"}, {"name": "PowerShellGet"}, {"name": "PSWindowsUpdate"}, - {"name": "SqlServer"} + {"name": "SqlServer"}, + {"name": "VSSetup"} ], "azureModules": [ { @@ -153,6 +154,7 @@ }, "visualStudio": { "version" : "2017", + "subversion" : "15", "edition" : "Enterprise", "workloads": [ "Microsoft.Net.Component.4.6.2.SDK", diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index 0d0dfa8b8..af76d7773 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -90,7 +90,8 @@ {"name": "Pester"}, {"name": "PowerShellGet"}, {"name": "PSWindowsUpdate"}, - {"name": "SqlServer"} + {"name": "SqlServer"}, + {"name": "VSSetup"} ], "azureModules": [ { @@ -162,6 +163,7 @@ }, "visualStudio": { "version" : "2019", + "subversion" : "16", "edition" : "Enterprise", "workloads": [ "Component.Dotfuscator",