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