mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
[Windows] Refactor virtual-env image generation provisioners (#1288)
* refactor virtual-env image generation provisioners
This commit is contained in:
committed by
GitHub
parent
97e1907055
commit
21165eb578
@@ -123,7 +123,7 @@
|
|||||||
],
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Install-PowerShellModules.ps1",
|
"{{ 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"
|
"execution_policy": "unrestricted"
|
||||||
},
|
},
|
||||||
@@ -183,7 +183,7 @@
|
|||||||
{
|
{
|
||||||
"type": "powershell",
|
"type": "powershell",
|
||||||
"scripts":[
|
"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`}}"
|
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
||||||
],
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Windows2016/Install-VS2017.ps1"
|
"{{ template_dir }}/scripts/Installers/Install-VS.ps1"
|
||||||
],
|
],
|
||||||
"elevated_user": "{{user `install_user`}}",
|
"elevated_user": "{{user `install_user`}}",
|
||||||
"elevated_password": "{{user `install_password`}}"
|
"elevated_password": "{{user `install_password`}}"
|
||||||
|
|||||||
@@ -123,7 +123,7 @@
|
|||||||
],
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Install-PowerShellModules.ps1",
|
"{{ 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"
|
"execution_policy": "unrestricted"
|
||||||
},
|
},
|
||||||
@@ -191,7 +191,7 @@
|
|||||||
{
|
{
|
||||||
"type": "powershell",
|
"type": "powershell",
|
||||||
"scripts":[
|
"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`}}"
|
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
||||||
],
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Windows2019/Install-VS2019.ps1"
|
"{{ template_dir }}/scripts/Installers/Install-VS.ps1"
|
||||||
],
|
],
|
||||||
"elevated_user": "{{user `install_user`}}",
|
"elevated_user": "{{user `install_user`}}",
|
||||||
"elevated_password": "{{user `install_password`}}"
|
"elevated_password": "{{user `install_password`}}"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ param()
|
|||||||
. $PSScriptRoot\InstallHelpers.ps1
|
. $PSScriptRoot\InstallHelpers.ps1
|
||||||
. $PSScriptRoot\ChocoHelpers.ps1
|
. $PSScriptRoot\ChocoHelpers.ps1
|
||||||
. $PSScriptRoot\TestsHelpers.ps1
|
. $PSScriptRoot\TestsHelpers.ps1
|
||||||
|
. $PSScriptRoot\VisualStudioHelpers.ps1
|
||||||
|
|
||||||
Export-ModuleMember -Function @(
|
Export-ModuleMember -Function @(
|
||||||
'Test-MachinePath'
|
'Test-MachinePath'
|
||||||
|
|||||||
@@ -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
|
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 {
|
function Install-AndroidSDKPackages {
|
||||||
Param
|
Param
|
||||||
(
|
(
|
||||||
|
|||||||
76
images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1
Normal file
76
images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1
Normal file
@@ -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}" }
|
||||||
|
}
|
||||||
@@ -30,6 +30,9 @@ function Disable-UserAccessControl {
|
|||||||
Write-Host "User Access Control (UAC) has been disabled."
|
Write-Host "User Access Control (UAC) has been disabled."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set TLS1.2
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
|
||||||
|
|
||||||
Write-Host "Disable Antivirus"
|
Write-Host "Disable Antivirus"
|
||||||
Set-MpPreference -DisableRealtimeMonitoring $true
|
Set-MpPreference -DisableRealtimeMonitoring $true
|
||||||
|
|
||||||
@@ -44,10 +47,15 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Install .NET Framework 3.5 (required by Chocolatey)
|
# 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.
|
# 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
|
# 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
|
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
|
# Install FS-iSCSITarget-Server
|
||||||
$fsResult = Install-WindowsFeature -Name FS-iSCSITarget-Server -IncludeAllSubFeature -IncludeManagementTools
|
$fsResult = Install-WindowsFeature -Name FS-iSCSITarget-Server -IncludeAllSubFeature -IncludeManagementTools
|
||||||
if ( $fsResult.Success ) {
|
if ( $fsResult.Success ) {
|
||||||
@@ -97,7 +105,6 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Run the installer
|
# Run the installer
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
|
|
||||||
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
||||||
|
|
||||||
# Turn off confirmation
|
# Turn off confirmation
|
||||||
@@ -110,6 +117,11 @@ Remove-Item -Path $env:ChocolateyInstall\bin\cpack.exe -Force
|
|||||||
# Install webpi
|
# Install webpi
|
||||||
Choco-Install -PackageName webpicmd
|
Choco-Install -PackageName webpicmd
|
||||||
|
|
||||||
|
if (Test-IsWin16) {
|
||||||
|
# Install vcredist140
|
||||||
|
Choco-Install -PackageName vcredist140
|
||||||
|
}
|
||||||
|
|
||||||
# Expand disk size of OS drive
|
# Expand disk size of OS drive
|
||||||
New-Item -Path d:\ -Name cmds.txt -ItemType File -Force
|
New-Item -Path d:\ -Name cmds.txt -ItemType File -Force
|
||||||
Add-Content -Path d:\cmds.txt "SELECT VOLUME=C`r`nEXTEND"
|
Add-Content -Path d:\cmds.txt "SELECT VOLUME=C`r`nEXTEND"
|
||||||
@@ -119,4 +131,3 @@ Write-Host $expandResult
|
|||||||
|
|
||||||
Write-Host "Disk sizes after expansion"
|
Write-Host "Disk sizes after expansion"
|
||||||
wmic logicaldisk get size,freespace,caption
|
wmic logicaldisk get size,freespace,caption
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
## File: Install-VS2019.ps1
|
## File: Install-VS.ps1
|
||||||
## Desc: Install Visual Studio 2019
|
## Desc: Install Visual Studio
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
@@ -15,7 +15,8 @@ $workLoads = @(
|
|||||||
$workLoadsArgument = [String]::Join(" ", $workLoads)
|
$workLoadsArgument = [String]::Join(" ", $workLoads)
|
||||||
|
|
||||||
$releaseInPath = $toolset.visualStudio.edition
|
$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 VS
|
||||||
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
||||||
@@ -31,8 +32,7 @@ if ($instanceFolders -is [array])
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$visualStudioVersion = $toolset.visualStudio.version
|
$vsInstallRoot = Get-VisualStudioPath
|
||||||
$vsInstallRoot = Get-VisualStudioPath -Version $visualStudioVersion -Edition $releaseInPath
|
|
||||||
|
|
||||||
# Initialize Visual Studio Experimental Instance
|
# Initialize Visual Studio Experimental Instance
|
||||||
& "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
|
& "$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}'
|
$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
|
Set-Content -Path "$vsInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent
|
||||||
|
|
||||||
# Install Windows 10 SDK version 10.0.14393.795
|
if (Test-IsWin19) {
|
||||||
$sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkId=838916"
|
# Install Windows 10 SDK version 10.0.14393.795
|
||||||
$sdkFileName = "sdksetup14393.exe"
|
$sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkId=838916"
|
||||||
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit")
|
$sdkFileName = "sdksetup14393.exe"
|
||||||
|
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit")
|
||||||
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList
|
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList
|
||||||
|
}
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "VisualStudio"
|
Invoke-PesterTests -TestFile "VisualStudio"
|
||||||
33
images/win/scripts/Installers/Update-DockerImages.ps1
Normal file
33
images/win/scripts/Installers/Update-DockerImages.ps1
Normal file
@@ -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
|
||||||
@@ -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
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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"
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
@@ -5,9 +5,7 @@ Describe "Visual Studio" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Devenv.exe" {
|
It "Devenv.exe" {
|
||||||
$visualStudioEdition = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty edition
|
$vsInstallRoot = Get-VisualStudioPath
|
||||||
$visualStudioVersion = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty version
|
|
||||||
$vsInstallRoot = Get-VisualStudioPath -Version $visualStudioVersion -Edition $visualStudioEdition
|
|
||||||
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
||||||
$devenvexePath | Should -Exist
|
$devenvexePath | Should -Exist
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,8 @@
|
|||||||
{"name": "Pester"},
|
{"name": "Pester"},
|
||||||
{"name": "PowerShellGet"},
|
{"name": "PowerShellGet"},
|
||||||
{"name": "PSWindowsUpdate"},
|
{"name": "PSWindowsUpdate"},
|
||||||
{"name": "SqlServer"}
|
{"name": "SqlServer"},
|
||||||
|
{"name": "VSSetup"}
|
||||||
],
|
],
|
||||||
"azureModules": [
|
"azureModules": [
|
||||||
{
|
{
|
||||||
@@ -153,6 +154,7 @@
|
|||||||
},
|
},
|
||||||
"visualStudio": {
|
"visualStudio": {
|
||||||
"version" : "2017",
|
"version" : "2017",
|
||||||
|
"subversion" : "15",
|
||||||
"edition" : "Enterprise",
|
"edition" : "Enterprise",
|
||||||
"workloads": [
|
"workloads": [
|
||||||
"Microsoft.Net.Component.4.6.2.SDK",
|
"Microsoft.Net.Component.4.6.2.SDK",
|
||||||
|
|||||||
@@ -90,7 +90,8 @@
|
|||||||
{"name": "Pester"},
|
{"name": "Pester"},
|
||||||
{"name": "PowerShellGet"},
|
{"name": "PowerShellGet"},
|
||||||
{"name": "PSWindowsUpdate"},
|
{"name": "PSWindowsUpdate"},
|
||||||
{"name": "SqlServer"}
|
{"name": "SqlServer"},
|
||||||
|
{"name": "VSSetup"}
|
||||||
],
|
],
|
||||||
"azureModules": [
|
"azureModules": [
|
||||||
{
|
{
|
||||||
@@ -162,6 +163,7 @@
|
|||||||
},
|
},
|
||||||
"visualStudio": {
|
"visualStudio": {
|
||||||
"version" : "2019",
|
"version" : "2019",
|
||||||
|
"subversion" : "16",
|
||||||
"edition" : "Enterprise",
|
"edition" : "Enterprise",
|
||||||
"workloads": [
|
"workloads": [
|
||||||
"Component.Dotfuscator",
|
"Component.Dotfuscator",
|
||||||
|
|||||||
Reference in New Issue
Block a user