I am attempting to run some regression tests using CI/CD and the arcgis libraries are not able to be found when the test are ran this way. But when the test.bat file is ran manually all the tests pass. I have followed all the steps in https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Regression-Testing but am unsure if there are additional changes that need to be made to allow for the tests to be ran via CI/CD.
Any advice would be greatly appreciated.
Error message from one of the tests that fails
Error: System.IO.FileNotFoundException: Could not load file or assembly 'ArcGIS.Desktop.Core, Version=13.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'. The system cannot find the file specified.
Passed GetAllProjects [1 s]
Failed CreateMapOnce [443 ms]
Error Message:
Test method Reg_TESTS_Regression.MapFeatureClass.CreateMapOnce threw exception:
System.Exception: Failed to open Project;
Test Function
[TestMethod]
public async Task CreateMapOnce()
{
CreateProjectSettings createProjectSettings = new CreateProjectSettings()
{
Name = "Test",
};
await Project.CreateAsync(createProjectSettings);
Assert.IsTrue(true);
}
CI/CD code:
test:
stage: test
script:
- .\test.bat
dependencies:
- build_debug
test.bat
call "%VS22Tools%\vsdevcmd"
echo "Dotnet restore"
dotnet restore
echo "Restoring git packages"
nuget restore %Solution%
echo "Build Reg TESTS project"
msbuild.exe %Solution%
echo "Running Reg Tests"
vstest.console.exe Reg_tests\bin\Debug\net6.0-windows\Reg_tests.dll
echo "Running Reg Tests"
vstest.console.exe Reg_TESTS_Regression\bin\Debug\net6.0-windows\Reg_TESTS_Regression.dll
We do something similar and found we needed to manually have the Esri dlls copied to the unit test output folder, which we accomplished with a target in the test project csproj file.
<Target Name="CopyEsriDlls" AfterTargets="Build">
<ItemGroup>
<EsriDlls Include="$(NuGetPackageRoot)Esri.ArcGISPro.Extensions30\3.1.*\ref\net6.0-windows7.0\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(EsriDlls)" DestinationFolder="$(OutputPath)" />
</Target>
Thank you so much for this idea. Unfortunately this had the same effect of setting the copy local status of the reference to true
<Reference Include="ArcGIS.Desktop.Core">
<HintPath>C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll</HintPath>
<CopyLocal>True</CopyLocal>
<Private>False</Private>
</Reference>
It throws this error when testing locally or when running the tests via the CI/CD
The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.DllNotFoundException: Unable to load DLL 'DADFLib.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)