[Windows] Move Windows features to toolset (#3838)

* move windows features to toolset

* Update WindowsFeatures.Tests.ps1

* revert templates
This commit is contained in:
Maxim Lobanov
2021-08-03 20:17:31 +03:00
committed by GitHub
parent c960549cb1
commit f93413492e
7 changed files with 60 additions and 51 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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
# 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
}
$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
Write-Host "Install Containers feature"
Install-WindowsFeature -Name Containers
$resultSuccess = $result.Success
}
Invoke-PesterTests -TestFile "WindowsFeatures" -TestName "ContainersFeature"
if ($resultSuccess) {
Write-Host "Windows Feature '$($feature.name)' was activated successfully"
} else {
throw "Failed to activate Windows Feature '$($feature.name)'"
}
}