Skip to content

Commit

Permalink
Merge pull request #1376 from veleek/veleek/native-assembly-resolve-v315
Browse files Browse the repository at this point in the history
Integrate TestAssemblyLoadContext changes to version315
  • Loading branch information
OsirisTerje authored May 22, 2024
2 parents 8b77e76 + 5f9515f commit a0e18d3
Show file tree
Hide file tree
Showing 10 changed files with 419 additions and 73 deletions.
3 changes: 2 additions & 1 deletion cake/package-checks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ string[] AGENT_FILES = {
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll"};
string[] AGENT_FILES_NETCORE = {
"nunit-agent.dll", "nunit-agent.dll.config",
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll"};
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
"Microsoft.Extensions.DependencyModel.dll"};
string[] AGENT_PDB_FILES = {
"nunit-agent.pdb", "nunit-agent-x86.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
string[] AGENT_PDB_FILES_NETCORE = {
Expand Down
5 changes: 5 additions & 0 deletions choco/nunit-console-runner.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<file src = "$BIN_DIR$agents/netcoreapp3.1/nunit.engine.api.xml" target="tools/agents/netcoreapp3.1" />
<file src = "$BIN_DIR$agents/netcoreapp3.1/nunit.engine.core.dll" target="tools/agents/netcoreapp3.1" />
<file src = "$BIN_DIR$agents/netcoreapp3.1/testcentric.engine.metadata.dll" target="tools/agents/netcoreapp3.1" />
<file src = "$BIN_DIR$agents/netcoreapp3.1/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/netcoreapp3.1" />
<file src = "nunit.agent.addins" target = "tools/agents/netcoreapp3.1" />

<file src = "$BIN_DIR$agents/net5.0/nunit-agent.dll" target="tools/agents/net5.0" />
Expand All @@ -81,6 +82,7 @@
<file src = "$BIN_DIR$agents/net5.0/nunit.engine.api.xml" target="tools/agents/net5.0" />
<file src = "$BIN_DIR$agents/net5.0/nunit.engine.core.dll" target="tools/agents/net5.0" />
<file src = "$BIN_DIR$agents/net5.0/testcentric.engine.metadata.dll" target="tools/agents/net5.0" />
<file src = "$BIN_DIR$agents/net5.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net5.0" />
<file src = "nunit.agent.addins" target = "tools/agents/net5.0" />

<file src = "$BIN_DIR$agents/net6.0/nunit-agent.dll" target="tools/agents/net6.0" />
Expand All @@ -91,6 +93,7 @@
<file src = "$BIN_DIR$agents/net6.0/nunit.engine.api.xml" target="tools/agents/net6.0" />
<file src = "$BIN_DIR$agents/net6.0/nunit.engine.core.dll" target="tools/agents/net6.0" />
<file src = "$BIN_DIR$agents/net6.0/testcentric.engine.metadata.dll" target="tools/agents/net6.0" />
<file src = "$BIN_DIR$agents/net6.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net6.0" />
<file src = "nunit.agent.addins" target = "tools/agents/net6.0" />

<file src = "$BIN_DIR$agents/net7.0/nunit-agent.dll" target="tools/agents/net7.0" />
Expand All @@ -101,6 +104,7 @@
<file src = "$BIN_DIR$agents/net7.0/nunit.engine.api.xml" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/nunit.engine.core.dll" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/testcentric.engine.metadata.dll" target="tools/agents/net7.0" />
<file src = "$BIN_DIR$agents/net7.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net7.0" />
<file src = "nunit.agent.addins" target = "tools/agents/net7.0" />

<file src = "$BIN_DIR$agents/net8.0/nunit-agent.dll" target="tools/agents/net8.0" />
Expand All @@ -111,6 +115,7 @@
<file src = "$BIN_DIR$agents/net8.0/nunit.engine.api.xml" target="tools/agents/net8.0" />
<file src = "$BIN_DIR$agents/net8.0/nunit.engine.core.dll" target="tools/agents/net8.0" />
<file src = "$BIN_DIR$agents/net8.0/testcentric.engine.metadata.dll" target="tools/agents/net8.0" />
<file src = "$BIN_DIR$agents/net8.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net8.0" />
<file src = "nunit.agent.addins" target = "tools/agents/net8.0" />
</files>
</package>
37 changes: 29 additions & 8 deletions msi/nunit/engine-files.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@
</ComponentGroup>
<ComponentGroup Id="NETCORE31_AGENT" Directory="NETCORE31_AGENT_DIR">
<Component Id="NUNIT_AGENT_NETCORE31" Location="local" Guid="21E39B4C-07E4-4C38-8F91-7030516127E2">
<File Id="nunit_agent_netcore31.exe"
<File Id="nunit_agent_netcore31.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/netcoreapp3.1/nunit-agent.dll" />
Source="$(var.InstallImage)bin/agents/netcoreapp3.1/nunit-agent-netcore31.dll" />
<File Id="nunit_agent_netcore31.dll.config"
Source="$(var.InstallImage)bin/agents/netcoreapp3.1/nunit-agent-netcore31.dll.config" />
<File Id="nunit_agent_netcore31.deps.json"
Source="$(var.InstallImage)bin/agents/netcoreapp3.1/nunit-agent.deps.json" />
<File Id="nunit_agent_netcore31.runtimeconfig.json"
Expand All @@ -117,12 +119,19 @@
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/netcoreapp3.1/testcentric.engine.metadata.dll" />
</Component>
<Component Id="NUNIT_AGENT_NETCORE31_DEPENDENCY_MODEL" Location="local" Guid="6A33A615-BCD2-411C-B3A8-95BF5829C8CA">
<File Id="Microsoft.Extensions.DependencyModel.netcore31.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)agents/nunit-agent-netcore31/Microsoft.Extensions.DependencyModel.dll" />
</Component>
</ComponentGroup>
<ComponentGroup Id="NET50_AGENT" Directory="NET50_AGENT_DIR">
<Component Id="NUNIT_AGENT_NET50" Location="local" Guid="6B5C423E-5EDB-4DD4-8B7F-626C8F4EAF06">
<File Id="nunit_agent_net50.exe"
<File Id="nunit_agent_net50.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net5.0/nunit-agent.dll" />
Source="$(var.InstallImage)bin/agents/net5.0/nunit-agent-net50.dll" />
<File Id="nunit_agent_net50.dll.config"
Source="$(var.InstallImage)bin/agents/net5.0/nunit-agent-net50.dll.config" />
<File Id="nunit_agent_net50.deps.json"
Source="$(var.InstallImage)bin/agents/net5.0/nunit-agent.deps.json" />
<File Id="nunit_agent_net50.runtimeconfig.json"
Expand All @@ -145,16 +154,23 @@
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net5.0/testcentric.engine.metadata.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET50_DEPENDENCY_MODEL" Location="local" Guid="EF4F5A8A-AC06-4228-97C0-DBD8B7E1C50B">
<File Id="Microsoft.Extensions.DependencyModel.net50.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net5.0/Microsoft.Extensions.DependencyModel.dll" />
</Component>
</ComponentGroup>
<ComponentGroup Id="NET60_AGENT" Directory="NET60_AGENT_DIR">
<Component Id="NUNIT_AGENT_NET60" Location="local" Guid="8AFA7F03-96EA-4F80-8B79-7AFB59B67786">
<File Id="nunit_agent_net60.exe"
<File Id="nunit_agent_net60.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net6.0/nunit-agent.dll" />
Source="$(var.InstallImage)bin/net6.0/nunit-agent-net60.dll" />
<File Id="nunit_agent_net60.dll.config"
Source="$(var.InstallImage)bin/net6.0/nunit-agent-net60.dll.config" />
<File Id="nunit_agent_net60.deps.json"
Source="$(var.InstallImage)bin/agents/net6.0/nunit-agent.deps.json" />
Source="$(var.InstallImage)bin/net6.0/nunit-agent.deps.json" />
<File Id="nunit_agent_net60.runtimeconfig.json"
Source="$(var.InstallImage)bin/agents/net6.0/nunit-agent.runtimeconfig.json" />
Source="$(var.InstallImage)bin/net6.0/nunit-agent.runtimeconfig.json" />
</Component>
<Component Id="NUNIT_AGENT_NET60_ENGINE_API" Location="local" Guid="393F8699-4F44-479B-916D-34F506F089D1">
<File Id="nunit.agent.net60.engine.api.dll"
Expand All @@ -173,6 +189,11 @@
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/testcentric.engine.metadata.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET60_DEPENDENCY_MODEL" Location="local" Guid="EFD82EAE-A38E-45E0-944B-A776F7353100">
<File Id="Microsoft.Extensions.DependencyModel.net60.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/Microsoft.Extensions.DependencyModel.dll" />
</Component>
</ComponentGroup>
</Fragment>
</Include>
1 change: 1 addition & 0 deletions nuget/runners/nunit.console-runner.netcore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<file src="net6.0/nunit.engine.api.pdb" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.api.xml" target="tools/net6.0/any" />
<file src="net6.0/testcentric.engine.metadata.dll" target="tools/net6.0/any" />
<file src="Microsoft.Extensions.DependencyModel.dll" target="tools/net6.0/any" />
<file src="../../nuget/runners/nunit.console.nuget.addins" target="tools/net6.0/any"/>
<file src="../../nuget/runners/DotnetToolSettings.xml" target="tools/net6.0/any"/>

Expand Down
5 changes: 5 additions & 0 deletions nuget/runners/nunit.console-runner.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<file src="agents/netcoreapp3.1/nunit.engine.core.dll" target="tools/agents/netcoreapp3.1" />
<file src="agents/netcoreapp3.1/nunit.engine.core.pdb" target="tools/agents/netcoreapp3.1" />
<file src="agents/netcoreapp3.1/testcentric.engine.metadata.dll" target="tools/agents/netcoreapp3.1" />
<file src="agents/netcoreapp3.1/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/netcoreapp3.1" />
<file src="../../nuget/engine/nunit.agent.addins" target="tools/agents/netcoreapp3.1"/>

<file src="agents/net5.0/nunit-agent.dll" target="tools/agents/net5.0" />
Expand All @@ -78,6 +79,7 @@
<file src="agents/net5.0/nunit.engine.core.dll" target="tools/agents/net5.0" />
<file src="agents/net5.0/nunit.engine.core.pdb" target="tools/agents/net5.0" />
<file src="agents/net5.0/testcentric.engine.metadata.dll" target="tools/agents/net5.0" />
<file src="agents/net5.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net5.0" />
<file src="../../nuget/engine/nunit.agent.addins" target="tools/agents/net5.0"/>

<file src="agents/net6.0/nunit-agent.dll" target="tools/agents/net6.0" />
Expand All @@ -91,6 +93,7 @@
<file src="agents/net6.0/nunit.engine.core.dll" target="tools/agents/net6.0" />
<file src="agents/net6.0/nunit.engine.core.pdb" target="tools/agents/net6.0" />
<file src="agents/net6.0/testcentric.engine.metadata.dll" target="tools/agents/net6.0" />
<file src="agents/net6.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net6.0" />
<file src="../../nuget/engine/nunit.agent.addins" target="tools/agents/net6.0"/>

<file src="agents/net7.0/nunit-agent.dll" target="tools/agents/net7.0" />
Expand All @@ -104,6 +107,7 @@
<file src="agents/net7.0/nunit.engine.core.dll" target="tools/agents/net7.0" />
<file src="agents/net7.0/nunit.engine.core.pdb" target="tools/agents/net7.0" />
<file src="agents/net7.0/testcentric.engine.metadata.dll" target="tools/agents/net7.0" />
<file src="agents/net7.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net7.0" />
<file src="../../nuget/engine/nunit.agent.addins" target="tools/agents/net7.0"/>

<file src="agents/net8.0/nunit-agent.dll" target="tools/agents/net8.0" />
Expand All @@ -117,6 +121,7 @@
<file src="agents/net8.0/nunit.engine.core.dll" target="tools/agents/net8.0" />
<file src="agents/net8.0/nunit.engine.core.pdb" target="tools/agents/net8.0" />
<file src="agents/net8.0/testcentric.engine.metadata.dll" target="tools/agents/net8.0" />
<file src="agents/net8.0/Microsoft.Extensions.DependencyModel.dll" target="tools/agents/net8.0" />
<file src="../../nuget/engine/nunit.agent.addins" target="tools/agents/net8.0"/>

<file src="net20/nunit3-console.exe" target="tools" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class NUnitNetCore31Driver : IFrameworkDriver
Assembly _frameworkAssembly;
object _frameworkController;
Type _frameworkControllerType;
CustomAssemblyLoadContext _assemblyLoadContext;
TestAssemblyLoadContext _assemblyLoadContext;

/// <summary>
/// An id prefix that will be passed to the test framework and used as part of the
Expand All @@ -58,13 +58,7 @@ public string Load(string assemblyPath, IDictionary<string, object> settings)
var idPrefix = string.IsNullOrEmpty(ID) ? "" : ID + "-";

assemblyPath = Path.GetFullPath(assemblyPath); //AssemblyLoadContext requires an absolute path
_assemblyLoadContext = new CustomAssemblyLoadContext(assemblyPath);

_assemblyLoadContext.Resolving += (context, assemblyName) =>
{
var calc = context as CustomAssemblyLoadContext;
return calc?.LoadFallback(assemblyName);
};
_assemblyLoadContext = new TestAssemblyLoadContext(assemblyPath);

try
{
Expand Down

This file was deleted.

Loading

0 comments on commit a0e18d3

Please sign in to comment.