diff --git a/README.md b/README.md index 849f556c6..31d0e4253 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c #### Requirements -* [.NET Core 2.1.401 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.401) or newer patch release +* [.NET Core 2.1.502 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.502) or newer patch release * [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) * Optionally but recommended for development: [Visual Studio 2017](https://www.visualstudio.com/downloads/) diff --git a/Rules/Strings.Designer.cs b/Rules/Strings.Designer.cs index ba1d61a4d..edb0a29f4 100644 --- a/Rules/Strings.Designer.cs +++ b/Rules/Strings.Designer.cs @@ -602,7 +602,7 @@ internal static string AvoidUsernameAndPasswordParamsError { } /// - /// Looks up a localized string similar to AvoidUsingUserNameAndPassWordParams. + /// Looks up a localized string similar to AvoidUsingUsernameAndPasswordParams. /// internal static string AvoidUsernameAndPasswordParamsName { get { diff --git a/Rules/Strings.resx b/Rules/Strings.resx index d4ebf259c..56cdb1794 100644 --- a/Rules/Strings.resx +++ b/Rules/Strings.resx @@ -484,7 +484,7 @@ Function '{0}' has both Username and Password parameters. Either set the type of the Password parameter to SecureString or replace the Username and Password parameters with a Credential parameter of type PSCredential. If using a Credential parameter in PowerShell 4.0 or earlier, please define a credential transformation attribute after the PSCredential type attribute. - AvoidUsingUserNameAndPassWordParams + AvoidUsingUsernameAndPasswordParams Avoid Invoking Empty Members diff --git a/Rules/UseStandardDSCFunctionsInResource.cs b/Rules/UseStandardDSCFunctionsInResource.cs index b93147bf7..7022da2d4 100644 --- a/Rules/UseStandardDSCFunctionsInResource.cs +++ b/Rules/UseStandardDSCFunctionsInResource.cs @@ -35,7 +35,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName List expectedTargetResourceFunctionNames = new List(new string[] { "Get-TargetResource", "Set-TargetResource", "Test-TargetResource" }); // Retrieve a list of Asts where the function name contains TargetResource - IEnumerable functionDefinitionAsts = (ast.FindAll(dscAst => dscAst is FunctionDefinitionAst && ((dscAst as FunctionDefinitionAst).Name.IndexOf("targetResource", StringComparison.CurrentCultureIgnoreCase) != -1), true)); + IEnumerable functionDefinitionAsts = (ast.FindAll(dscAst => dscAst is FunctionDefinitionAst && ((dscAst as FunctionDefinitionAst).Name.IndexOf("targetResource", StringComparison.OrdinalIgnoreCase) != -1), true)); List targetResourceFunctionNamesInAst = new List(); foreach (FunctionDefinitionAst functionDefinitionAst in functionDefinitionAsts) @@ -46,7 +46,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName foreach (string expectedTargetResourceFunctionName in expectedTargetResourceFunctionNames) { // If the Ast does not contain the expected functions, provide a Rule violation message - if (!targetResourceFunctionNamesInAst.Contains(expectedTargetResourceFunctionName, StringComparer.CurrentCultureIgnoreCase)) + if (!targetResourceFunctionNamesInAst.Contains(expectedTargetResourceFunctionName, StringComparer.OrdinalIgnoreCase)) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInResourceError, expectedTargetResourceFunctionName), ast.Extent, GetName(), DiagnosticSeverity.Error, fileName); diff --git a/global.json b/global.json index 3520291b0..d328f8082 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.401" + "version": "2.1.502" } } diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index cc8e15f81..46fc0736a 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -32,13 +32,33 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json - $dotNetCoreSDKVersion = $globalDotJson.sdk.version - # don't try to run this script on linux - we have to do the negative check because IsLinux will be defined in core, but not windows - if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion)) -and ! $IsLinux ) { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # https://github.com/dotnet/announcements/issues/77 - Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 - .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion - Remove-Item .\dotnet-install.ps1 + $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version + if ($PSVersionTable.PSVersion.Major -gt 4) { + $requiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion + } + else { + # WMF 4 image has old SDK that does not have --list-sdks parameter + $requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($requiredDotNetCoreSDKVersion) + } + if (-not $requiredDotNetCoreSDKVersionPresent) { + Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" + $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol + try { + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + if ($IsLinux -or $isMacOS) { + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh + bash dotnet-install.sh --version $requiredDotNetCoreSDKVersion + [System.Environment]::SetEnvironmentVariable('PATH', "/home/appveyor/.dotnet$([System.IO.Path]::PathSeparator)$PATH") + } + else { + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + .\dotnet-install.ps1 -Version $requiredDotNetCoreSDKVersion + } + } + finally { + [Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol + Remove-Item .\dotnet-install.* + } } }