Skip to content

"The library 'hostpolicy.dll' required to execute the application was not found" - Azure vstest #4743

Closed

Description

Description

Hello, I have an automated E2E test project on Azure and have a build pipeline set up to run our test suite

I am trying to set up a release pipeline in order to run selected automated tests directly from Azure Test Plans, following this guide:
https://learn.microsoft.com/en-us/azure/devops/test/run-automated-tests-from-test-hub?view=azure-devops

My build pipeline publishes an artifact containing the test binaries and the release pipeline downloads the binaries artifact ok, also the automated test cases are associated to the case in the Test Plan

But when I go to run the test I get a 'hostpolicy.dll' library missing error (see error message / logs below)

I tried following the steps outlined in this response but have not been able to get it working but yet:
#2427 (comment)

Steps to reproduce

Expected behavior

Selected test(s) from Test Plans should run

Actual behavior

Test exits with error: 'hostpolicy.dll' required to execute the application was not found

Diagnostic logs

2023-11-08T18:38:35.3500242Z ##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'C:\agent01_work\r1\a\binaries\Ts.TestAutomation.Web.Tests.dll' exited with error: Cannot use file stream for [C:\agent01_work\r1\a\binaries\testhost.deps.json]: No such file or directory
2023-11-08T18:38:35.3507332Z A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\agent01_work\r1\a\binaries'.
2023-11-08T18:38:35.3509600Z Failed to run as a self-contained app.
2023-11-08T18:38:35.3511962Z - The application was run as a self-contained app because 'C:\agent01_work\r1\a\binaries\testhost.runtimeconfig.json' was not found.
2023-11-08T18:38:35.3517076Z - If this should be a framework-dependent app, add the 'C:\agent01_work\r1\a\binaries\testhost.runtimeconfig.json' file and specify the appropriate framework.
2023-11-08T18:38:35.3519328Z . Please check the diagnostic logs for more information.
2023-11-08T18:38:35.3522035Z at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable1 sources, Boolean testHostExited) in /_/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs:line 520 2023-11-08T18:38:35.3525746Z at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources, String runSettings) in //src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs:line 294
2023-11-08T18:38:35.3529864Z at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters) in /
/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyDiscoveryManager.cs:line 149
2023-11-08T18:38:35.4866569Z ##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'C:\agent01_work\r1\a\binaries\Ts.TestAutomation.Web.Tests.dll' exited with error: . Please check the diagnostic logs for more information.
2023-11-08T18:38:35.4962672Z at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable1 sources, Boolean testHostExited) in /_/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs:line 520 2023-11-08T18:38:35.4979792Z at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable1 sources, String runSettings) in //src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs:line 294
2023-11-08T18:38:35.4987864Z at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters) in /
/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyDiscoveryManager.cs:line 149
2023-11-08T18:38:35.5697915Z ##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'C:\agent01_work\r1\a\binaries\binaries\Ts.TestAutomation.Web.Tests.dll' exited with error: Cannot use file stream for [C:\agent01_work\r1\a\binaries\binaries\testhost.deps.json]: No such file or directory
2023-11-08T18:38:35.5704704Z A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\agent01_work\r1\a\binaries\binaries'.
2023-11-08T18:38:35.5707532Z Failed to run as a self-contained app.
2023-11-08T18:38:35.5709067Z - The application was run as a self-contained app because 'C:\agent01_work\r1\a\binaries\binaries\testhost.runtimeconfig.json' was not found.
2023-11-08T18:38:35.5711018Z - If this should be a framework-dependent app, add the 'C:\agent01_work\r1\a\binaries\binaries\testhost.runtimeconfig.json' file and specify the appropriate framework.

Environment

Test project on .NET 7.0
vstest task version 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions