Fix it for 'dotnet build' scenario

This commit is contained in:
Dongbo Wang 2016-06-28 13:29:17 -07:00 committed by Andrew Schwartzmeyer
parent 66dcd00d93
commit ca28391b38
3 changed files with 28 additions and 4 deletions

View File

@ -189,6 +189,7 @@ namespace System.Management.Automation
if (useResolvingHandlerOnly)
throw new NotSupportedException(UseResolvingEventHandlerOnly);
System.Console.WriteLine("== LC1 == Requesting: {0}", assemblyName.FullName);
return Resolve(this, assemblyName);
}
@ -246,6 +247,7 @@ namespace System.Management.Automation
// In this case, return null so that other Resolving event handlers can kick in to resolve the request.
if (!isAssemblyFileFound || !isAssemblyFileMatching)
{
System.Console.WriteLine(" -- Return null");
return null;
}
@ -256,6 +258,7 @@ namespace System.Management.Automation
{
// Add the loaded assembly to the cache
AssemblyCache.TryAdd(assemblyName.Name, asmLoaded);
System.Console.WriteLine(" ++ Load succeed: {0}", asmLoaded.FullName);
}
}
@ -270,6 +273,7 @@ namespace System.Management.Automation
internal Assembly LoadFrom(string assemblyPath)
{
ValidateAssemblyPath(assemblyPath, "assemblyPath");
System.Console.WriteLine("*** LC1 *** LoadFrom {0}", assemblyPath);
Assembly asmLoaded;
AssemblyName assemblyName = GetAssemblyName(assemblyPath);
@ -300,6 +304,7 @@ namespace System.Management.Automation
{
probingPaths.Add(parentPath);
}
System.Console.WriteLine(" ++ LoadFrom succeed: {0}", asmLoaded.FullName);
}
}
@ -436,10 +441,28 @@ namespace System.Management.Automation
return coreClrTypeCatalog.Keys;
}
/// <summary>
/// Set the profile optimization root on the approprite load context
/// </summary>
internal void SetProfileOptimizationRootImpl(string directoryPath)
{
if (this.useResolvingHandlerOnly)
activeLoadContext.SetProfileOptimizationRoot(directoryPath);
}
/// <summary>
/// Start the profile optimization on the approprite load context
/// </summary>
internal void StartProfileOptimizationImpl(string profile)
{
if (this.useResolvingHandlerOnly)
activeLoadContext.StartProfileOptimization(profile);
}
#endregion Protected_Internal_Methods
#region Private_Methods
/// <summary>
/// Handle the AssemblyLoad event
/// </summary>

View File

@ -661,7 +661,7 @@ namespace System.Management.Automation
internal static void SetProfileOptimizationRoot(string directoryPath)
{
#if CORECLR
System.Runtime.Loader.AssemblyLoadContext.Default.SetProfileOptimizationRoot(directoryPath);
PSAssemblyLoadContext.SetProfileOptimizationRootImpl(directoryPath);
#else
System.Runtime.ProfileOptimization.SetProfileRoot(directoryPath);
#endif
@ -674,7 +674,7 @@ namespace System.Management.Automation
internal static void StartProfileOptimization(string profile)
{
#if CORECLR
System.Runtime.Loader.AssemblyLoadContext.Default.StartProfileOptimization(profile);
PSAssemblyLoadContext.StartProfileOptimizationImpl(profile);
#else
System.Runtime.ProfileOptimization.StartProfile(profile);
#endif

View File

@ -25,6 +25,7 @@ namespace Microsoft.PowerShell
// Open PowerShell has to set the ALC here, since we don't own the native host
string appBase = System.IO.Path.GetDirectoryName(typeof(ManagedPSEntry).GetTypeInfo().Assembly.Location);
Console.WriteLine(" == APPBASE == {0}", appBase);
//Console.Read();
return (int)PowerShellAssemblyLoadContextInitializer.
InitializeAndCallEntryMethod(
appBase,