From bac163a71bdb60285e49158c0dc60ee54099d53e Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 29 Sep 2020 18:13:37 +0300 Subject: [PATCH 01/10] move mms provisioner scripts --- .../Add-SshHostKeys.ps1 | 4 ++ .../Create-Junction.ps1 | 30 ++++++++++++++ .../Remove-AzureRegistrySettings.ps1 | 9 +++++ .../Set-RunnerToolCache.ps1 | 14 +++++++ .../Update-VSConfiguration.ps1 | 4 ++ .../Update-WindowsPath.ps1 | 39 +++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 images/win/afterDeploymentActions/Add-SshHostKeys.ps1 create mode 100644 images/win/afterDeploymentActions/Create-Junction.ps1 create mode 100644 images/win/afterDeploymentActions/Remove-AzureRegistrySettings.ps1 create mode 100644 images/win/afterDeploymentActions/Set-RunnerToolCache.ps1 create mode 100644 images/win/afterDeploymentActions/Update-VSConfiguration.ps1 create mode 100644 images/win/afterDeploymentActions/Update-WindowsPath.ps1 diff --git a/images/win/afterDeploymentActions/Add-SshHostKeys.ps1 b/images/win/afterDeploymentActions/Add-SshHostKeys.ps1 new file mode 100644 index 000000000..2ddeb1310 --- /dev/null +++ b/images/win/afterDeploymentActions/Add-SshHostKeys.ps1 @@ -0,0 +1,4 @@ +# Add well-known SSH host keys to ssh_known_hosts + +ssh-keyscan -t rsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" +ssh-keyscan -t dsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" \ No newline at end of file diff --git a/images/win/afterDeploymentActions/Create-Junction.ps1 b/images/win/afterDeploymentActions/Create-Junction.ps1 new file mode 100644 index 000000000..a41f0f0c5 --- /dev/null +++ b/images/win/afterDeploymentActions/Create-Junction.ps1 @@ -0,0 +1,30 @@ +# Create Rust junction points to cargo and rustup folder +$cargoTarget = "$env:USERPROFILE\.cargo" +if (-not (Test-Path $cargoTarget)) +{ + New-Item -ItemType Junction -Path $cargoTarget -Target "C:\Rust\.cargo" + + if (Test-Path $cargoTarget) + { + Write-Host "Junction created for $cargoTarget <<===>> C:\Rust\.cargo" + } + else + { + Write-Host "Junction was not created for $cargoTarget" + } +} + +$rustupTarget = "$env:USERPROFILE\.rustup" +if (-not (Test-Path $rustupTarget)) +{ + New-Item -ItemType Junction -Path $rustupTarget -Target "C:\Rust\.rustup" + + if (Test-Path $rustupTarget) + { + Write-Host "Junction created for $rustupTarget <<===>> C:\Rust\.rustup" + } + else + { + Write-Host "Junction was not created for $rustupTarget" + } +} \ No newline at end of file diff --git a/images/win/afterDeploymentActions/Remove-AzureRegistrySettings.ps1 b/images/win/afterDeploymentActions/Remove-AzureRegistrySettings.ps1 new file mode 100644 index 000000000..d59f5375f --- /dev/null +++ b/images/win/afterDeploymentActions/Remove-AzureRegistrySettings.ps1 @@ -0,0 +1,9 @@ +# Script to address any current issues with images that could be easily worked around. +$ErrorActionPreference="Stop" + +# Remove 3 registry settings that are left behind when sysprepping. Having those registry settings together with a +# race condition that kicks in when trying to run custom scripts extensions and stops us from reimaging machines. +# ICM: https://portal.microsofticm.com/imp/v3/incidents/details/191973270/home +Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'Incarnation' -Force -ErrorAction Ignore +Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'InVmSvdSeqNo' -Force -ErrorAction Ignore +Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'LastGoalStateMethod' -Force -ErrorAction Ignore diff --git a/images/win/afterDeploymentActions/Set-RunnerToolCache.ps1 b/images/win/afterDeploymentActions/Set-RunnerToolCache.ps1 new file mode 100644 index 000000000..3f11343ce --- /dev/null +++ b/images/win/afterDeploymentActions/Set-RunnerToolCache.ps1 @@ -0,0 +1,14 @@ +if ([string]::IsNullOrEmpty($env:RUNNER_TOOL_CACHE)) +{ + $env:RUNNER_TOOL_CACHE=$env:AGENT_TOOLSDIRECTORY + [System.Environment]::SetEnvironmentVariable('RUNNER_TOOL_CACHE', $env:AGENT_TOOLSDIRECTORY, [System.EnvironmentVariableTarget]::Machine) + Write-Host "RUNNER_TOOL_CACHE set to match AGENT_TOOLSDIRECTORY: $env:RUNNER_TOOL_CACHE" + + [System.Environment]::SetEnvironmentVariable('AGENT_TOOLSDIRECTORY', $null, [System.EnvironmentVariableTarget]::Machine) + $isAgentToolsDirectoryNotThere = [string]::IsNullOrEmpty($env:RUNNER_TOOL_CACHE) + Write-Host "AGENT_TOOLSDIRECTORY deleted: $isAgentToolsDirectoryNotThere" +} +else +{ + Write-Host "RUNNER_TOOL_CACHE non-empty: $env:RUNNER_TOOL_CACHE" +} diff --git a/images/win/afterDeploymentActions/Update-VSConfiguration.ps1 b/images/win/afterDeploymentActions/Update-VSConfiguration.ps1 new file mode 100644 index 000000000..0ff9d7bfb --- /dev/null +++ b/images/win/afterDeploymentActions/Update-VSConfiguration.ps1 @@ -0,0 +1,4 @@ +$vsInstallRoot = Get-VisualStudioPath +$devEnvPath = "$vsInstallRoot\Common7\IDE\devenv.exe" + +cmd.exe /c "`"$devEnvPath`" /updateconfiguration" \ No newline at end of file diff --git a/images/win/afterDeploymentActions/Update-WindowsPath.ps1 b/images/win/afterDeploymentActions/Update-WindowsPath.ps1 new file mode 100644 index 000000000..ef84a6e25 --- /dev/null +++ b/images/win/afterDeploymentActions/Update-WindowsPath.ps1 @@ -0,0 +1,39 @@ +$isPathUpdated = $false +$hgPath = "$Env:ProgramFiles\Mercurial\" +$latestPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) + +if (Test-Path -Path $hgPath) +{ + $latestPath = "$hgPath;$latestPath" + Write-Host "Added Mercurial to PATH" + $isPathUpdated = $true +} +else +{ + Write-Host "Didn't find Mercurial at $hgPath. Skipping adding PATH to it." +} + +$dotnetPath = "$env:USERPROFILE\.dotnet\tools" +if ($latestPath.Contains("C:\Users\VssAdministrator\.dotnet\tools")) +{ + $latestPath = $latestPath.Replace("C:\Users\VssAdministrator\.dotnet\tools", "$dotnetPath") + $isPathUpdated = $true +} + +if (-not $latestPath.Contains($dotnetPath)) +{ + $latestPath = "$dotnetPath;$latestPath" + Write-Host "Added .dotnet\tools $dotnetPath to PATH" + $isPathUpdated = $true +} +else +{ + Write-Host "$dotnetPath already in PATH" +} + +if ($isPathUpdated) +{ + [System.Environment]::SetEnvironmentVariable('PATH', $latestPath, [System.EnvironmentVariableTarget]::Machine) +} +$updatedPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) +Write-Host "Windows PATH: $updatedPath" \ No newline at end of file From 94c7463a7f6af79d630ac981ce7e7ba318e9b0ef Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 29 Sep 2020 18:16:37 +0300 Subject: [PATCH 02/10] rename folder --- .../Add-SshHostKeys.ps1 | 0 .../Create-Junction.ps1 | 0 .../Remove-AzureRegistrySettings.ps1 | 0 .../Set-RunnerToolCache.ps1 | 0 .../Update-VSConfiguration.ps1 | 0 .../Update-WindowsPath.ps1 | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename images/win/{afterDeploymentActions => post-generation}/Add-SshHostKeys.ps1 (100%) rename images/win/{afterDeploymentActions => post-generation}/Create-Junction.ps1 (100%) rename images/win/{afterDeploymentActions => post-generation}/Remove-AzureRegistrySettings.ps1 (100%) rename images/win/{afterDeploymentActions => post-generation}/Set-RunnerToolCache.ps1 (100%) rename images/win/{afterDeploymentActions => post-generation}/Update-VSConfiguration.ps1 (100%) rename images/win/{afterDeploymentActions => post-generation}/Update-WindowsPath.ps1 (100%) diff --git a/images/win/afterDeploymentActions/Add-SshHostKeys.ps1 b/images/win/post-generation/Add-SshHostKeys.ps1 similarity index 100% rename from images/win/afterDeploymentActions/Add-SshHostKeys.ps1 rename to images/win/post-generation/Add-SshHostKeys.ps1 diff --git a/images/win/afterDeploymentActions/Create-Junction.ps1 b/images/win/post-generation/Create-Junction.ps1 similarity index 100% rename from images/win/afterDeploymentActions/Create-Junction.ps1 rename to images/win/post-generation/Create-Junction.ps1 diff --git a/images/win/afterDeploymentActions/Remove-AzureRegistrySettings.ps1 b/images/win/post-generation/Remove-AzureRegistrySettings.ps1 similarity index 100% rename from images/win/afterDeploymentActions/Remove-AzureRegistrySettings.ps1 rename to images/win/post-generation/Remove-AzureRegistrySettings.ps1 diff --git a/images/win/afterDeploymentActions/Set-RunnerToolCache.ps1 b/images/win/post-generation/Set-RunnerToolCache.ps1 similarity index 100% rename from images/win/afterDeploymentActions/Set-RunnerToolCache.ps1 rename to images/win/post-generation/Set-RunnerToolCache.ps1 diff --git a/images/win/afterDeploymentActions/Update-VSConfiguration.ps1 b/images/win/post-generation/Update-VSConfiguration.ps1 similarity index 100% rename from images/win/afterDeploymentActions/Update-VSConfiguration.ps1 rename to images/win/post-generation/Update-VSConfiguration.ps1 diff --git a/images/win/afterDeploymentActions/Update-WindowsPath.ps1 b/images/win/post-generation/Update-WindowsPath.ps1 similarity index 100% rename from images/win/afterDeploymentActions/Update-WindowsPath.ps1 rename to images/win/post-generation/Update-WindowsPath.ps1 From 85b60d074cd4e7106ea37b6de7b00b5d3ac3a3be Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Wed, 30 Sep 2020 12:34:36 +0300 Subject: [PATCH 03/10] resolve comments --- .../win/post-generation/Add-SshHostKeys.ps1 | 2 +- .../win/post-generation/Create-Junction.ps1 | 30 ------------------- .../post-generation/Create-RustJunction.ps1 | 12 ++++++++ .../Remove-AzureRegistrySettings.ps1 | 4 +-- .../post-generation/Set-RunnerToolCache.ps1 | 14 --------- ...-WindowsPath.ps1 => Update-DotnetPath.ps1} | 17 ----------- .../post-generation/Update-MercurialPath.ps1 | 16 ++++++++++ 7 files changed, 30 insertions(+), 65 deletions(-) delete mode 100644 images/win/post-generation/Create-Junction.ps1 create mode 100644 images/win/post-generation/Create-RustJunction.ps1 delete mode 100644 images/win/post-generation/Set-RunnerToolCache.ps1 rename images/win/post-generation/{Update-WindowsPath.ps1 => Update-DotnetPath.ps1} (61%) create mode 100644 images/win/post-generation/Update-MercurialPath.ps1 diff --git a/images/win/post-generation/Add-SshHostKeys.ps1 b/images/win/post-generation/Add-SshHostKeys.ps1 index 2ddeb1310..114a98d6a 100644 --- a/images/win/post-generation/Add-SshHostKeys.ps1 +++ b/images/win/post-generation/Add-SshHostKeys.ps1 @@ -1,4 +1,4 @@ # Add well-known SSH host keys to ssh_known_hosts ssh-keyscan -t rsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" -ssh-keyscan -t dsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" \ No newline at end of file +ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" \ No newline at end of file diff --git a/images/win/post-generation/Create-Junction.ps1 b/images/win/post-generation/Create-Junction.ps1 deleted file mode 100644 index a41f0f0c5..000000000 --- a/images/win/post-generation/Create-Junction.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -# Create Rust junction points to cargo and rustup folder -$cargoTarget = "$env:USERPROFILE\.cargo" -if (-not (Test-Path $cargoTarget)) -{ - New-Item -ItemType Junction -Path $cargoTarget -Target "C:\Rust\.cargo" - - if (Test-Path $cargoTarget) - { - Write-Host "Junction created for $cargoTarget <<===>> C:\Rust\.cargo" - } - else - { - Write-Host "Junction was not created for $cargoTarget" - } -} - -$rustupTarget = "$env:USERPROFILE\.rustup" -if (-not (Test-Path $rustupTarget)) -{ - New-Item -ItemType Junction -Path $rustupTarget -Target "C:\Rust\.rustup" - - if (Test-Path $rustupTarget) - { - Write-Host "Junction created for $rustupTarget <<===>> C:\Rust\.rustup" - } - else - { - Write-Host "Junction was not created for $rustupTarget" - } -} \ No newline at end of file diff --git a/images/win/post-generation/Create-RustJunction.ps1 b/images/win/post-generation/Create-RustJunction.ps1 new file mode 100644 index 000000000..86f3fc106 --- /dev/null +++ b/images/win/post-generation/Create-RustJunction.ps1 @@ -0,0 +1,12 @@ +# Create Rust junction points to cargo and rustup folder +$cargoTarget = "$env:USERPROFILE\.cargo" +if (-not (Test-Path $cargoTarget)) +{ + New-Item -ItemType Junction -Path $cargoTarget -Target "C:\Rust\.cargo" +} + +$rustupTarget = "$env:USERPROFILE\.rustup" +if (-not (Test-Path $rustupTarget)) +{ + New-Item -ItemType Junction -Path $rustupTarget -Target "C:\Rust\.rustup" +} \ No newline at end of file diff --git a/images/win/post-generation/Remove-AzureRegistrySettings.ps1 b/images/win/post-generation/Remove-AzureRegistrySettings.ps1 index d59f5375f..e3a62d372 100644 --- a/images/win/post-generation/Remove-AzureRegistrySettings.ps1 +++ b/images/win/post-generation/Remove-AzureRegistrySettings.ps1 @@ -1,9 +1,7 @@ -# Script to address any current issues with images that could be easily worked around. $ErrorActionPreference="Stop" -# Remove 3 registry settings that are left behind when sysprepping. Having those registry settings together with a +# Remove 3 registry settings that are left behind when sysprepping. Having those registry settings together with a # race condition that kicks in when trying to run custom scripts extensions and stops us from reimaging machines. -# ICM: https://portal.microsofticm.com/imp/v3/incidents/details/191973270/home Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'Incarnation' -Force -ErrorAction Ignore Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'InVmSvdSeqNo' -Force -ErrorAction Ignore Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'LastGoalStateMethod' -Force -ErrorAction Ignore diff --git a/images/win/post-generation/Set-RunnerToolCache.ps1 b/images/win/post-generation/Set-RunnerToolCache.ps1 deleted file mode 100644 index 3f11343ce..000000000 --- a/images/win/post-generation/Set-RunnerToolCache.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -if ([string]::IsNullOrEmpty($env:RUNNER_TOOL_CACHE)) -{ - $env:RUNNER_TOOL_CACHE=$env:AGENT_TOOLSDIRECTORY - [System.Environment]::SetEnvironmentVariable('RUNNER_TOOL_CACHE', $env:AGENT_TOOLSDIRECTORY, [System.EnvironmentVariableTarget]::Machine) - Write-Host "RUNNER_TOOL_CACHE set to match AGENT_TOOLSDIRECTORY: $env:RUNNER_TOOL_CACHE" - - [System.Environment]::SetEnvironmentVariable('AGENT_TOOLSDIRECTORY', $null, [System.EnvironmentVariableTarget]::Machine) - $isAgentToolsDirectoryNotThere = [string]::IsNullOrEmpty($env:RUNNER_TOOL_CACHE) - Write-Host "AGENT_TOOLSDIRECTORY deleted: $isAgentToolsDirectoryNotThere" -} -else -{ - Write-Host "RUNNER_TOOL_CACHE non-empty: $env:RUNNER_TOOL_CACHE" -} diff --git a/images/win/post-generation/Update-WindowsPath.ps1 b/images/win/post-generation/Update-DotnetPath.ps1 similarity index 61% rename from images/win/post-generation/Update-WindowsPath.ps1 rename to images/win/post-generation/Update-DotnetPath.ps1 index ef84a6e25..c051ebd4a 100644 --- a/images/win/post-generation/Update-WindowsPath.ps1 +++ b/images/win/post-generation/Update-DotnetPath.ps1 @@ -1,18 +1,5 @@ -$isPathUpdated = $false -$hgPath = "$Env:ProgramFiles\Mercurial\" $latestPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) -if (Test-Path -Path $hgPath) -{ - $latestPath = "$hgPath;$latestPath" - Write-Host "Added Mercurial to PATH" - $isPathUpdated = $true -} -else -{ - Write-Host "Didn't find Mercurial at $hgPath. Skipping adding PATH to it." -} - $dotnetPath = "$env:USERPROFILE\.dotnet\tools" if ($latestPath.Contains("C:\Users\VssAdministrator\.dotnet\tools")) { @@ -31,9 +18,5 @@ else Write-Host "$dotnetPath already in PATH" } -if ($isPathUpdated) -{ - [System.Environment]::SetEnvironmentVariable('PATH', $latestPath, [System.EnvironmentVariableTarget]::Machine) -} $updatedPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) Write-Host "Windows PATH: $updatedPath" \ No newline at end of file diff --git a/images/win/post-generation/Update-MercurialPath.ps1 b/images/win/post-generation/Update-MercurialPath.ps1 new file mode 100644 index 000000000..de68e1812 --- /dev/null +++ b/images/win/post-generation/Update-MercurialPath.ps1 @@ -0,0 +1,16 @@ +$hgPath = "$Env:ProgramFiles\Mercurial\" +$latestPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) + +if (Test-Path -Path $hgPath) +{ + $latestPath = "$hgPath;$latestPath" + Write-Host "Added Mercurial to PATH" + $isPathUpdated = $true +} +else +{ + Write-Host "Didn't find Mercurial at $hgPath. Skipping adding PATH to it." +} + +$updatedPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) +Write-Host "Windows PATH: $updatedPath" \ No newline at end of file From 56633cec4a6ad6c1eb0e4755e8d47b7c4eda31b2 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Wed, 30 Sep 2020 20:13:40 +0300 Subject: [PATCH 04/10] refactor and rename scripts --- ...trySettings.ps1 => AzureRegistrySettings.ps1} | 0 .../{Update-DotnetPath.ps1 => DotnetPath.ps1} | 12 +----------- images/win/post-generation/MercurialPath.ps1 | 8 ++++++++ ...{Create-RustJunction.ps1 => RustJunction.ps1} | 0 .../{Add-SshHostKeys.ps1 => SshHostKeys.ps1} | 0 .../win/post-generation/Update-MercurialPath.ps1 | 16 ---------------- ...e-VSConfiguration.ps1 => VSConfiguration.ps1} | 0 7 files changed, 9 insertions(+), 27 deletions(-) rename images/win/post-generation/{Remove-AzureRegistrySettings.ps1 => AzureRegistrySettings.ps1} (100%) rename images/win/post-generation/{Update-DotnetPath.ps1 => DotnetPath.ps1} (55%) create mode 100644 images/win/post-generation/MercurialPath.ps1 rename images/win/post-generation/{Create-RustJunction.ps1 => RustJunction.ps1} (100%) rename images/win/post-generation/{Add-SshHostKeys.ps1 => SshHostKeys.ps1} (100%) delete mode 100644 images/win/post-generation/Update-MercurialPath.ps1 rename images/win/post-generation/{Update-VSConfiguration.ps1 => VSConfiguration.ps1} (100%) diff --git a/images/win/post-generation/Remove-AzureRegistrySettings.ps1 b/images/win/post-generation/AzureRegistrySettings.ps1 similarity index 100% rename from images/win/post-generation/Remove-AzureRegistrySettings.ps1 rename to images/win/post-generation/AzureRegistrySettings.ps1 diff --git a/images/win/post-generation/Update-DotnetPath.ps1 b/images/win/post-generation/DotnetPath.ps1 similarity index 55% rename from images/win/post-generation/Update-DotnetPath.ps1 rename to images/win/post-generation/DotnetPath.ps1 index c051ebd4a..ea5a2de5a 100644 --- a/images/win/post-generation/Update-DotnetPath.ps1 +++ b/images/win/post-generation/DotnetPath.ps1 @@ -4,19 +4,9 @@ $dotnetPath = "$env:USERPROFILE\.dotnet\tools" if ($latestPath.Contains("C:\Users\VssAdministrator\.dotnet\tools")) { $latestPath = $latestPath.Replace("C:\Users\VssAdministrator\.dotnet\tools", "$dotnetPath") - $isPathUpdated = $true } if (-not $latestPath.Contains($dotnetPath)) { $latestPath = "$dotnetPath;$latestPath" - Write-Host "Added .dotnet\tools $dotnetPath to PATH" - $isPathUpdated = $true -} -else -{ - Write-Host "$dotnetPath already in PATH" -} - -$updatedPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) -Write-Host "Windows PATH: $updatedPath" \ No newline at end of file +} \ No newline at end of file diff --git a/images/win/post-generation/MercurialPath.ps1 b/images/win/post-generation/MercurialPath.ps1 new file mode 100644 index 000000000..7847d7142 --- /dev/null +++ b/images/win/post-generation/MercurialPath.ps1 @@ -0,0 +1,8 @@ +$hgPath = "$Env:ProgramFiles\Mercurial\" +$latestPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) + +if (Test-Path -Path $hgPath) +{ + $latestPath = "$hgPath;$latestPath" + Write-Host "Added Mercurial to PATH" +} diff --git a/images/win/post-generation/Create-RustJunction.ps1 b/images/win/post-generation/RustJunction.ps1 similarity index 100% rename from images/win/post-generation/Create-RustJunction.ps1 rename to images/win/post-generation/RustJunction.ps1 diff --git a/images/win/post-generation/Add-SshHostKeys.ps1 b/images/win/post-generation/SshHostKeys.ps1 similarity index 100% rename from images/win/post-generation/Add-SshHostKeys.ps1 rename to images/win/post-generation/SshHostKeys.ps1 diff --git a/images/win/post-generation/Update-MercurialPath.ps1 b/images/win/post-generation/Update-MercurialPath.ps1 deleted file mode 100644 index de68e1812..000000000 --- a/images/win/post-generation/Update-MercurialPath.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -$hgPath = "$Env:ProgramFiles\Mercurial\" -$latestPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) - -if (Test-Path -Path $hgPath) -{ - $latestPath = "$hgPath;$latestPath" - Write-Host "Added Mercurial to PATH" - $isPathUpdated = $true -} -else -{ - Write-Host "Didn't find Mercurial at $hgPath. Skipping adding PATH to it." -} - -$updatedPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) -Write-Host "Windows PATH: $updatedPath" \ No newline at end of file diff --git a/images/win/post-generation/Update-VSConfiguration.ps1 b/images/win/post-generation/VSConfiguration.ps1 similarity index 100% rename from images/win/post-generation/Update-VSConfiguration.ps1 rename to images/win/post-generation/VSConfiguration.ps1 From 91ee0cc2682fcc58b746667164239c906c9293a7 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Thu, 1 Oct 2020 10:48:50 +0300 Subject: [PATCH 05/10] rename and remove scripts --- images/win/post-generation/AzureRegistrySettings.ps1 | 7 ------- images/win/post-generation/{DotnetPath.ps1 => Dotnet.ps1} | 0 images/win/post-generation/MercurialPath.ps1 | 8 -------- 3 files changed, 15 deletions(-) delete mode 100644 images/win/post-generation/AzureRegistrySettings.ps1 rename images/win/post-generation/{DotnetPath.ps1 => Dotnet.ps1} (100%) delete mode 100644 images/win/post-generation/MercurialPath.ps1 diff --git a/images/win/post-generation/AzureRegistrySettings.ps1 b/images/win/post-generation/AzureRegistrySettings.ps1 deleted file mode 100644 index e3a62d372..000000000 --- a/images/win/post-generation/AzureRegistrySettings.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -$ErrorActionPreference="Stop" - -# Remove 3 registry settings that are left behind when sysprepping. Having those registry settings together with a -# race condition that kicks in when trying to run custom scripts extensions and stops us from reimaging machines. -Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'Incarnation' -Force -ErrorAction Ignore -Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'InVmSvdSeqNo' -Force -ErrorAction Ignore -Remove-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Azure\HandlerState' -Name 'LastGoalStateMethod' -Force -ErrorAction Ignore diff --git a/images/win/post-generation/DotnetPath.ps1 b/images/win/post-generation/Dotnet.ps1 similarity index 100% rename from images/win/post-generation/DotnetPath.ps1 rename to images/win/post-generation/Dotnet.ps1 diff --git a/images/win/post-generation/MercurialPath.ps1 b/images/win/post-generation/MercurialPath.ps1 deleted file mode 100644 index 7847d7142..000000000 --- a/images/win/post-generation/MercurialPath.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -$hgPath = "$Env:ProgramFiles\Mercurial\" -$latestPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) - -if (Test-Path -Path $hgPath) -{ - $latestPath = "$hgPath;$latestPath" - Write-Host "Added Mercurial to PATH" -} From c101287fd83cc310e38f6d19d3a9547324882373 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Thu, 1 Oct 2020 11:41:42 +0300 Subject: [PATCH 06/10] rework dotnet script --- images/win/post-generation/Dotnet.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/images/win/post-generation/Dotnet.ps1 b/images/win/post-generation/Dotnet.ps1 index ea5a2de5a..5f38eaec8 100644 --- a/images/win/post-generation/Dotnet.ps1 +++ b/images/win/post-generation/Dotnet.ps1 @@ -1,12 +1,9 @@ $latestPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) - $dotnetPath = "$env:USERPROFILE\.dotnet\tools" -if ($latestPath.Contains("C:\Users\VssAdministrator\.dotnet\tools")) -{ - $latestPath = $latestPath.Replace("C:\Users\VssAdministrator\.dotnet\tools", "$dotnetPath") -} if (-not $latestPath.Contains($dotnetPath)) { $latestPath = "$dotnetPath;$latestPath" -} \ No newline at end of file +} + +[System.Environment]::SetEnvironmentVariable('PATH', $latestPath, [System.EnvironmentVariableTarget]::Machine) \ No newline at end of file From fb82e1197aef8a52f10d3762019f4b46d2213449 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Thu, 1 Oct 2020 11:52:39 +0300 Subject: [PATCH 07/10] add scripts to templates --- images/win/Windows2016-Azure.json | 5 +++++ images/win/Windows2019-Azure.json | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 77d57aef1..4c8111bed 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -82,6 +82,11 @@ "source": "{{ template_dir }}/scripts/SoftwareReport", "destination": "{{user `image_folder`}}" }, + { + "type": "file", + "source": "{{ template_dir }}/post-generation", + "destination": "{{user `image_folder`}}" + }, { "type": "file", "source": "{{ template_dir }}/scripts/Tests", diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 473051dba..fe47bd64e 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -82,6 +82,11 @@ "source": "{{ template_dir }}/scripts/SoftwareReport", "destination": "{{user `image_folder`}}" }, + { + "type": "file", + "source": "{{ template_dir }}/post-generation", + "destination": "{{user `image_folder`}}" + }, { "type": "file", "source": "{{ template_dir }}/scripts/Tests", From 3a2c8bc0b966a5ea6a4c2982118e2acdac9422eb Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Thu, 1 Oct 2020 12:28:33 +0300 Subject: [PATCH 08/10] change destination --- images/win/Windows2016-Azure.json | 2 +- images/win/Windows2019-Azure.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 4c8111bed..a0edde4bc 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -85,7 +85,7 @@ { "type": "file", "source": "{{ template_dir }}/post-generation", - "destination": "{{user `image_folder`}}" + "destination": "C:/post-generation" }, { "type": "file", diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index fe47bd64e..6f0759e18 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -85,7 +85,7 @@ { "type": "file", "source": "{{ template_dir }}/post-generation", - "destination": "{{user `image_folder`}}" + "destination": "C:/post-generation" }, { "type": "file", From 29300ce6eb3db1b5071d8c1f51b84c0ab18bbe9e Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Thu, 1 Oct 2020 12:43:21 +0300 Subject: [PATCH 09/10] minor change --- images/win/post-generation/Dotnet.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/images/win/post-generation/Dotnet.ps1 b/images/win/post-generation/Dotnet.ps1 index 5f38eaec8..fd43757a6 100644 --- a/images/win/post-generation/Dotnet.ps1 +++ b/images/win/post-generation/Dotnet.ps1 @@ -4,6 +4,5 @@ $dotnetPath = "$env:USERPROFILE\.dotnet\tools" if (-not $latestPath.Contains($dotnetPath)) { $latestPath = "$dotnetPath;$latestPath" -} - -[System.Environment]::SetEnvironmentVariable('PATH', $latestPath, [System.EnvironmentVariableTarget]::Machine) \ No newline at end of file + [System.Environment]::SetEnvironmentVariable('PATH', $latestPath, [System.EnvironmentVariableTarget]::Machine) +} \ No newline at end of file From ed9705b7fd2ccb8870b8f613910c08d437d29d70 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Thu, 1 Oct 2020 14:53:27 +0300 Subject: [PATCH 10/10] move ssh host key creation to install-git.ps1 --- images/win/post-generation/SshHostKeys.ps1 | 4 ---- images/win/scripts/Installers/Install-Git.ps1 | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 images/win/post-generation/SshHostKeys.ps1 diff --git a/images/win/post-generation/SshHostKeys.ps1 b/images/win/post-generation/SshHostKeys.ps1 deleted file mode 100644 index 114a98d6a..000000000 --- a/images/win/post-generation/SshHostKeys.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -# Add well-known SSH host keys to ssh_known_hosts - -ssh-keyscan -t rsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" -ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Git.ps1 b/images/win/scripts/Installers/Install-Git.ps1 index 2a5ea9259..16b7ac15e 100644 --- a/images/win/scripts/Installers/Install-Git.ps1 +++ b/images/win/scripts/Installers/Install-Git.ps1 @@ -40,5 +40,10 @@ Choco-Install -PackageName hub Add-MachinePathItem "C:\Program Files\Git\bin" +# Add well-known SSH host keys to ssh_known_hosts + +ssh-keyscan -t rsa github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" +ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts" + Invoke-PesterTests -TestFile "Git" -TestName "Git" Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Hub CLI"