Permalink
Browse files

Merge WIP -> master (#302)

* Back compat with older builds of PowerShell Core (#300)
  • Loading branch information...
brywang-msft committed Sep 1, 2017
1 parent 025795b commit 283c60931da54c94fbd925c98a1013e49f015af2
@@ -1,8 +1,8 @@
$IsLegacyTestRun = (Get-Variable -Name IsLegacyTestRun -ErrorAction Ignore) -and $global:IsLegacyTestRun
Describe "Legacy tests" -Tags "Legacy" {
It "Blocks import on legacy PowerShell Core" -Skip:((-not $IsLegacyTestRun)) {
It "Can import on legacy PowerShell Core" -Skip:((-not $IsLegacyTestRun)) {
try { Import-Module PackageManagement -RequiredVersion 1.1.6.0 } catch {}
Get-Module PackageManagement | should benullorempty
Get-Module PackageManagement | should not benullorempty
}
}
View
@@ -360,7 +360,7 @@ if ($testframework -eq "coreclr")
Copy-Item "$CoreCLRTestHome\Examples\*.ps1" (Join-Path -Path $packagemanagementfolder -ChildPath "Examples")
# copy the OneGet bits into powershell core
$OneGetBinaryPath ="$packagemanagementfolder\coreclr"
$OneGetBinaryPath ="$packagemanagementfolder\coreclr\netcoreapp2.0"
if(-not (Test-Path -Path $OneGetBinaryPath))
{
New-Item -Path $OneGetBinaryPath -ItemType Directory -Force -Verbose
@@ -371,9 +371,10 @@ if ($testframework -eq "coreclr")
}
Copy-Item "$TestBin\coreclr\*.dll" $OneGetBinaryPath -Force -Verbose
Copy-Item "$TestBin\coreclr\netcoreapp2.0\*.dll" $OneGetBinaryPath -Force -Verbose
if ($powershellLegacyFolder) {
$OneGetBinaryPath ="$packagemanagementfolder\coreclr\netstandard1.6"
$packagemanagementfolder = "$powershellLegacyFolder\Modules\PackageManagement\$PackageManagementVersion\"
Write-Verbose ("OneGet Folder '{0}'" -f $packagemanagementfolder)
@@ -414,7 +415,7 @@ if ($testframework -eq "coreclr")
}
Copy-Item "$TestBin\coreclr\*.dll" $OneGetBinaryPath -Force -Verbose
Copy-Item "$TestBin\coreclr\netstandard1.6\*.dll" $OneGetBinaryPath -Force -Verbose
}
$PSGetPath = "$powershellFolder\Modules\PowerShellGet\$PowerShellGetVersion\"
@@ -434,7 +435,7 @@ if ($testframework -eq "coreclr")
Copy-Item "$($TestHome)\Unit\Providers\PSChained1Provider.psm1" "$($powershellFolder)\Modules" -force -verbose
Copy-Item "$($TestHome)\Unit\Providers\PSOneGetTestProvider" "$($powershellFolder)\Modules" -Recurse -force -verbose
if ($powershellLegacyFolder) {
if ($powershellLegacyFolder -and $script:IsWindows) {
$PSGetPath = "$powershellLegacyFolder\Modules\PowerShellGet\$PowerShellGetVersion\"
Write-Verbose ("Legacy PowerShellGet Folder '{0}'" -f $PSGetPath)
@@ -555,7 +556,7 @@ if ($testframework -eq "coreclr")
throw "$($x.'test-results'.failures) tests failed"
}
}
if ($powershellLegacyFolder) {
if ($powershellLegacyFolder -and $script:IsWindows) {
# Tests on legacy version of PowerShell Core
$command = ""
$command += "Import-Module '$pesterFolder';`$global:IsLegacyTestRun=`$true;"
@@ -564,14 +565,7 @@ if ($testframework -eq "coreclr")
Write-Host "(Legacy) CoreCLR: Calling $powershellLegacyFolder\powershell -command $command"
if($script:IsWindows)
{
& "$powershellLegacyFolder\powershell" -command "& {$command}"
}
else
{
& powershell -command "& {$command}"
}
& "$powershellLegacyFolder\powershell" -command "& {$command}"
$x = [xml](Get-Content -raw $testResultsFile)
if ([int]$x.'test-results'.failures -gt 0)
View
@@ -20,7 +20,7 @@ build_script:
- git submodule update --init
- ps: nuget locals all -clear
- ps: import-module c:\projects\oneget\test\TestUtility.psm1 -force
- ps: cd .\src; .\bootstrap.ps1; .\build.ps1 -framework "net451" Release; .\build.ps1 -framework "netcoreapp2.0" Release
- ps: cd .\src; .\bootstrap.ps1; .\build.ps1 -framework "net451" Release; .\build.ps1 -framework "netcoreapp2.0" Release; .\build.ps1 -framework "netstandard1.6" Release
View
@@ -200,6 +200,7 @@ git submodule update --init
#building OneGet for coreclr
> .\build.ps1 netstandard1.6
> .\build.ps1 netcoreapp2.0
```
If successfully built above, you should be able to see a folder:
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net451;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net451;netcoreapp2.0;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DelaySign>true</DelaySign>
<AssemblyName>Microsoft.PackageManagement.ArchiverProviders</AssemblyName>
<AssemblyOriginatorKeyFile>../signing/35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PackageId>Microsoft.PackageManagement.ArchiverProviders</PackageId>
<RuntimeIdentifiers>win7-x64;win81-x64;win10-x64</RuntimeIdentifiers>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<PackageTargetFallback Condition=" ('$(TargetFramework)' == 'netcoreapp2.0') Or ('$(TargetFramework)' == 'netstandard1.6') ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">2.0.0</NetStandardImplicitPackageVersion>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.6' ">1.6.0</NetStandardImplicitPackageVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -56,7 +57,12 @@
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<DefineConstants>$(DefineConstants);CORECLR;COREv1</DefineConstants>
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup Condition=" ('$(TargetFramework)' == 'netcoreapp2.0') Or ('$(TargetFramework)' == 'netstandard1.6') ">
<Compile Remove="Providers\Inbox\Common\*;Resources\*" />
</ItemGroup>
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net451;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net451;netcoreapp2.0;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DelaySign>true</DelaySign>
<AssemblyName>Microsoft.PackageManagement.CoreProviders</AssemblyName>
<AssemblyOriginatorKeyFile>../signing/35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PackageId>Microsoft.PackageManagement.CoreProviders</PackageId>
<RuntimeIdentifiers>win7-x64;win81-x64;win10-x64</RuntimeIdentifiers>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<PackageTargetFallback Condition=" ('$(TargetFramework)' == 'netcoreapp2.0') Or ('$(TargetFramework)' == 'netstandard1.6') ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">2.0.0</NetStandardImplicitPackageVersion>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.6' ">1.6.0</NetStandardImplicitPackageVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -28,7 +29,7 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="System.Management.Automation" Version="6.0.0-beta.2" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<ItemGroup Condition=" ('$(TargetFramework)' == 'net451') Or ('$(TargetFramework)' == 'netstandard1.6') ">
<PackageReference Include="System.Management.Automation" Version="1.0.0-alpha9" />
</ItemGroup>
@@ -63,7 +64,12 @@
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<DefineConstants>$(DefineConstants);CORECLR;COREv1</DefineConstants>
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup Condition=" ('$(TargetFramework)' == 'netcoreapp2.0') Or ('$(TargetFramework)' == 'netstandard1.6') ">
<Compile Remove="Resources\Messages.Designer.cs;ProgramsProvider.cs" />
<EmbeddedResource Remove="Resources\Messages.resx" />
</ItemGroup>
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net451;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net451;netcoreapp2.0;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DelaySign>true</DelaySign>
<AssemblyName>Microsoft.PackageManagement.MetaProvider.PowerShell</AssemblyName>
<AssemblyOriginatorKeyFile>../signing/35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PackageId>Microsoft.PackageManagement.MetaProvider.PowerShell</PackageId>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<PackageTargetFallback Condition=" ('$(TargetFramework)' == 'netcoreapp2.0') Or ('$(TargetFramework)' == 'netstandard1.6') ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -26,7 +26,7 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="System.Management.Automation" Version="6.0.0-beta.2" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<ItemGroup Condition=" ('$(TargetFramework)' == 'net451') Or ('$(TargetFramework)' == 'netstandard1.6') ">
<PackageReference Include="System.Management.Automation" Version="1.0.0-alpha9" />
</ItemGroup>
@@ -61,7 +61,12 @@
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<DefineConstants>$(DefineConstants);CORECLR;COREv1</DefineConstants>
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup Condition=" ('$(TargetFramework)' == 'netcoreapp2.0') Or ('$(TargetFramework)' == 'netstandard1.6') ">
<Compile Remove="Resources\Messages.Designer.cs" />
<EmbeddedResource Remove="Resources\Messages.resx" />
</ItemGroup>
@@ -179,8 +179,19 @@ public class PowerShellMetaProvider : IDisposable {
if (!File.Exists(_powershellProviderFunctionsPath))
{
// oh-oh, no powershell functions file.
throw new Exception(String.Format(CultureInfo.CurrentCulture, Resources.Messages.UnableToFindPowerShellFunctionsFile, _powershellProviderFunctionsPath));
// For now just try another level - sometimes this is the framework directory (e.g. net451)
// Need to fix the BaseFolder calculation
try
{
_powershellProviderFunctionsPath = Path.Combine(Path.GetDirectoryName(BaseFolder), "..", "PackageProviderFunctions.psm1");
}
catch { }
if (!File.Exists(_powershellProviderFunctionsPath))
{
// oh-oh, no powershell functions file.
throw new Exception(String.Format(CultureInfo.CurrentCulture, Resources.Messages.UnableToFindPowerShellFunctionsFile, _powershellProviderFunctionsPath));
}
}
}
}
@@ -480,6 +491,26 @@ public class PowerShellMetaProvider : IDisposable {
e.Dump(request);
}
}
else if (ps.HadErrors)
{
foreach (var errorMessage in ps.Streams.Error.Select(e => e.ErrorDetails).Select(ed => ed.Message))
{
if (logWarning)
{
request.Warning(errorMessage);
}
}
}
}
else if (ps.HadErrors)
{
foreach (var errorMessage in ps.Streams.Error.Select(e => e.ErrorDetails).Select(ed => ed.Message))
{
if (logWarning)
{
request.Warning(errorMessage);
}
}
}
} catch (Exception e) {
// something didn't go well.
@@ -32,11 +32,6 @@
<EmbeddedResource Remove="Resources\Messages.resx" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Compile Remove="Resources\Messages.Designer.cs" />
<EmbeddedResource Remove="Resources\Messages.resx" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System.Runtime" />
<Reference Include="System.Xml" />
@@ -1303,7 +1303,12 @@ private IMetaProvider GetMetaProviderObject(IHostApi request)
try {
Assembly assembly = null;
// This preprocessor directive is defined in build project (.NET Core csproj)
#if COREv1
assembly = Microsoft.PowerShell.CoreCLR.AssemblyExtensions.LoadFrom(assemblyPath);
#else
assembly = Assembly.LoadFrom(assemblyPath);
#endif
if (assembly == null) {
return false;
Oops, something went wrong.

0 comments on commit 283c609

Please sign in to comment.