Skip to content

Commit

Permalink
Copy Cone.dll to ApplicationBase if missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkcod committed Nov 10, 2014
1 parent e70209f commit 866726d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Source/Runners/CrossDomainConeRuner.cs
Expand Up @@ -96,24 +96,32 @@ class RunTestsCommand
}

static T WithTestDomain<T>(string configPath, string[] assemblyPaths, Func<AppDomain,T> @do) {
var domainSetup = new AppDomainSetup {
var domainSetup = new AppDomainSetup {
ApplicationBase = Path.GetDirectoryName(assemblyPaths.First()),
ShadowCopyFiles = "False",
};

if(string.IsNullOrEmpty(configPath) && assemblyPaths.Length == 1)
configPath = Path.GetFullPath(assemblyPaths[0] + ".config");

if(File.Exists(configPath))
domainSetup.ConfigurationFile = configPath;

var conePath = new Uri(typeof(CrossDomainConeRunner).Assembly.CodeBase).LocalPath;

var localCone = Path.Combine(domainSetup.ApplicationBase, Path.GetFileName(conePath));
if(!File.Exists(localCone))
File.Copy(conePath, localCone);

var testDomain = AppDomain.CreateDomain("Cone.TestDomain",
null,
AppDomain.CurrentDomain.Evidence,
domainSetup,
new PermissionSet(PermissionState.Unrestricted));

Environment.CurrentDirectory = Path.GetFullPath(Path.GetDirectoryName(assemblyPaths.First()));

testDomain.SetData("assemblyPaths", assemblyPaths);
testDomain.Load(File.ReadAllBytes(new Uri(typeof(CrossDomainConeRunner).Assembly.CodeBase).LocalPath));
testDomain.AssemblyResolve += (_, e) => {
var candidates = (ResolveCandidate[])AppDomain.CurrentDomain.GetData("candidatePaths");
if(candidates == null) {
Expand Down

0 comments on commit 866726d

Please sign in to comment.