Skip to content

Commit 7304362

Browse files
authored
Upgrade 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 (#919)
* Upgrade system.automation.management to 6.0.1.1 for netstandard, which required upgrade from netstandard 1.6 to netstandard2.0,which included some breaking changes in netstandard2.0 that required some more nuget packges. * use release version of TypeExtensions instead of pre-release * Update System.Management.Automation from 6.0.1.1 to 6.0.2 * run PowerShell Core tests only if image has at least 6.0.2 as required by the new system.management.automation package. * install pwsh for windows if required instead of skipping tests. Thanks for Ilya for the help to get that working * upgrade to net 461 and use in full clr as well * fix other references to net451 with net461 * Revert "fix other references to net451 with net461" This reverts commit d31a55b. * Revert "upgrade to net 461 and use in full clr as well" This reverts commit 52d8521. * use v3/5 reference assemblies * Make UseIdenticalMandatoryParametersDSC rule compilable for v4 by introducing PSV4Release Remove old csproj files that are not needed any more * fix wmf4 build * Use 1.0.0-alpha* of Microsoft.Management.Infrastructure nuget package (i.e. latest instead of specific)
1 parent 1a8d285 commit 7304362

13 files changed

+106
-390
lines changed

.build.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
param(
2-
[ValidateSet("net451", "netstandard1.6")]
2+
[ValidateSet("net451", "netstandard2.0")]
33
[string]$Framework = "net451",
44

5-
[ValidateSet("Debug", "Release", "PSv3Debug", "PSv3Release")]
5+
[ValidateSet("Debug", "Release", "PSv3Debug", "PSv3Release", "PSv4Release")]
66
[string]$Configuration = "Debug"
77
)
88

@@ -17,9 +17,9 @@ if ($BuildTask -eq "release") {
1717
$buildData = @{
1818
Frameworks = @{
1919
"net451" = @{
20-
Configuration = @('Release', "PSV3Release")
20+
Configuration = @('Release', "PSV3Release", "PSv4Release")
2121
}
22-
"netstandard1.6" = @{
22+
"netstandard2.0" = @{
2323
Configuration = @('Release')
2424
}
2525
}
@@ -145,7 +145,7 @@ task createModule {
145145
$itemsToCopyBinaries = @("$solutionDir\Engine\bin\$Configuration\$Framework\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll",
146146
"$solutionDir\Rules\bin\$Configuration\$Framework\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll")
147147

148-
if ($Framework -eq "netstandard1.6") {
148+
if ($Framework -eq "netstandard2.0") {
149149
$destinationDirBinaries = "$destinationDir\coreclr"
150150
}
151151
elseif ($Configuration -match 'PSv3') {

Engine/Engine.csproj

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,37 @@
22

33
<PropertyGroup>
44
<VersionPrefix>1.16.1</VersionPrefix>
5-
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
5+
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
66
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer</AssemblyName>
77
<PackageId>Engine</PackageId>
88
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace> <!-- Namespace needs to match Assembly name for ressource binding -->
99
</PropertyGroup>
1010

11-
<ItemGroup>
12-
<PackageReference Include="System.Management.Automation" Version="6.0.0-alpha13" />
13-
</ItemGroup>
14-
1511
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
1612
<Reference Include="System.ComponentModel.Composition" />
1713
<Reference Include="System" />
18-
<Reference Include="Microsoft.CSharp" />
1914
</ItemGroup>
2015

2116
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
2217
<DebugType>portable</DebugType>
2318
</PropertyGroup>
2419

25-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
20+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
2621
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
2722
</PropertyGroup>
2823

29-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
24+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
3025
<Compile Remove="SafeDirectoryCatalog.cs" />
3126
</ItemGroup>
3227

3328
<ItemGroup>
3429
<Compile Remove="Commands\GetScriptAnalyzerLoggerCommand.cs" />
3530
</ItemGroup>
3631

32+
<ItemGroup>
33+
<PackageReference Include="Microsoft.CSharp" Version="4.4.1" />
34+
</ItemGroup>
35+
3736
<ItemGroup>
3837
<Compile Update="Strings.Designer.cs">
3938
<DesignTime>True</DesignTime>
@@ -49,8 +48,28 @@
4948
</EmbeddedResource>
5049
</ItemGroup>
5150

51+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
52+
<PackageReference Include="System.Management.Automation" Version="6.0.2" />
53+
</ItemGroup>
54+
55+
<ItemGroup Condition="'$(TargetFramework)' == 'net451' AND '$(Configuration)' == 'PSV3Release' AND '$(Configuration)' != 'PSV4Release'">
56+
<PackageReference Include="Microsoft.PowerShell.3.ReferenceAssemblies" Version="1.0.0" />
57+
</ItemGroup>
58+
59+
<ItemGroup Condition="'$(TargetFramework)' == 'net451' AND '$(Configuration)' == 'PSV4Release'">
60+
<PackageReference Include="Microsoft.PowerShell.4.ReferenceAssemblies" Version="1.0.0" />
61+
</ItemGroup>
62+
63+
<ItemGroup Condition="'$(TargetFramework)' == 'net451' AND '$(Configuration)' != 'PSV3Release'">
64+
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.0.0" />
65+
</ItemGroup>
66+
5267
<PropertyGroup Condition=" '$(Configuration)' == 'PSV3Release' ">
53-
<DefineConstants>$(DefineConstants);PSV3;PSV5</DefineConstants>
68+
<DefineConstants>$(DefineConstants);PSV3</DefineConstants>
69+
</PropertyGroup>
70+
71+
<PropertyGroup Condition=" '$(Configuration)' == 'PSV4Release' ">
72+
<DefineConstants>$(DefineConstants);PSV3;PSV4</DefineConstants>
5473
</PropertyGroup>
5574

5675
</Project>

Engine/PSScriptAnalyzer.psm1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition
1515
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'coreclr'
1616
}
1717
else {
18-
if ($PSVersionTable.PSVersion -lt [Version]'5.0') {
18+
if ($PSVersionTable.PSVersion.Major -eq 3) {
1919
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'PSv3'
2020
}
21+
elseif ($PSVersionTable.PSVersion.Major -eq 4) {
22+
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'PSv4'
23+
}
2124
}
2225

2326
$binaryModulePath = Join-Path -Path $binaryModuleRoot -ChildPath 'Microsoft.Windows.PowerShell.ScriptAnalyzer.dll'

Engine/ScriptAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ private List<ExternalRule> GetExternalRule(string[] moduleNames)
11311131
{
11321132
dynamic description = helpContent[0].Properties["Description"];
11331133

1134-
if (null != description && null != description.Value && description.Value.GetType().IsArray)
1134+
if (description != null && description.Value != null && description.Value.GetType().IsArray)
11351135
{
11361136
desc = description.Value[0].Text;
11371137
}

Engine/ScriptAnalyzerEngine.csproj

Lines changed: 0 additions & 174 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,17 @@ Exit
107107
```powershell
108108
.\buildCoreClr.ps1 -Framework net451 -Configuration Release -Build
109109
```
110-
* Windows PowerShell version 3.0 and 4.0
110+
* Windows PowerShell version 4.0
111+
```powershell
112+
.\buildCoreClr.ps1 -Framework net451 -Configuration PSV4Release -Build
113+
```
114+
* Windows PowerShell version 3.0
111115
```powershell
112116
.\buildCoreClr.ps1 -Framework net451 -Configuration PSV3Release -Build
113117
```
114118
* PowerShell Core
115119
```powershell
116-
.\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build
120+
.\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build
117121
```
118122
* Build documenatation
119123
```powershell

0 commit comments

Comments
 (0)