Add script for backing up Visual Studio
This commit is contained in:
parent
8e47fae09c
commit
40564d5374
1 changed files with 27 additions and 0 deletions
27
scripts/Windows/Software/VisualStudio/Manage.ps1
Normal file
27
scripts/Windows/Software/VisualStudio/Manage.ps1
Normal file
|
@ -0,0 +1,27 @@
|
|||
Import-Module "KnownFolders";
|
||||
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
||||
$programs32Path = $(Get-KnownFolder "ProgramFilesX86").Path;
|
||||
$vsInstaller = "$programs32Path/Microsoft Visual Studio/Installer/vs_installer.exe";
|
||||
|
||||
[System.Tuple[string, string, string][]]$versions = @(
|
||||
[System.Tuple]::Create("visualstudio2019enterprise", "VisualStudio.16.Release", "Microsoft.VisualStudio.Product.Enterprise"));
|
||||
|
||||
function Get-ConfigPath([Context] $context, [string] $packageName) {
|
||||
return Join-Path $($context.BackupRoot()) $packageName ".vsconfig";
|
||||
}
|
||||
|
||||
function Invoke-BackupVisualStudio([Context] $context) {
|
||||
foreach ($version in $versions) {
|
||||
$configPath = Get-ConfigPath $context $version[0];
|
||||
$null = New-Item -Force -ItemType Directory "$(Split-Path -Parent $configPath)";
|
||||
|
||||
Start-Process -FilePath "$vsInstaller" `
|
||||
-Wait `
|
||||
-ArgumentList @(
|
||||
"export",
|
||||
"--channelId", "$($version[1])",
|
||||
"--productId", "$($version[2])",
|
||||
"--config", "$configPath",
|
||||
"--quiet");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue