Adding dependency loading mechansim for NetCore

This commit is contained in:
markcowl 2018-09-18 19:52:11 -07:00
Родитель 546bdcf96f
Коммит 43b095e263
8 изменённых файлов: 33 добавлений и 6 удалений

Просмотреть файл

@ -69,9 +69,6 @@ RequiredAssemblies = '.\Microsoft.Azure.PowerShell.Authentication.Abstractions.d
'.\Microsoft.Azure.PowerShell.Websites.dll',
'.\Hyak.Common.dll', '.\Microsoft.ApplicationInsights.dll',
'.\Microsoft.Azure.Common.dll',
'.\Microsoft.IdentityModel.Clients.ActiveDirectory.dll',
'.\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll',
'.\Microsoft.IdentityModel.Tokens.dll',
'.\Microsoft.Rest.ClientRuntime.dll',
'.\Microsoft.Rest.ClientRuntime.Azure.dll',
'.\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll',

Просмотреть файл

@ -36,9 +36,17 @@
<ItemGroup>
<PreLoadAssemblies Include="$(ProjectDir)..\..\..\lib\Newtonsoft.Json.9.dll"/>
<PreLoadAssemblies Include="$(ProjectDir)..\..\..\lib\Newtonsoft.Json.10.dll"/>
<PreLoadAssemblies Include="$(ProjectDir)..\..\..\lib\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"/>
<PreLoadAssemblies Include="$(ProjectDir)..\..\..\lib\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll"/>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<NetCoreAssemblies Include="$(ProjectDir)..\..\..\lib\netcore\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"/>
<NetCoreAssemblies Include="$(ProjectDir)..\..\..\lib\netcore\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll"/>
</ItemGroup>
<ItemGroup>
<StorageDependencies Include="$(ProjectDir)..\..\..\lib\Microsoft.WindowsAzure.Storage.dll"/>
<StorageDependencies Include="$(ProjectDir)..\..\..\lib\Microsoft.WindowsAzure.Storage.DataMovement.dll"/>
</ItemGroup>
@ -81,6 +89,7 @@
<Target Name="CopyFiles" AfterTargets="Build">
<Copy SourceFiles="@(PreLoadAssemblies)" DestinationFolder="$(TargetDir)\PreloadAssemblies" />
<Copy SourceFiles="@(NetCoreAssemblies)" DestinationFolder="$(TargetDir)\NetCoreAssemblies" />
<Copy SourceFiles="@(StorageDependencies)" DestinationFolder="$(TargetDir)" />
</Target>
</Project>

Двоичный файл не отображается.

Двоичные данные
src/lib/Microsoft.IdentityModel.Clients.ActiveDirectory.dll Normal file

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -21,6 +21,25 @@ if($PSEdition -eq 'Desktop' -and (Test-Path $preloadPath))
catch {}
}
$netCorePath = (Join-Path $PSScriptRoot -ChildPath "NetCoreAssemblies")
if($PSEdition -eq 'Core' -and (Test-Path $netCorePath))
{
try
{
$loadedAssemblies = ([System.AppDomain]::CurrentDomain.GetAssemblies() | %{New-Object -TypeName System.Reflection.AssemblyName -ArgumentList $_.FullName} )
Get-ChildItem -Path $netCorePath -Filter "*.dll" | ForEach-Object {
$assemblyName = ([System.Reflection.AssemblyName]::GetAssemblyName($_.FullName))
$matches = ($loadedAssemblies | Where-Object {$_.Name -eq $assemblyName.Name})
if (-not $matches)
{
[System.Reflection.Assembly]::Load([System.IO.File]::ReadAllBytes($_.FullName))
}
}
}
catch {}
}
%IMPORTED-DEPENDENCIES%
if (Test-Path -Path "$PSScriptRoot\StartupScripts")

Просмотреть файл

@ -42,13 +42,15 @@
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.0.4" IncludeAssets="All" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="[10.0.3]" />
</ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Client.ActiveDirectory" Version="3.19.2">
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.1.0-rc.1" IncludeAssets="All" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Client.ActiveDirectory" Version="3.19.2">
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />