mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
Improve Windows Visual Studio provisioners (#758)
* Add retries to DotnetSDK provisioner * Improve VS provisioners * Fixes in syntax * Fixes in syntax * Rename Install-VS function * Remove bootstrapperName parameter from Install-VisualStudio * Small fix
This commit is contained in:
@@ -14,6 +14,7 @@ Export-ModuleMember -Function @(
|
|||||||
'Get-SystemVariable'
|
'Get-SystemVariable'
|
||||||
'Set-SystemVariable'
|
'Set-SystemVariable'
|
||||||
'Install-Binary'
|
'Install-Binary'
|
||||||
|
'Install-VisualStudio'
|
||||||
'Get-ToolcachePackages'
|
'Get-ToolcachePackages'
|
||||||
'Get-ToolsetContent'
|
'Get-ToolsetContent'
|
||||||
'Get-ToolsByName'
|
'Get-ToolsByName'
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ function Install-Binary
|
|||||||
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Name "winsdksetup.exe" -ArgumentList ("/features", "+", "/quiet")
|
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Name "winsdksetup.exe" -ArgumentList ("/features", "+", "/quiet")
|
||||||
#>
|
#>
|
||||||
|
|
||||||
Param (
|
Param
|
||||||
|
(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[String] $Url,
|
[String] $Url,
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -62,6 +63,68 @@ 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
|
||||||
{
|
{
|
||||||
<#
|
<#
|
||||||
@@ -74,7 +137,8 @@ function Stop-SvcWithErrHandling
|
|||||||
.PARAMETER StopOnError
|
.PARAMETER StopOnError
|
||||||
Switch for stopping the script and exit from PowerShell if one service is absent
|
Switch for stopping the script and exit from PowerShell if one service is absent
|
||||||
#>
|
#>
|
||||||
param (
|
param
|
||||||
|
(
|
||||||
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
||||||
[string] $ServiceName,
|
[string] $ServiceName,
|
||||||
[switch] $StopOnError
|
[switch] $StopOnError
|
||||||
@@ -123,7 +187,8 @@ function Set-SvcWithErrHandling
|
|||||||
Hashtable for service arguments
|
Hashtable for service arguments
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param (
|
param
|
||||||
|
(
|
||||||
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
||||||
[string] $ServiceName,
|
[string] $ServiceName,
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -152,7 +217,8 @@ function Set-SvcWithErrHandling
|
|||||||
|
|
||||||
function Start-DownloadWithRetry
|
function Start-DownloadWithRetry
|
||||||
{
|
{
|
||||||
param (
|
param
|
||||||
|
(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string] $Url,
|
[string] $Url,
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -253,7 +319,8 @@ function Install-VsixExtension
|
|||||||
|
|
||||||
function Get-VSExtensionVersion
|
function Get-VSExtensionVersion
|
||||||
{
|
{
|
||||||
param (
|
Param
|
||||||
|
(
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string] $packageName
|
[string] $packageName
|
||||||
)
|
)
|
||||||
@@ -289,7 +356,8 @@ function Get-ToolsetContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-ToolsByName {
|
function Get-ToolsByName {
|
||||||
param (
|
Param
|
||||||
|
(
|
||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $True)]
|
||||||
[string]$SoftwareName
|
[string]$SoftwareName
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ function InstallSDKVersion (
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Fix for issue 1276. This will be fixed in 3.1.
|
# Fix for issue 1276. This will be fixed in 3.1.
|
||||||
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/dotnet/sdk/82bc30c99f1325dfaa7ad450be96857a4fca2845/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.ImportPublishProfile.targets" -outfile "C:\Program Files\dotnet\sdk\$sdkVersion\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportPublishProfile.targets"
|
$sdkTargetsName = "Microsoft.NET.Sdk.ImportPublishProfile.targets"
|
||||||
|
$sdkTargetsUrl = "https://raw.githubusercontent.com/dotnet/sdk/82bc30c99f1325dfaa7ad450be96857a4fca2845/src/Tasks/Microsoft.NET.Build.Tasks/targets/${sdkTargetsName}"
|
||||||
|
$sdkTargetsPath = "C:\Program Files\dotnet\sdk\$sdkVersion\Sdks\Microsoft.NET.Sdk\targets"
|
||||||
|
Start-DownloadWithRetry -Url $sdkTargetsUrl -DownloadPath $sdkTargetsPath -Name $sdkTargetsName
|
||||||
|
|
||||||
# warm up dotnet for first time experience
|
# warm up dotnet for first time experience
|
||||||
$templates | ForEach-Object {
|
$templates | ForEach-Object {
|
||||||
@@ -49,8 +52,10 @@ function InstallSDKVersion (
|
|||||||
|
|
||||||
function InstallAllValidSdks()
|
function InstallAllValidSdks()
|
||||||
{
|
{
|
||||||
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json' -UseBasicParsing -OutFile 'releases-index.json'
|
$releaseIndexName = "releases-index.json"
|
||||||
$dotnetChannels = Get-Content -Path 'releases-index.json' | ConvertFrom-Json
|
$releaseIndexUrl = "https://raw.githubusercontent.com/dotnet/core/master/release-notes/${releaseIndexName}"
|
||||||
|
$releasesIndexPath = Start-DownloadWithRetry -Url $releaseIndexUrl -Name $releaseIndexName
|
||||||
|
$dotnetChannels = Get-Content -Path $releasesIndexPath | ConvertFrom-Json
|
||||||
|
|
||||||
# Consider all channels except preview/eol channels.
|
# Consider all channels except preview/eol channels.
|
||||||
# Sort the channels in ascending order
|
# Sort the channels in ascending order
|
||||||
@@ -58,13 +63,15 @@ function InstallAllValidSdks()
|
|||||||
$dotnetChannels = $dotnetChannels.'releases-index' | Where-Object { (!$_."support-phase".Equals('preview') -and !$_."support-phase".Equals('eol')) -or ($_."channel-version" -eq "2.2") } | Sort-Object { [Version] $_."channel-version" }
|
$dotnetChannels = $dotnetChannels.'releases-index' | Where-Object { (!$_."support-phase".Equals('preview') -and !$_."support-phase".Equals('eol')) -or ($_."channel-version" -eq "2.2") } | Sort-Object { [Version] $_."channel-version" }
|
||||||
|
|
||||||
# Download installation script.
|
# Download installation script.
|
||||||
Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile 'dotnet-install.ps1'
|
$installationName = "dotnet-install.ps1"
|
||||||
|
$installationUrl = "https://dot.net/v1/${installationName}"
|
||||||
|
Start-DownloadWithRetry -Url $installationUrl -Name $installationName -DownloadPath ".\"
|
||||||
|
|
||||||
ForEach ($dotnetChannel in $dotnetChannels)
|
ForEach ($dotnetChannel in $dotnetChannels)
|
||||||
{
|
{
|
||||||
$channelVersion = $dotnetChannel.'channel-version';
|
$channelVersion = $dotnetChannel.'channel-version';
|
||||||
Invoke-WebRequest -Uri $dotnetChannel.'releases.json' -UseBasicParsing -OutFile "releases-$channelVersion.json"
|
$releasesJsonPath = Start-DownloadWithRetry -Url $dotnetChannel.'releases.json' -Name "releases-$channelVersion.json"
|
||||||
$currentReleases = Get-Content -Path "releases-$channelVersion.json" | ConvertFrom-Json
|
$currentReleases = Get-Content -Path $releasesJsonPath | ConvertFrom-Json
|
||||||
# filtering out the preview/rc releases
|
# filtering out the preview/rc releases
|
||||||
$currentReleases = $currentReleases.'releases' | Where-Object { !$_.'release-version'.Contains('-') } | Sort-Object { [Version] $_.'release-version' }
|
$currentReleases = $currentReleases.'releases' | Where-Object { !$_.'release-version'.Contains('-') } | Sort-Object { [Version] $_.'release-version' }
|
||||||
|
|
||||||
@@ -74,7 +81,6 @@ function InstallAllValidSdks()
|
|||||||
{
|
{
|
||||||
Write-Host 'Found sdks property in release: ' + $release.'release-version' + 'with sdks count: ' + $release.'sdks'.Count
|
Write-Host 'Found sdks property in release: ' + $release.'release-version' + 'with sdks count: ' + $release.'sdks'.Count
|
||||||
|
|
||||||
|
|
||||||
# Remove duplicate entries & preview/rc version from download list
|
# Remove duplicate entries & preview/rc version from download list
|
||||||
# Sort the sdks on version
|
# Sort the sdks on version
|
||||||
$sdks = @($release.'sdk');
|
$sdks = @($release.'sdk');
|
||||||
|
|||||||
@@ -3,61 +3,9 @@
|
|||||||
## Desc: Install Visual Studio 2017
|
## Desc: Install Visual Studio 2017
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
Function InstallVS
|
$ErrorActionPreference = "Stop"
|
||||||
{
|
|
||||||
Param
|
|
||||||
(
|
|
||||||
[String]$WorkLoads,
|
|
||||||
[String]$Sku,
|
|
||||||
[String] $VSBootstrapperURL
|
|
||||||
)
|
|
||||||
|
|
||||||
$exitCode = -1
|
Import-Module -Name ImageHelpers -Force
|
||||||
|
|
||||||
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 -Object '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 "Downloading Bootstrapper ..."
|
|
||||||
Invoke-WebRequest -Uri $VSBootstrapperURL -OutFile "${env:Temp}\vs_$Sku.exe"
|
|
||||||
|
|
||||||
$FilePath = "${env:Temp}\vs_$Sku.exe"
|
|
||||||
$Arguments = ('/c', $FilePath, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache' )
|
|
||||||
|
|
||||||
Write-Host "Starting Install ..."
|
|
||||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru
|
|
||||||
$exitCode = $process.ExitCode
|
|
||||||
|
|
||||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
|
||||||
{
|
|
||||||
Write-Host -Object 'Installation successful'
|
|
||||||
return $exitCode
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
|
||||||
|
|
||||||
# this wont work because of log size limitation in extension manager
|
|
||||||
# Get-Content $customLogFilePath | Write-Host
|
|
||||||
|
|
||||||
exit $exitCode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Write-Host -Object "Failed to install Visual Studio. Check the logs for details in $customLogFilePath"
|
|
||||||
Write-Host -Object $_.Exception.Message
|
|
||||||
exit -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$WorkLoads = '--allWorkloads --includeRecommended ' + `
|
$WorkLoads = '--allWorkloads --includeRecommended ' + `
|
||||||
'--add Microsoft.Net.Component.4.6.2.SDK ' + `
|
'--add Microsoft.Net.Component.4.6.2.SDK ' + `
|
||||||
@@ -129,20 +77,18 @@ $WorkLoads = '--allWorkloads --includeRecommended ' + `
|
|||||||
'--add Microsoft.VisualStudio.Workload.Office ' + `
|
'--add Microsoft.VisualStudio.Workload.Office ' + `
|
||||||
'--add Microsoft.VisualStudio.Workload.OfficeBuildTools '
|
'--add Microsoft.VisualStudio.Workload.OfficeBuildTools '
|
||||||
|
|
||||||
$Sku = 'Enterprise'
|
$ReleaseInPath = "Enterprise"
|
||||||
$VSBootstrapperURL = 'https://aka.ms/vs/15/release/vs_enterprise.exe'
|
$BootstrapperUrl = "https://aka.ms/vs/15/release/vs_${ReleaseInPath}.exe"
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
|
||||||
|
|
||||||
# Install VS
|
# Install VS
|
||||||
$exitCode = InstallVS -WorkLoads $WorkLoads -Sku $Sku -VSBootstrapperURL $VSBootstrapperURL
|
Install-VisualStudio -BootstrapperUrl $BootstrapperUrl -WorkLoads $WorkLoads
|
||||||
|
|
||||||
# Find the version of VS installed for this instance
|
# Find the version of VS installed for this instance
|
||||||
# Only supports a single instance
|
# Only supports a single instance
|
||||||
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
||||||
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
||||||
|
|
||||||
if($instanceFolders -is [array])
|
if ($instanceFolders -is [array])
|
||||||
{
|
{
|
||||||
Write-Host "More than one instance installed"
|
Write-Host "More than one instance installed"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -151,20 +97,19 @@ if($instanceFolders -is [array])
|
|||||||
$catalogContent = Get-Content -Path ($instanceFolders.FullName + '\catalog.json')
|
$catalogContent = Get-Content -Path ($instanceFolders.FullName + '\catalog.json')
|
||||||
$catalog = $catalogContent | ConvertFrom-Json
|
$catalog = $catalogContent | ConvertFrom-Json
|
||||||
$version = $catalog.info.id
|
$version = $catalog.info.id
|
||||||
$VSInstallRoot = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"
|
$VSInstallRoot = "C:\Program Files (x86)\Microsoft Visual Studio\2017\$ReleaseInPath"
|
||||||
Write-Host "Visual Studio version" $version "installed"
|
Write-Host "Visual Studio version ${version} installed"
|
||||||
|
|
||||||
# Initialize Visual Studio Experimental Instance for integration testing
|
# Initialize Visual Studio Experimental Instance for integration testing
|
||||||
&"$VSInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit | Wait-Process
|
& "$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
|
# 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}'
|
$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
|
||||||
|
|
||||||
|
|
||||||
# Adding description of the software to Markdown
|
# Adding description of the software to Markdown
|
||||||
|
|
||||||
$SoftwareName = "Visual Studio 2017 Enterprise"
|
$SoftwareName = "Visual Studio 2017 $ReleaseInPath"
|
||||||
|
|
||||||
$Description = @"
|
$Description = @"
|
||||||
_Version:_ $version<br/>
|
_Version:_ $version<br/>
|
||||||
@@ -199,7 +144,3 @@ Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $
|
|||||||
|
|
||||||
# Adding explicitly added Workloads details to markdown by parsing $Workloads
|
# Adding explicitly added Workloads details to markdown by parsing $Workloads
|
||||||
Add-ContentToMarkdown -Content $($WorkLoads.Split('--') | % { if( ($_.Split(" "))[0] -like "add") { "* " +($_.Split(" "))[1] } } )
|
Add-ContentToMarkdown -Content $($WorkLoads.Split('--') | % { if( ($_.Split(" "))[0] -like "add") { "* " +($_.Split(" "))[1] } } )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exit $exitCode
|
|
||||||
|
|||||||
@@ -4,61 +4,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
Function InstallVS
|
Import-Module -Name ImageHelpers -Force
|
||||||
{
|
|
||||||
Param
|
|
||||||
(
|
|
||||||
[String]$WorkLoads,
|
|
||||||
[String]$Sku,
|
|
||||||
[String] $VSBootstrapperURL
|
|
||||||
)
|
|
||||||
|
|
||||||
$exitCode = -1
|
|
||||||
|
|
||||||
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 -Object '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 "Downloading Bootstrapper ..."
|
|
||||||
Invoke-WebRequest -Uri $VSBootstrapperURL -OutFile "${env:Temp}\vs_$Sku.exe"
|
|
||||||
|
|
||||||
$FilePath = "${env:Temp}\vs_$Sku.exe"
|
|
||||||
$Arguments = ('/c', $FilePath, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache' )
|
|
||||||
|
|
||||||
Write-Host "Starting Install ..."
|
|
||||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru
|
|
||||||
$exitCode = $process.ExitCode
|
|
||||||
|
|
||||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
|
||||||
{
|
|
||||||
Write-Host -Object 'Installation successful'
|
|
||||||
return $exitCode
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
|
||||||
|
|
||||||
# this wont work because of log size limitation in extension manager
|
|
||||||
# Get-Content $customLogFilePath | Write-Host
|
|
||||||
|
|
||||||
exit $exitCode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Write-Host -Object "Failed to install Visual Studio. Check the logs for details in $customLogFilePath"
|
|
||||||
Write-Host -Object $_.Exception.Message
|
|
||||||
exit -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$WorkLoads = '--allWorkloads --includeRecommended ' + `
|
$WorkLoads = '--allWorkloads --includeRecommended ' + `
|
||||||
'--add Component.Dotfuscator ' + `
|
'--add Component.Dotfuscator ' + `
|
||||||
@@ -150,22 +96,18 @@ $WorkLoads = '--allWorkloads --includeRecommended ' + `
|
|||||||
'--add Microsoft.VisualStudio.Workload.Universal ' + `
|
'--add Microsoft.VisualStudio.Workload.Universal ' + `
|
||||||
'--add Microsoft.VisualStudio.Workload.VisualStudioExtension'
|
'--add Microsoft.VisualStudio.Workload.VisualStudioExtension'
|
||||||
|
|
||||||
|
$ReleaseInPath = "Enterprise"
|
||||||
$ReleaseInPath = 'Enterprise'
|
$BootstrapperUrl = "https://aka.ms/vs/16/release/vs_${ReleaseInPath}.exe"
|
||||||
$Sku = 'Enterprise'
|
|
||||||
$VSBootstrapperURL = 'https://aka.ms/vs/16/release/vs_Enterprise.exe'
|
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
|
||||||
|
|
||||||
# Install VS
|
# Install VS
|
||||||
$exitCode = InstallVS -WorkLoads $WorkLoads -Sku $Sku -VSBootstrapperURL $VSBootstrapperURL
|
Install-VisualStudio -BootstrapperUrl $BootstrapperUrl -WorkLoads $WorkLoads
|
||||||
|
|
||||||
# Find the version of VS installed for this instance
|
# Find the version of VS installed for this instance
|
||||||
# Only supports a single instance
|
# Only supports a single instance
|
||||||
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
||||||
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
||||||
|
|
||||||
if($instanceFolders -is [array])
|
if ($instanceFolders -is [array])
|
||||||
{
|
{
|
||||||
Write-Host "More than one instance installed"
|
Write-Host "More than one instance installed"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -174,14 +116,15 @@ if($instanceFolders -is [array])
|
|||||||
$catalogContent = Get-Content -Path ($instanceFolders.FullName + '\catalog.json')
|
$catalogContent = Get-Content -Path ($instanceFolders.FullName + '\catalog.json')
|
||||||
$catalog = $catalogContent | ConvertFrom-Json
|
$catalog = $catalogContent | ConvertFrom-Json
|
||||||
$version = $catalog.info.id
|
$version = $catalog.info.id
|
||||||
Write-Host "Visual Studio version" $version "installed"
|
$VSInstallRoot = "C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath"
|
||||||
|
Write-Host "Visual Studio version ${version} installed"
|
||||||
|
|
||||||
# Initialize Visual Studio Experimental Instance
|
# Initialize Visual Studio Experimental Instance
|
||||||
&"C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath\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
|
||||||
|
|
||||||
# Updating content of MachineState.json file to disable autoupdate of VSIX extensions
|
# 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}'
|
$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 "C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath\Common7\IDE\Extensions\MachineState.json" -Value $newContent
|
Set-Content -Path "$VSInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent
|
||||||
|
|
||||||
|
|
||||||
# Adding description of the software to Markdown
|
# Adding description of the software to Markdown
|
||||||
@@ -190,7 +133,7 @@ $SoftwareName = "Visual Studio 2019 Enterprise"
|
|||||||
|
|
||||||
$Description = @"
|
$Description = @"
|
||||||
_Version:_ $version<br/>
|
_Version:_ $version<br/>
|
||||||
_Location:_ C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath
|
_Location:_ $VSInstallRoot
|
||||||
|
|
||||||
The following workloads and components are installed with Visual Studio 2019:
|
The following workloads and components are installed with Visual Studio 2019:
|
||||||
"@
|
"@
|
||||||
@@ -199,6 +142,3 @@ Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $
|
|||||||
|
|
||||||
# Adding explicitly added Workloads details to markdown by parsing $Workloads
|
# Adding explicitly added Workloads details to markdown by parsing $Workloads
|
||||||
Add-ContentToMarkdown -Content $($WorkLoads.Split('--') | % { if( ($_.Split(" "))[0] -like "add") { "* " +($_.Split(" "))[1] } } )
|
Add-ContentToMarkdown -Content $($WorkLoads.Split('--') | % { if( ($_.Split(" "))[0] -like "add") { "* " +($_.Split(" "))[1] } } )
|
||||||
|
|
||||||
|
|
||||||
exit $exitCode
|
|
||||||
|
|||||||
Reference in New Issue
Block a user