-
Notifications
You must be signed in to change notification settings - Fork 40
Cloning an Instance
You can clone the channel and component selection from an instance on one machine to use on another machine.
First create a script file or define a function with the following content:
#Requires -Version 3
#Requires -Module VSSetup
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, Position=0)]
[string] $Path,
[Parameter(Mandatory=$true, Position=1)]
[string] $Destination
)
$instance = Get-VSSetupInstance $Path
if (!$instance) {
throw "No instance found in $Path"
}
$name = $instance.DisplayName
if ($nickname = $instance.Properties['Nickname']) {
$name += " ($nickname)"
}
write-verbose "Copying instance: $name"
$response = @{
channelUri = $instance.ChannelUri
channelId = $instance.ChannelId
productId = $instance.Product.Id
add = $($instance.Packages | where-object { @('Workload', 'Component') -contains $_.Type -and !$_.IsExtension } | select -expand Id)
addProductLang = @('en-US')
}
$languages = $instance.Packages | where-object { $_.Language } | group-object Language -noelement
if ($languages.Count) {
write-verbose 'Overriding default language with installed languages'
$response.addProductLang = $languages | select-object Name -unique
}
# None of this information should contain Unicode characters; need UTF-8 without BOM.
write-verbose "Writing response file to $Destination"
$response | convertto-json | set-content $Destination -encoding ASCII
Run this command with the path to the instance you want to clone and the location of the response file to create:
Copy-VSSetupInstance "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise" $env:TEMP\response.json
You'll use this response file in the following steps.
Warning: cloning selected components this way means that if you later remove workloads or components for the new instance, not all child components may be removed.
To install from the web onto individual machine:
- Download the Visual Studio bootstrapper (any edition will do).
- Copy "$env:TEMP\response.json" ("%TEMP%\response.json") to your target machine, e.g. in its own "$env:TEMP".
- Assuming the downloaded location "~\Downloads\vs_enterprise.exe", run the following on another machine:
~\Downloads\vs_enterprise.exe --in $env:TEMP\response.json
- Choose an install location and make any other selections you want.
- Click Install.
To add or update a response file for a layout:
- Review how to define settings in a response file.
- Modify the "response.json" file to merge the content of "$env:TEMP\response.json" - mainly the
add
JSON property. - Deploy the layout.
Copyright (C) Microsoft Corporation. All rights reserved. Licensed under the MIT license. See LICENSE.txt in the project root for license information.