mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
[Windows] Move Windows features to toolset (#3838)
* move windows features to toolset * Update WindowsFeatures.Tests.ps1 * revert templates
This commit is contained in:
@@ -417,6 +417,7 @@ function Install-AndroidSDKPackages {
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$AndroidSDKRootPath,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[AllowEmptyCollection()]
|
||||
[string[]]$AndroidPackages,
|
||||
[string] $PrefixPackageName
|
||||
)
|
||||
|
||||
@@ -29,6 +29,18 @@ function Invoke-Warmup (
|
||||
}
|
||||
}
|
||||
|
||||
function Fix-ImportPublishProfile (
|
||||
$SdkVersion
|
||||
) {
|
||||
if (Test-IsWin16 -or Test-IsWin19) {
|
||||
# Fix for issue https://github.com/dotnet/sdk/issues/1276. This will be fixed in 3.1.
|
||||
$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
|
||||
}
|
||||
}
|
||||
|
||||
function InstallSDKVersion (
|
||||
$SdkVersion,
|
||||
$Warmup
|
||||
@@ -44,11 +56,7 @@ function InstallSDKVersion (
|
||||
Write-Host "Sdk version $sdkVersion already installed"
|
||||
}
|
||||
|
||||
# Fix for issue 1276. This will be fixed in 3.1.
|
||||
$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
|
||||
Fix-ImportPublishProfile -SdkVersion $SdkVersion
|
||||
|
||||
if ($Warmup) {
|
||||
Invoke-Warmup -SdkVersion $SdkVersion
|
||||
|
||||
@@ -7,7 +7,7 @@ Set-SystemVariable -SystemVariable PGUSER -Value $pgUser
|
||||
Set-SystemVariable -SystemVariable PGPASSWORD -Value $pgPwd
|
||||
|
||||
#Install latest PostgreSQL
|
||||
Choco-Install -PackageName postgresql -ArgumentList "--params", "'/Password:$pgPwd /NoPath'", "--params-global", "--debug", "--verbose"
|
||||
Choco-Install -PackageName postgresql -ArgumentList "--params", "'/Password:$pgPwd /NoPath'", "--params-global"
|
||||
|
||||
#Get Path to pg_ctl.exe
|
||||
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
# Install .NET Framework 3.5 (required by Chocolatey)
|
||||
# Explicitly install all 4.7 sub features to include ASP.Net.
|
||||
# As of 1/16/2019, WinServer 19 lists .Net 4.7 as NET-Framework-45-Features
|
||||
Install-WindowsFeature -Name NET-Framework-Features -IncludeAllSubFeature
|
||||
Install-WindowsFeature -Name NET-Framework-45-Features -IncludeAllSubFeature
|
||||
$windowsFeatures = (Get-ToolsetContent).windowsFeatures
|
||||
|
||||
if (Test-IsWin16) {
|
||||
Install-WindowsFeature -Name BITS -IncludeAllSubFeature
|
||||
Install-WindowsFeature -Name DSC-Service
|
||||
foreach ($feature in $windowsFeatures) {
|
||||
if ($feature.optionalFeature) {
|
||||
Write-Host "Activating Windows Optional Feature '$($feature.name)'..."
|
||||
Enable-WindowsOptionalFeature -Online -FeatureName $feature.name -NoRestart
|
||||
|
||||
$resultSuccess = $?
|
||||
} else {
|
||||
Write-Host "Activating Windows Feature '$($feature.name)'..."
|
||||
$Arguments = @{
|
||||
Name = $feature.name
|
||||
IncludeAllSubFeature = [System.Convert]::ToBoolean($feature.includeAllSubFeatures)
|
||||
IncludeManagementTools = [System.Convert]::ToBoolean($feature.includeManagementTools)
|
||||
}
|
||||
$result = Install-WindowsFeature @Arguments
|
||||
|
||||
$resultSuccess = $result.Success
|
||||
}
|
||||
|
||||
if ($resultSuccess) {
|
||||
Write-Host "Windows Feature '$($feature.name)' was activated successfully"
|
||||
} else {
|
||||
throw "Failed to activate Windows Feature '$($feature.name)'"
|
||||
}
|
||||
}
|
||||
|
||||
# Install FS-iSCSITarget-Server
|
||||
$fsResult = Install-WindowsFeature -Name FS-iSCSITarget-Server -IncludeAllSubFeature -IncludeManagementTools
|
||||
if ( $fsResult.Success ) {
|
||||
Write-Host "FS-iSCSITarget-Server has been successfully installed"
|
||||
} else {
|
||||
Write-Host "Failed to install FS-iSCSITarget-Server"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Install Containers feature"
|
||||
Install-WindowsFeature -Name Containers
|
||||
|
||||
Invoke-PesterTests -TestFile "WindowsFeatures" -TestName "ContainersFeature"
|
||||
@@ -1,33 +1,17 @@
|
||||
Describe "WindowsFeatures" {
|
||||
$windowsFeatures = (Get-ToolsetContent).windowsFeatures
|
||||
$testCases = $windowsFeatures | ForEach-Object { @{ Name = $_.name; OptionalFeature = $_.optionalFeature } }
|
||||
|
||||
$testCases = @(
|
||||
@{ FeatureName = "NET-Framework-Features" }
|
||||
@{ FeatureName = "NET-Framework-45-Features" }
|
||||
@{ FeatureName = "FS-iSCSITarget-Server" }
|
||||
)
|
||||
|
||||
if (Test-isWin16) {
|
||||
$testCases += @{ FeatureName = "BITS" }
|
||||
$testCases += @{ FeatureName = "DSC-Service" }
|
||||
}
|
||||
if (Test-isWin19) {
|
||||
$testCases += @{ FeatureName = "Microsoft-Windows-Subsystem-Linux" }
|
||||
}
|
||||
|
||||
It "Windows Feature <FeatureName> is installed" -TestCases $testCases {
|
||||
(Get-WindowsFeature -Name $FeatureName).InstallState | Should -Be "Installed"
|
||||
}
|
||||
|
||||
if (Test-isWin19) {
|
||||
it "Check WSL is on path" {
|
||||
(Get-Command -Name 'wsl') | Should -BeTrue
|
||||
It "Windows Feature <Name> is installed" -TestCases $testCases {
|
||||
if ($OptionalFeature) {
|
||||
(Get-WindowsOptionalFeature -Online -FeatureName $Name).State | Should -Be "Enabled"
|
||||
} else {
|
||||
(Get-WindowsFeature -Name $Name).InstallState | Should -Be "Installed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "ContainersFeature" {
|
||||
It "Windows containers feature is installed" {
|
||||
(Get-WindowsFeature -Name "Containers").InstallState | Should -Be "Installed"
|
||||
it "Check WSL is on path" -Skip:(-not (Test-IsWin19)) {
|
||||
(Get-Command -Name 'wsl') | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,6 +248,14 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"windowsFeatures": [
|
||||
{ "name": "NET-Framework-Features", "includeAllSubFeatures": true },
|
||||
{ "name": "NET-Framework-45-Features", "includeAllSubFeatures": true },
|
||||
{ "name": "BITS", "includeAllSubFeatures": true },
|
||||
{ "name": "DSC-Service" },
|
||||
{ "name": "FS-iSCSITarget-Server", "includeAllSubFeatures": true, "includeManagementTools": true },
|
||||
{ "name": "Containers" }
|
||||
],
|
||||
"visualStudio": {
|
||||
"version" : "2017",
|
||||
"subversion" : "15",
|
||||
|
||||
@@ -248,6 +248,12 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"windowsFeatures": [
|
||||
{ "name": "NET-Framework-Features", "includeAllSubFeatures": true },
|
||||
{ "name": "NET-Framework-45-Features", "includeAllSubFeatures": true },
|
||||
{ "name": "FS-iSCSITarget-Server", "includeAllSubFeatures": true, "includeManagementTools": true },
|
||||
{ "name": "Containers" }
|
||||
],
|
||||
"visualStudio": {
|
||||
"version" : "2019",
|
||||
"subversion" : "16",
|
||||
|
||||
Reference in New Issue
Block a user