issue with nunit runner on platform specific test run within TeamCity but not from nunitlauncher in a command line

Hello,

I'm running into issues during test run for a sln2008 build:

NUnit Error: System.IO.FileNotFoundException: Could not load file or assembly 'AnAssemblyReferencedInNyTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

please see the complete stack trace at the end of this post.

some informations:
- build config / solution is specified to building for x86
- the build agent is on a 32 bit OS
- the nunit is specified to test for x86
- the tests and dependencies relies on native assembly
- teamcity 5.0.2 build 10784

running the following commands from command prompt works ok (I can't reproduce the error):

absolutepathtobuildagent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe v2.0 msil NUnit-2.5.3 absolutepathtothetestsdll

or

absolutepathtobuildagent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe v2.0 x86 NUnit-2.5.3 absolutepathtothetestsdll

I've tried almost all permutations in the build configuration settings but can't get it to work, I'm sure that I hit the right assembly in the temporary working copy (tried after forcing a clean checkout with only platform built in the working copy)

Any idea how I can investigate / solve the problem?

Thanks

===================================================
here is the complete stack trace that come out of the build failure log:


Server stack trace:
   at System.Reflection.Assembly._GetExportedTypes()
   at System.Reflection.Assembly.GetExportedTypes()
   at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
   at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
   at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
   at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.Load(TestPackage package)
   at JetBrains.TeamCity.NUnitLauncher.NUnitRunner.LoadTest(String testAssembly, String testName, TestRunner runner) in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\NUnit-2.5\NUnitRunner.cs:line 42
   at JetBrains.TeamCity.NUnitLauncher.AssemblyTest.LoadTestDomain() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\AssemblyTest.cs:line 71
   at JetBrains.TeamCity.NUnitLauncher.LoadTestDomainAction.Action(AssemblyTest test) in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\LoadTestDomainAction.cs:line 14
   at JetBrains.TeamCity.NUnitLauncher.TryOneAssemblyTest.Action() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\TryOneAssemblyTest.cs:line 18
   at JetBrains.TeamCity.NUnitLauncher.TryOneAssembly.Do() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\TryOneAssembly.cs:line 31

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  d:\programs\teamcity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.TeamCity.PlatformProcessRunner.x86.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = AssemblyReferenceByTheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release
LOG: Initial PrivatePath = NULL
Calling assembly : TheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly.DLL.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly/AssemblyReferenceByTheTestAssembly.DLL.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly.EXE.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly/AssemblyReferenceByTheTestAssembly.EXE.
[16:52:46]: Failure executing test(s) on assembly D:\tmp\teamcitybuildagent\workdir\ae4ccce25713186f\ACE\Test\obj\x86\Release\TheTestAssembly.dll with NUnit 2.5.3.9345. System.IO.FileNotFoundException: Could not load file or assembly 'AssemblyReferenceByTheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'AssemblyReferenceByTheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

Server stack trace:
   at System.Reflection.Assembly._GetExportedTypes()
   at System.Reflection.Assembly.GetExportedTypes()
   at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
   at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
   at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
   at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.Load(TestPackage package)
   at JetBrains.TeamCity.NUnitLauncher.NUnitRunner.LoadTest(String testAssembly, String testName, TestRunner runner) in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\NUnit-2.5\NUnitRunner.cs:line 42
   at JetBrains.TeamCity.NUnitLauncher.AssemblyTest.LoadTestDomain() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\AssemblyTest.cs:line 71
   at JetBrains.TeamCity.NUnitLauncher.LoadTestDomainAction.Action(AssemblyTest test) in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\LoadTestDomainAction.cs:line 14
   at JetBrains.TeamCity.NUnitLauncher.TryOneAssemblyTest.Action() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\TryOneAssemblyTest.cs:line 18
   at JetBrains.TeamCity.NUnitLauncher.TryOneAssembly.Do() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\TryOneAssembly.cs:line 31

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  d:\programs\teamcity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.TeamCity.PlatformProcessRunner.x86.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = AssemblyReferenceByTheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release
LOG: Initial PrivatePath = NULL
Calling assembly : TheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly.DLL.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly/AssemblyReferenceByTheTestAssembly.DLL.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly.EXE.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly/AssemblyReferenceByTheTestAssembly.EXE.
[16:52:46]: System.IO.FileNotFoundException: Could not load file or assembly 'AssemblyReferenceByTheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'AssemblyReferenceByTheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

Server stack trace:
   at System.Reflection.Assembly._GetExportedTypes()
   at System.Reflection.Assembly.GetExportedTypes()
   at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
   at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
   at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
   at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.Load(TestPackage package)
   at JetBrains.TeamCity.NUnitLauncher.NUnitRunner.LoadTest(String testAssembly, String testName, TestRunner runner) in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\NUnit-2.5\NUnitRunner.cs:line 42
   at JetBrains.TeamCity.NUnitLauncher.AssemblyTest.LoadTestDomain() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\AssemblyTest.cs:line 71
   at JetBrains.TeamCity.NUnitLauncher.LoadTestDomainAction.Action(AssemblyTest test) in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\LoadTestDomainAction.cs:line 14
   at JetBrains.TeamCity.NUnitLauncher.TryOneAssemblyTest.Action() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\TryOneAssemblyTest.cs:line 18
   at JetBrains.TeamCity.NUnitLauncher.TryOneAssembly.Do() in c:\Agent\work\3f3d88bdf17c1223\src\NUnitLauncher\src\TryOneAssembly.cs:line 31

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  d:\programs\teamcity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.TeamCity.PlatformProcessRunner.x86.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = AssemblyReferenceByTheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release
LOG: Initial PrivatePath = NULL
Calling assembly : TheTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly.DLL.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly/AssemblyReferenceByTheTestAssembly.DLL.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly.EXE.
LOG: Attempting download of new URL file:///D:/tmp/teamcitybuildagent/workdir/ae4ccce25713186f/ACE/Test/obj/x86/Release/AssemblyReferenceByTheTestAssembly/AssemblyReferenceByTheTestAssembly.EXE.
[16:52:46]: [Project "ACE.sln.teamcity.patch.tcprojx" (Build_TeamCity_generated_48136652dffe4d849da2b906de876dd0;NUnit_TeamCity_generated_48136652dffe4d849da2b906de876dd0 target(s)):] D:\tmp\teamcitybuildagent\workdir\ae4ccce25713186f\ACE\ACE.sln.teamcity.patch.tcprojx(10, 5): d:\programs\teamcity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe "@@" D:\tmp\teamcitybuildagent\tmp\buildTmp\tmp3DE4.tmp exited with code 1.

5 comments
Comment actions Permalink

Could you please do the following:
- make build agent server running under some administrative accound
- check the missing assembly is placed near test assembly.

Thanks!

0
Comment actions Permalink

Hello Eugene, thanks for your help.

I've switched the build agent service to an admin account (was SYSTEM account previously though) without change, I reverted to SYSTEM

The assembly sits right next to the test assembly in the binary output folder of the test project.

It looks to me that the issue for some reason is with loading native dependencies but I can't find a good reason for that (x86 build on a x86 os with x86 set all the way, and it works when using nunitlauncher from the command line with both x86 or msil platform argument)

EDIT: also tested to setup Administrator right checkbox on the TeamCityAgentService-windows-x86-32.exe in property / compatibility tab

0
Comment actions Permalink

Could you please try to specify a full path to the assembly to run tests on.

0
Comment actions Permalink

Thanks Eugene, interestingly, it make the build succeed, in fact all tests were already passing even with the error I'm reporting.

my Run tests from setting was '**\*test*.dll'

It seems that the test runner try to load the test from somwhere else, but I can't find any other place that match this pattern in the solution folder.

Do someone have any clue from where does the nunit runner would find the dll with the pattern I'm using? I'm positive that there is only one test dll in the solution I'm running the build for.

EDIT: when specifying relative path to the assembly (SOLUTION\PROJECT\OUTPUTDIR\ASSEMBLYNAME.dll), build is still crashing

EDIT: the test tries to run from the obj folder which doesn't contains referenced assemblies...
=> fixed the pattern to **\bin\**\*Test*.dll
=> feels somewhat dumb now, moving on the x64 build

0
Comment actions Permalink

For .net builds with msbuild don't use too much open wildcard pattern for running tests:

for example *\test*.dll will try to run the assemblies from the obj folder where assemblies lays after the build.

use *\bin\\test*.dll instead

0

Please sign in to leave a comment.