Dirty fix for appdomain base directory

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 10 years ago
parent 08ea617ae9
commit 52d634af7b
  1. 22
      DotNetBuilder/NUnitTester.cs

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using NUnit.Core; using NUnit.Core;
namespace MicroBuildServer.DotNetBuilder namespace MicroBuildServer.DotNetBuilder
@ -136,17 +138,20 @@ namespace MicroBuildServer.DotNetBuilder
} }
} }
[Serializable] public interface ITestWorker
private class TestWorker
{ {
public string TestLibraryPath { get; set; } void DoTest(string testLibraryPath);
}
public void DoTest() [Serializable]
public class TestWorker : MarshalByRefObject, ITestWorker
{
public void DoTest(string testLibraryPath)
{ {
Console.SetOut(new StubWriter()); Console.SetOut(new StubWriter());
var listener = new Listener(); var listener = new Listener();
CoreExtensions.Host.InitializeService(); CoreExtensions.Host.InitializeService();
var package = new TestPackage(TestLibraryPath); var package = new TestPackage(testLibraryPath);
//package.AutoBinPath = true; //package.AutoBinPath = true;
//package.BasePath = Path.GetDirectoryName(TestLibraryPath); //package.BasePath = Path.GetDirectoryName(TestLibraryPath);
//package.ConfigurationFile = TestLibraryPath + ".config"; //package.ConfigurationFile = TestLibraryPath + ".config";
@ -199,13 +204,12 @@ namespace MicroBuildServer.DotNetBuilder
{ {
AppDomainSetup setup = new AppDomainSetup(); AppDomainSetup setup = new AppDomainSetup();
setup.ConfigurationFile = request.TestLibraryPath + ".config"; setup.ConfigurationFile = request.TestLibraryPath + ".config";
setup.ApplicationBase = Path.GetDirectoryName(request.TestLibraryPath);
AppDomain tester = AppDomain.CreateDomain("tester", AppDomain.CurrentDomain.Evidence, setup); AppDomain tester = AppDomain.CreateDomain("tester", AppDomain.CurrentDomain.Evidence, setup);
var worker = new TestWorker(); var worker = (ITestWorker) tester.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, typeof (TestWorker).FullName);
worker.TestLibraryPath = request.TestLibraryPath;
var del = new CrossAppDomainDelegate(worker.DoTest); worker.DoTest(request.TestLibraryPath);
tester.DoCallBack(del);
return (Response)(tester.GetData(DATA_TEST_RESULTS_KEY)); return (Response)(tester.GetData(DATA_TEST_RESULTS_KEY));
} }
} }

Loading…
Cancel
Save