Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions src/Build/Utilities/NuGetFrameworkWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ public NuGetFrameworkWrapper()
BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory;
try
{
#if FEATURE_ASSEMBLYLOADCONTEXT
var NuGetAssembly = Assembly.LoadFrom(Path.Combine(assemblyDirectory, "NuGet.Frameworks.dll"));
#else
var NuGetAssembly = Assembly.LoadFile(Path.Combine(assemblyDirectory, "NuGet.Frameworks.dll"));
#endif
var NuGetFramework = NuGetAssembly.GetType("NuGet.Frameworks.NuGetFramework");
var NuGetFrameworkCompatibilityProvider = NuGetAssembly.GetType("NuGet.Frameworks.CompatibilityProvider");
var NuGetFrameworkDefaultCompatibilityProvider = NuGetAssembly.GetType("NuGet.Frameworks.DefaultCompatibilityProvider");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,4 @@
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

<Target Name="CreateTaskDir" AfterTargets="Build" Condition="'$(TargetFrameworkIdentifier)' != ''">
<ItemGroup>
<OutputAssemblyList Include="$(TargetDir)Microsoft.Build.CommandLine.UnitTests.dll" />
</ItemGroup>
<Copy SourceFiles="@(OutputAssemblyList)" DestinationFolder="$(TargetDir)Task" />
</Target>
</Project>
9 changes: 3 additions & 6 deletions src/MSBuild.UnitTests/XMake_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2383,8 +2383,7 @@ public void EndToEndWarnAsErrors()

#if FEATURE_ASSEMBLYLOADCONTEXT
/// <summary>
/// Ensure that tasks get loaded into their own <see cref="System.Runtime.Loader.AssemblyLoadContext"/>
/// if they are in a directory other than the MSBuild directory.
/// Ensure that tasks get loaded into their own <see cref="System.Runtime.Loader.AssemblyLoadContext"/>.
/// </summary>
/// <remarks>
/// When loading a task from a test assembly in a test within that assembly, the assembly is already loaded
Expand All @@ -2394,10 +2393,7 @@ public void EndToEndWarnAsErrors()
[Fact]
public void TasksGetAssemblyLoadContexts()
{
string customTaskPath = Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Task",
Path.GetFileName(Assembly.GetExecutingAssembly().Location));
string customTaskPath = Assembly.GetExecutingAssembly().Location;

string projectContents = $@"<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<UsingTask TaskName=`ValidateAssemblyLoadContext` AssemblyFile=`{customTaskPath}` />
Expand All @@ -2409,6 +2405,7 @@ public void TasksGetAssemblyLoadContexts()

ExecuteMSBuildExeExpectSuccess(projectContents);
}

#endif

private string CopyMSBuild()
Expand Down
14 changes: 1 addition & 13 deletions src/Shared/CoreCLRAssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@ internal sealed class CoreClrAssemblyLoader

private bool _resolvingHandlerHookedUp = false;

private static readonly string _msbuildDirPath;
private static readonly Version _currentAssemblyVersion = new Version(Microsoft.Build.Shared.MSBuildConstants.CurrentAssemblyVersion);

static CoreClrAssemblyLoader()
{
_msbuildDirPath = FileUtilities.NormalizePath(typeof(CoreClrAssemblyLoader).Assembly.Location);
_msbuildDirPath = Path.GetDirectoryName(_msbuildDirPath);
}

public void AddDependencyLocation(string fullPath)
{
if (fullPath == null)
Expand Down Expand Up @@ -59,12 +52,7 @@ public Assembly LoadFromPath(string fullPath)
// folders in a NuGet package).
fullPath = FileUtilities.NormalizePath(fullPath);

// If the requested load comes from the same directory as MSBuild, assume that
// the load is part of the platform, and load it using the Default ALC.
string assemblyDir = Path.GetDirectoryName(fullPath);

if (Traits.Instance.EscapeHatches.UseSingleLoadContext ||
FileUtilities.ComparePathsNoThrow(assemblyDir, _msbuildDirPath, string.Empty))
if (Traits.Instance.EscapeHatches.UseSingleLoadContext)
{
return LoadUsingLegacyDefaultContext(fullPath);
}
Expand Down