I'm setting up TeamCity to run some NUnit tests, TeamCity reports that all the test pass but it reports the build as a fail with the error message 'New build status is : : NUnit error, {build.status.text}'.
Digging in to the build log I can see that there's a failure to load the program under test, here's the reported error;
[Step 2/2] NUnit error running tests in 'C:\TeamCity\buildAgent\work\f73bb9cce36ccd59\ProjectName.Web\ProjectName.BrowserTests\obj\Release\MyProject.BrowserTests.dll' assembly
Loading assembly is compiled for v4.0.30319, MSIL
NUnit runner runtime is v4.0.30319, x86
System.IO.FileNotFoundException: Could not load file or assembly 'MyProject.Browser, Version=0.24.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'MyProject.Browser, Version=0.24.0.0, Culture=neutral, PublicKeyToken=null'
Server stack trace:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.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, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
So, why can the file not be loaded I wonder? The tests have all passed so why does this file even need to be loaded now?
I've experimented with setting the .NET runtime to x86 in the NUnit build step, to no avail.
Environment: Windows 7, VS 2012 Update 2, compiling to .NET 4.0, NUnit 2.6.2, TeamCity 7.1.
If this is still active;
It is a pretty clear error:
System.IO.FileNotFoundException: Could not load file or assembly 'MyProject.Browser, Version=0.24.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
You have to create build step to compile tests
Create another build step NUnit and pass path to assembly file you can use wildcards, more info https://stackoverflow.com/a/16629676/1075077 here.
Related
While running my unit test in VS2017 in debug mode, after the build the run starts but immediately after i get an exception before any of my breakpoints are hit:
Managed Debugging Assistant 'BindingFailure'
Message=Managed Debugging Assistant 'BindingFailure' :'*The assembly with display name 'Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter' failed to load in the 'Load' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter' or one of its dependencies. The system cannot find the file specified.*'
How can I figure it out where is this issue coming from?
The file in the exception message can be found under:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions and has the version 15.0.28307
The VS2017 that i use has the version 15.9.11
I keep getting this error when i try to use Azure Pipelines.
I am running this on the Hosted VS2017 pool.
Here is the pipeline i constructed:
The error i keep getting is displayed in the following logs:
2019-04-30T12:13:03.1506572Z =============================================================================
2019-04-30T12:13:03.1506616Z Task : .NET Core
2019-04-30T12:13:03.1506659Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2019-04-30T12:13:03.1506705Z Version : 2.150.1
2019-04-30T12:13:03.1506734Z Author : Microsoft Corporation
2019-04-30T12:13:03.1506782Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2019-04-30T12:13:03.1506811Z ==============================================================================
2019-04-30T12:13:03.7965121Z [command]C:\windows\system32\chcp.com 65001
2019-04-30T12:13:03.8059420Z Active code page: 65001
2019-04-30T12:13:03.8489997Z [command]"C:\Program Files\dotnet\dotnet.exe" build D:\a\1\s\SLDatatHighway.Tests\SLDatatHighway.Tests.csproj
2019-04-30T12:13:04.1500736Z Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
2019-04-30T12:13:04.1501599Z Copyright (C) Microsoft Corporation. All rights reserved.
2019-04-30T12:13:04.1501793Z
2019-04-30T12:13:04.8585498Z Restoring packages for D:\a\1\s\SLDatatHighway.Tests\SLDatatHighway.Tests.csproj...
2019-04-30T12:13:05.0444966Z Restore completed in 185.75 ms for D:\a\1\s\SLDatatHighway.Tests\SLDatatHighway.Tests.csproj.
2019-04-30T12:13:07.0489863Z SLDatatHighway.Tests -> D:\a\1\s\SLDatatHighway.Tests\bin\Debug\netstandard2.0\SLDatatHighway.Tests.dll
2019-04-30T12:13:07.0572034Z
2019-04-30T12:13:07.0572433Z Build succeeded.
2019-04-30T12:13:07.0572907Z 0 Warning(s)
2019-04-30T12:13:07.0573263Z 0 Error(s)
2019-04-30T12:13:07.0573380Z
2019-04-30T12:13:07.0573422Z Time Elapsed 00:00:02.84
2019-04-30T12:13:07.0915364Z [command]"C:\Program Files\dotnet\dotnet.exe" build D:\a\1\s\SL_DataHighway.Tests\SL_DataHighway.Tests.csproj
2019-04-30T12:13:07.3764095Z Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
2019-04-30T12:13:07.3807448Z Copyright (C) Microsoft Corporation. All rights reserved.
2019-04-30T12:13:07.3807518Z
2019-04-30T12:13:08.1015074Z Restoring packages for D:\a\1\s\SL_DataHighway.Tests\SL_DataHighway.Tests.csproj...
2019-04-30T12:13:08.7878736Z Restore completed in 484.69 ms for D:\a\1\s\SL_DataHighway.Tests\SL_DataHighway.Tests.csproj.
2019-04-30T12:13:14.0395526Z SL_DataHighway.Tests -> D:\a\1\s\SL_DataHighway.Tests\bin\Debug\netcoreapp2.1\SL_DataHighway.Tests.dll
2019-04-30T12:13:14.0481411Z
2019-04-30T12:13:14.0482045Z Build succeeded.
2019-04-30T12:13:14.0483401Z 0 Warning(s)
2019-04-30T12:13:14.0483487Z 0 Error(s)
2019-04-30T12:13:14.0483908Z
2019-04-30T12:13:14.0484034Z Time Elapsed 00:00:06.60
2019-04-30T12:13:14.0864499Z [command]"C:\Program Files\dotnet\dotnet.exe" build D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj
2019-04-30T12:13:14.3705111Z Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
2019-04-30T12:13:14.3705588Z Copyright (C) Microsoft Corporation. All rights reserved.
2019-04-30T12:13:14.3705720Z
2019-04-30T12:13:14.8626284Z Nothing to do. None of the projects specified contain packages to restore.
2019-04-30T12:13:15.3736897Z C:\Program Files\dotnet\sdk\2.2.105\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj]
2019-04-30T12:13:15.3779682Z C:\Program Files\dotnet\sdk\2.2.105\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj]
2019-04-30T12:13:15.4465770Z C:\Program Files\dotnet\sdk\2.2.105\Microsoft.Common.CurrentVersion.targets(2729,5): error MSB4062: The "Microsoft.Build.Tasks.ResolveComReference" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj]
2019-04-30T12:13:15.4550056Z
2019-04-30T12:13:15.4554234Z Build FAILED.
2019-04-30T12:13:15.4554556Z
2019-04-30T12:13:15.4574427Z C:\Program Files\dotnet\sdk\2.2.105\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj]
2019-04-30T12:13:15.4579425Z C:\Program Files\dotnet\sdk\2.2.105\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj]
2019-04-30T12:13:15.4580177Z C:\Program Files\dotnet\sdk\2.2.105\Microsoft.Common.CurrentVersion.targets(2729,5): error MSB4062: The "Microsoft.Build.Tasks.ResolveComReference" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj]
2019-04-30T12:13:15.4583312Z 2 Warning(s)
2019-04-30T12:13:15.4583865Z 1 Error(s)
2019-04-30T12:13:15.4585281Z
2019-04-30T12:13:15.4585654Z Time Elapsed 00:00:01.01
2019-04-30T12:13:15.4950879Z ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
2019-04-30T12:13:15.4960391Z ##[error]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\SL_Data_Highway_App\SL_Data_Highway_App.csproj
2019-04-30T12:13:15.4994396Z ##[section]Finishing: dotnet build
2019-04-30T12:13:15.5009622Z ##[section]Starting: Checkout
2019-04-30T12:13:15.5109587Z ==============================================================================
2019-04-30T12:13:15.5109634Z Task : Get sources
2019-04-30T12:13:15.5109671Z Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2019-04-30T12:13:15.5109870Z Version : 1.0.0
2019-04-30T12:13:15.5109906Z Author : Microsoft
2019-04-30T12:13:15.5109940Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2019-04-30T12:13:15.5109992Z ==============================================================================
2019-04-30T12:13:15.9176300Z Cleaning any cached credential from repository: SL-DataHighway (Git)
2019-04-30T12:13:15.9266683Z ##[section]Finishing: Checkout
2019-04-30T12:13:15.9371889Z ##[section]Starting: Finalize Job
2019-04-30T12:13:15.9414810Z Start cleaning up orphan processes.
2019-04-30T12:13:15.9425504Z ##[section]Finishing: Finalize Job
2019-04-30T12:13:15.9475730Z ##[section]Finishing: Job
Building via Visual Studio 2017 works fine. Problem is only when I try to build via an Azure Pipeline.
Is there something I am missing or did I import something wrong?
Here is an overview of the references in my project. As you can see the Outlook Interop is referenced fine as well as the Office reference.
My packages.config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Office.Interop.Outlook" version="15.0.4797.1003" targetFramework="net461" />
</packages>
Thank you in advance!
EDIT: Added pool, Added overview of packages.config
I am using Xunit.net with Visual Studio Online hosted build. My tests are being discovered and run fine both locally and on the build server. But on the build server I get this exception (causing the build to reach a "Partially Succeeded" state). This is odd, since all my tests are in fact being discovered and run.
[xUnit.net 00:00:01.3170293] Exception discovering tests from C:\a\bin\xunit.runner.visualstudio.testadapter.dll: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value HKLM\Software\Microsoft\Fusion!EnableLog to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Xunit.Sdk.Executor.EnumerateTests..ctor(Executor executor, Object _handler)$$RethrowMarker$$ at ExceptionExtensions.RethrowWithNoStackTraceLoss(Exception ex)
at Xunit.RemoteAppDomainManager.CreateObjectTObject
at Xunit.Xunit1Executor.EnumerateTests(ICallbackEventHandler handler)
at Xunit.Xunit1.Find(Predicate`1 filter, Boolean includeSourceInformation, IMessageSink messageSink)
at Xunit.Xunit1.Find(Boolean includeSourceInformation, IMessageSink messageSink)
at Xunit.XunitFrontController.Find(Boolean includeSourceInformation, IMessageSink messageSink)
at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.GetTests(IEnumerable`1 sources, IMessageLogger logger, XunitVisualStudioSettings settings, Stopwatch stopwatch)
See http://go.microsoft.com/fwlink/?LinkId=254169
I have the following nuget packages installed in the test project:
xunit 1.9.2
xunit.runner.visualstudio 0.99.2
Other unit testing frameworks, such as MS Test and NUnit, are working without problems. This makes me think the issue is with Xunit.net rather than with Visual Studio Online.
I have also opened an issue at the xUnit.net GitHub, but it remains unsolved.
https://github.com/xunit/xunit/issues/47
How can I get this working? Does anyone know of a workaround? Could I somehow suppress the error message?
The testrunner tries to discover the unit tests in xunit.runner.visualstudio.testadapter.dll. Why? Because it matches the default test sources spec of *.test*.dll.
When changing the default test source spec to *.tests.dll or something else more specific, it will work.
Source: http://erictummers.wordpress.com/2014/02/11/execute-xunit-tests-on-hosted-build-controller/
I have a Windows Phone 8 class library. Within that class library I make use of System.ServiceModel. The class library runs fine when used from a Windows Phone 8 app.
I have a unit test project. If I try and use the unit test project to test methods in the class library I get a FileNotFoundExcaption:
{"Could not load file or assembly 'System.ServiceModel,
Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file
specified.":"System.ServiceModel, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"}
I've tried using a binding re-direct, but because the two System.Service model assemblies have different publicKeyTokens that doesn't seem to work.
Is this possible?
The full fusion log is:
=== Pre-bind state information ===
LOG: User = MACHINENAME\Simon
LOG: DisplayName = System.ServiceModel, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///c:/[...]/PhoneClassLibraryReferenceTest/PhoneClassLibraryTest/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : PhoneClassLibraryReferenceTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.ServiceModel, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///c:/[...]/PhoneClassLibraryReferenceTest/PhoneClassLibraryTest/bin/Debug/System.ServiceModel.DLL.
LOG: Attempting download of new URL file:///c:/[...]/PhoneClassLibraryReferenceTest/PhoneClassLibraryTest/bin/Debug/System.ServiceModel/System.ServiceModel.DLL.
LOG: Attempting download of new URL file:///c:/[...]/PhoneClassLibraryReferenceTest/PhoneClassLibraryTest/bin/Debug/System.ServiceModel.EXE.
LOG: Attempting download of new URL file:///c:/[...]/PhoneClassLibraryReferenceTest/PhoneClassLibraryTest/bin/Debug/System.ServiceModel/System.ServiceModel.EXE.
The solution to this is to install Visual Studio 2012 update 2, and use a Windows Phone 8 test project.
This way your tests are run via the emulator and target the correct versions of the System.ServiceModel assembly.
This blog post describes how to get going with Windows Phone 8 unit test projects.
I'm able to run my unit tests through VS2010 with the CodeRush but when I try to run the tests with Icarus Test Runner I get this error.
An exception was thrown while exploring tests.
Location: C:\XXX\XXX.Server.Tests\bin\Release\XXX.Server.Tests.DLL
Reference: XXXServer.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Gallio.Common.Reflection.Impl.NativeAssemblyWrapper.GetTypes()
at Gallio.Framework.Pattern.TestAssemblyPatternAttribute.PopulateChildrenImmediately(IPatternScope assemblyScope, IAssemblyInfo assembly)
at Gallio.Framework.Pattern.TestAssemblyPatternAttribute.Consume(IPatternScope containingScope, ICodeElementInfo codeElement, Boolean skipChildren)
at Gallio.Framework.Pattern.DefaultPatternEvaluator.Consume(IPatternScope containingScope, ICodeElementInfo codeElement, Boolean skipChildren, IPattern defaultPrimaryPattern)
I've made sure Copy Local is set to True for project references.
Tests were being run on a 64bit machine with the test project Platform target set to "Any CPU" while the project being tested was set to "x86". So the machine was loading the tests as 64 which caused the error when trying to load the project being tested the same way.