Snehal Jadhav
Snehal Jadhav

Reputation: 61

Azure DevOps Pipeline VsTest: Error Message: System.IO.FileNotFoundException : Could not load file or assembly 'Mono.Android

Mocking the interfaces using Moq package is not working on Azure DevOps CI Build Pipeline VsTask. Xamarin Nunit test: VsTask failing with error Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1

Failing with the error Error Message: System.IO.FileNotFoundException : Could not load file or assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. The system cannot find the file specified.

pool:
vmImage: 'vs2017-win2016'
demands: - MSBuild Xamarin.Android JDK vstest

task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: | \UserModuleNUnitTest.dll !*TestAdapter.dll !\obj.
searchFolder:
'$(build.binariesdirectory)/$(BuildConfiguration) codeCoverageEnabled: false task: PublishTestResults@2
displayName: 'Publish API Test Results'
inputs:
testResultsFormat: VSTest
testResultsFiles: '**/*.trx'

All test cases should execute successfully as they are executing on local Visual Studio 2019. Below errors in the logs of Build pipeline.

Failed   Register_Api_Call
Error Message:
System.IO.FileNotFoundException : Could not load file or assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. The system cannot find the file specified.
Stack Trace:
   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
   at System.Reflection.RuntimeMethodInfo.GetParameters()
   at Castle.DynamicProxy.Generators.MethodSignatureComparer.GetHashCode(MethodInfo obj)
   at System.Linq.Set`1.InternalGetHashCode(TElement value)
   at System.Linq.Set`1.Add(TElement value)
   at System.Linq.Set`1.UnionWith(IEnumerable`1 other)
   at System.Linq.Enumerable.DistinctIterator`1.FillSet()
   at System.Linq.Enumerable.DistinctIterator`1.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Castle.DynamicProxy.Generators.MethodFinder.GetAllInstanceMethods(Type type, BindingFlags flags)
   at Castle.DynamicProxy.Contributors.MembersCollector.CollectMethods(IProxyGenerationHook hook)
   at Castle.DynamicProxy.Contributors.MembersCollector.CollectMembersToProxy(IProxyGenerationHook hook)
   at Castle.DynamicProxy.Contributors.InterfaceProxyWithoutTargetContributor.CollectElementsToProxyInternal(IProxyGenerationHook hook)+MoveNext()
   at Castle.DynamicProxy.Contributors.CompositeTypeContributor.CollectElementsToProxy(IProxyGenerationHook hook, MetaType model)
   at Castle.DynamicProxy.Generators.InterfaceProxyWithoutTargetGenerator.GenerateType(String typeName, Type proxyTargetType, Type[] interfaces, INamingScope namingScope)
   at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.<>c__DisplayClass6_0.<GenerateCode>b__0(String n, INamingScope s)
   at Castle.Core.Internal.SynchronizedDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func`3 factory)
   at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors)
   at Moq.Mock`1.InitializeInstance()
   at Moq.Mock`1.OnGetObject()
   at Moq.Mock`1.get_Object()
   at Tests.Registration.Setup() in D:\a\1\s\UserModuleNUnitTest\Registration.cs:line 38
Results File: D:\a\1\s\TestResults\VssAdministrator_fv-az45_2019-08-24_11_45_24.trx

Upvotes: 0

Views: 1648

Answers (1)

Leo Varghese
Leo Varghese

Reputation: 175

@Snehal Jadhav This could be because your application cannot find the assembly file - Mono.Android. Could you re-run the test after verifying the below things?

  • path to the dll file is configured correctly?
  • you are not referring a
  • malformed assembly package you are using the correct version.

You can check for the version of the current dll file by viewing its details from a windows machine.

Upvotes: 0

Related Questions