Skip to content

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

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

Merged
merged 16 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions .build.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
param(
[ValidateSet("net451", "netstandard1.6")]
[ValidateSet("net451", "netstandard2.0")]
[string]$Framework = "net451",

[ValidateSet("Debug", "Release", "PSv3Debug", "PSv3Release")]
Expand All @@ -19,7 +19,7 @@ if ($BuildTask -eq "release") {
"net451" = @{
Configuration = @('Release', "PSV3Release")
}
"netstandard1.6" = @{
"netstandard2.0" = @{
Configuration = @('Release')
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@ task createModule {
$itemsToCopyBinaries = @("$solutionDir\Engine\bin\$Configuration\$Framework\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll",
"$solutionDir\Rules\bin\$Configuration\$Framework\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll")

if ($Framework -eq "netstandard1.6") {
if ($Framework -eq "netstandard2.0") {
$destinationDirBinaries = "$destinationDir\coreclr"
}
elseif ($Configuration -match 'PSv3') {
Expand Down
23 changes: 15 additions & 8 deletions Engine/Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@

<PropertyGroup>
<VersionPrefix>1.16.1</VersionPrefix>
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer</AssemblyName>
<PackageId>Engine</PackageId>
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace> <!-- Namespace needs to match Assembly name for ressource binding -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Management.Automation" Version="6.0.0-alpha13" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
<DebugType>portable</DebugType>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<Compile Remove="SafeDirectoryCatalog.cs" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Commands\GetScriptAnalyzerLoggerCommand.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.4.1" />
</ItemGroup>

<ItemGroup>
<Compile Update="Strings.Designer.cs">
<DesignTime>True</DesignTime>
Expand All @@ -49,6 +48,14 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Management.Automation" Version="6.0.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<PackageReference Include="System.Management.Automation" Version="6.0.0-alpha13" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is really about full CLR should we still point at this? Would Microsoft.PowerShell.5.ReferenceAssemblies be better? (or Microsoft.PowerShell.3.ReferenceAssemblies) rather than pointing off to that alpha13 thing?

Copy link
Collaborator Author

@bergmeister bergmeister Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment this PR changes it only for the coreclr but I can look into how to do it for full CLR. I first wanted to rather start with the simpler task but maybe it is better to do both in one go.

</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'PSV3Release' ">
<DefineConstants>$(DefineConstants);PSV3;PSV5</DefineConstants>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Engine/ScriptAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ private List<ExternalRule> GetExternalRule(string[] moduleNames)
{
dynamic description = helpContent[0].Properties["Description"];

if (null != description && null != description.Value && description.Value.GetType().IsArray)
if (description != null && description.Value != null && description.Value.GetType().IsArray)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to highlight why I needed the NuGet package for Microsoft.CSharp, which was included in netstandard1.6 but not netstandard2.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup - I found this as well when I was looking at building against PowerShellStandard.Library

{
desc = description.Value[0].Text;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Exit
```
* PowerShell Core
```powershell
.\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build
.\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build
```
* Build documenatation
```powershell
Expand Down
27 changes: 15 additions & 12 deletions Rules/Rules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

<PropertyGroup>
<VersionPrefix>1.16.1</VersionPrefix>
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules</AssemblyName>
<PackageId>Rules</PackageId>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.6' ">$(PackageTargetFallback)</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netstandard1.6' ">1.0.4</RuntimeFrameworkVersion>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard2.0' ">$(PackageTargetFallback)</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">1.0.4</RuntimeFrameworkVersion>
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace> <!-- Namespace needs to match Assembly name for ressource binding -->
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Engine\Engine.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Management.Automation" Version="6.0.0-alpha13" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>

Expand All @@ -30,14 +26,10 @@
<DebugType>portable</DebugType>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<Compile Remove="UseSingularNouns.cs" />
</ItemGroup>

<ItemGroup>
<Compile Update="Strings.Designer.cs">
<DesignTime>True</DesignTime>
Expand All @@ -53,6 +45,17 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<PackageReference Include="System.Management.Automation" Version="6.0.0-alpha13" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Management.Automation" Version="6.0.2" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="1.0.0-alpha08" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good example to show that the old System.Management.Automation package was self-contained and now we also need its other dependency Microsoft.Management.Infrastructure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this just be Version="1.0.0-alpha* (that's what it is in PowerShell repo)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it is reasonable to always take the latest version of a pre-release package.

<PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
<Compile Remove="UseSingularNouns.cs" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'PSV3Release' ">
<DefineConstants>$(DefineConstants);PSV3;PSV5</DefineConstants>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Utils/ReleaseMaker.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function New-ReleaseBuild
remove-item out/ -recurse -force
.\buildCoreClr.ps1 -Framework net451 -Configuration Release -Build
.\buildCoreClr.ps1 -Framework net451 -Configuration PSV3Release -Build
.\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build
.\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build
.\build.ps1 -BuildDocs
}
finally
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test_script:
}
}
- pwsh: |
if ($env:PowerShellEdition -eq 'PowerShellCore') {
if ($env:PowerShellEdition -eq 'PowerShellCore' -and $PSVersionTable.PSVersion -ge [version]'6.0.2') {
$modulePath = $env:PSModulePath.Split([System.IO.Path]::PathSeparator) | Where-Object { Test-Path $_} | Select-Object -First 1
Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force
$testResultsFile = ".\TestResults.xml"
Expand Down
8 changes: 4 additions & 4 deletions buildCoreClr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
[switch]$Uninstall,
[switch]$Install,

[ValidateSet("net451", "netstandard1.6")]
[string]$Framework = "netstandard1.6",
[ValidateSet("net451", "netstandard2.0")]
[string]$Framework = "netstandard2.0",

[ValidateSet("Debug", "Release", "PSv3Debug", "PSv3Release")]
[string]$Configuration = "Debug"
)

if ($Configuration -match "PSv3" -and $Framework -eq "netstandard1.6")
if ($Configuration -match "PSv3" -and $Framework -eq "netstandard2.0")
{
throw ("{0} configuration is not applicable to {1} framework" -f $Configuration,$Framework)
}
Expand All @@ -32,7 +32,7 @@ $itemsToCopyCommon = @("$solutionDir\Engine\PSScriptAnalyzer.psd1",

$destinationDir = "$solutionDir\out\PSScriptAnalyzer"
$destinationDirBinaries = $destinationDir
if ($Framework -eq "netstandard1.6")
if ($Framework -eq "netstandard2.0")
{
$destinationDirBinaries = "$destinationDir\coreclr"
}
Expand Down
2 changes: 1 addition & 1 deletion tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Invoke-AppVeyorBuild {
.\buildCoreClr.ps1 -Framework net451 -Configuration $BuildConfiguration -Build
}
elseif ($BuildType -eq 'NetStandard') {
.\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build
.\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build
}
.\build.ps1 -BuildDocs
Pop-Location
Expand Down