Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install dotnet sdk if missing on Unix as well to fix failing Ubuntu build due to image update and Pester/PowerShell bug #1107

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7c6de95
add unix support for installing the .net core sdk on-demand
bergmeister Nov 26, 2018
2db348d
add logging
bergmeister Nov 26, 2018
2cdb89b
update sdk
bergmeister Nov 26, 2018
80c9beb
adapt for dotnet writing to stderr
bergmeister Nov 26, 2018
45de0e0
fix parenthesis
bergmeister Nov 26, 2018
bf50f1d
only set protocol if needed and set erroraction to avoid ci failur
bergmeister Nov 26, 2018
574927c
try fix nullreferenceexception
bergmeister Nov 26, 2018
a282dfe
use use --list-sdks
bergmeister Nov 26, 2018
c0c1b18
use 2.1.403 sdk, which is at least available on Windows
bergmeister Nov 29, 2018
81d80f5
use erroractionpreference
bergmeister Nov 29, 2018
d6e01f0
redirect error
bergmeister Nov 29, 2018
2d7bee3
use continue
bergmeister Nov 29, 2018
0ba6a41
use 2.1.400 that is available on both windows and linux and revert ot…
bergmeister Nov 29, 2018
f33f66c
remove if check that could break wmf4?
bergmeister Nov 29, 2018
b8cd894
use --list-sdks
bergmeister Nov 29, 2018
330408a
try different syntax to get wmf4 to work
bergmeister Nov 29, 2018
4bb85e2
disable wmf4 for the moment
bergmeister Nov 29, 2018
d4e0436
use 2.1.403 and re-enable wmf4
bergmeister Nov 29, 2018
bd2648a
fix typo (wmf4)
bergmeister Nov 29, 2018
0172c98
use .net core sdk 2.1.502
bergmeister Dec 15, 2018
4838d45
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister Dec 20, 2018
8c48e93
ignore 5 pester failure on Ubuntu for AppVeyor due Pester/PowerShell …
bergmeister Dec 20, 2018
61c4d59
Fix typo
bergmeister Dec 20, 2018
064683f
add more skip statements for failing appveyor tests
bergmeister Dec 20, 2018
6b17c2b
Revert "add more skip statements for failing appveyor tests"
bergmeister Dec 29, 2018
5789ea1
Revert "Fix typo"
bergmeister Dec 29, 2018
f4e4441
Revert "ignore 5 pester failure on Ubuntu for AppVeyor due Pester/Pow…
bergmeister Dec 29, 2018
ee79467
set locale
bergmeister Dec 29, 2018
aded0ea
empty
bergmeister Jan 3, 2019
91765b0
Revert "set locale"
bergmeister Jan 3, 2019
7db40c3
simplify dotnet check
bergmeister Jan 3, 2019
e57a0b2
output debug details and disable other images
bergmeister Jan 3, 2019
84963f6
output rule names
bergmeister Jan 3, 2019
884206a
output more
bergmeister Jan 3, 2019
ae66e81
add more and downgrade sdk
bergmeister Jan 3, 2019
b9227b6
use 2.1.403 sdk
bergmeister Jan 3, 2019
a72cb1a
2.1.401 sdk
bergmeister Jan 3, 2019
8206306
2.1.400 sdk
bergmeister Jan 3, 2019
81428c2
Revert "simplify dotnet check"
bergmeister Jan 3, 2019
4fce77b
2.1.401
bergmeister Jan 3, 2019
20fcc7a
2.1.403
bergmeister Jan 3, 2019
2040651
2.1.502
bergmeister Jan 3, 2019
9794bfa
fix resource string casing of AvoidUsingUsernameAndPassWordParams to …
bergmeister Jan 3, 2019
ce8a531
another resource string casing optimisation
bergmeister Jan 3, 2019
9416432
use OrdinalIgnoreCase to be really case insensitive
bergmeister Jan 3, 2019
f5c5b7d
cleanup
bergmeister Jan 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
2 changes: 1 addition & 1 deletion Rules/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Rules/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
<value>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.</value>
</data>
<data name="AvoidUsernameAndPasswordParamsName" xml:space="preserve">
<value>AvoidUsingUserNameAndPassWordParams</value>
<value>AvoidUsingUsernameAndPasswordParams</value>
</data>
<data name="AvoidInvokingEmptyMembersCommonName" xml:space="preserve">
<value>Avoid Invoking Empty Members</value>
Expand Down
4 changes: 2 additions & 2 deletions Rules/UseStandardDSCFunctionsInResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
List<string> expectedTargetResourceFunctionNames = new List<string>(new string[] { "Get-TargetResource", "Set-TargetResource", "Test-TargetResource" });

// Retrieve a list of Asts where the function name contains TargetResource
IEnumerable<Ast> functionDefinitionAsts = (ast.FindAll(dscAst => dscAst is FunctionDefinitionAst && ((dscAst as FunctionDefinitionAst).Name.IndexOf("targetResource", StringComparison.CurrentCultureIgnoreCase) != -1), true));
IEnumerable<Ast> functionDefinitionAsts = (ast.FindAll(dscAst => dscAst is FunctionDefinitionAst && ((dscAst as FunctionDefinitionAst).Name.IndexOf("targetResource", StringComparison.OrdinalIgnoreCase) != -1), true));

List<string> targetResourceFunctionNamesInAst = new List<string>();
foreach (FunctionDefinitionAst functionDefinitionAst in functionDefinitionAsts)
Expand All @@ -46,7 +46,7 @@ public IEnumerable<DiagnosticRecord> 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);
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.401"
"version": "2.1.502"
}
}
34 changes: 27 additions & 7 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
}
}
}

Expand Down