When running a tests from a test plan in Azure Pipeline using Automated tests using Release stage, we are getting a failure "Could not load file or assembly 'sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. The system cannot find the file specified."
As this is a 64 bit dll, we have provided /Platform:x64 option in Vstest task. Below is the yaml for the VsTest task in the release pipeline:
steps:
- task: VSTest@2
displayName: 'VsTest - Test Run on Demand for ETL Tests'
inputs:
testSelector: testRun
searchFolder: '$(System.DefaultWorkingDirectory)\_Development\bin\Release'
vsTestVersion: toolsInstaller
pathtoCustomTestAdapters: '$(System.DefaultWorkingDirectory)\_Development\packages\'
runTestsInIsolation: false
otherConsoleOptions: '/Platform:x64'
platform: x64
configuration: Release
continueOnError: true
We are getting the same error even if the tests are run in isolation.
The Reflection LoaderExceptions fusion log is as follows:
Reflection error message is: Could not load file or assembly 'sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. The system cannot find the file specified.
Fusion Log:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\AzAgent\A1\_work\_tool\VsTest\16.7.1\x64\tools\net451\Common7\IDE\Extensions\TestPlatform\testhost.x86.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23
(Fully-specified)
LOG: Appbase = file:///C:/AzAgent/A1/_work/r1/a/_Development/packages/MSTest.TestAdapter.1.4.0/build/_common
LOG: Initial PrivatePath = NULL
Calling assembly : <calling assembly>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\AzAgent\A1\_work\r1\a\_Development\bin\Release\<test dll>.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: sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/packages/MSTest.TestAdapter.1.4.0/build/_common/sapnco.DLL.
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/packages/MSTest.TestAdapter.1.4.0/build/_common/sapnco/sapnco.DLL.
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/packages/MSTest.TestAdapter.1.4.0/build/_common/sapnco.EXE.
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/packages/MSTest.TestAdapter.1.4.0/build/_common/sapnco/sapnco.EXE.
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/bin/Release/sapnco.DLL.
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/bin/Release/sapnco/sapnco.DLL.
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/bin/Release/sapnco.EXE.
LOG: Attempting download of new URL file:///C:/AzAgent/A1/_work/r1/a/_Development/bin/Release/sapnco/sapnco.EXE.
The dll is present in the locations from which a download attempt is made in the fusion log.
We are not sure how to fix this error. We changed the build platform from Any CPU to x64 too. What is the solution to the issue?
Since you are running tests from Release stage, you should make sure the assembly file
sapnco.dll
is in your build artifact, so that could be downloaded to the release pipeline.You could check the folder
C:/AzAgent/A1/_work/r1/a/_Development/bin/Release
for assembly filesapnco.dll
.If that dll file is not there, you need to copy and publish it as artifact.
Another point is that make sure you are using the package sapnco3.x64 instead of sapnco, which is used for
x64
.Update:
After I double-checked your test task, I found that your select tests using is
Test run
rather thanTest assemblies
, the test run:To resolve this issue, please try to use
Test assemblies
.