pbachman
pbachman

Reputation: 1059

The library 'hostpolicy.dll' required to execute

We are using Azure Devops as a CI/CD pipeline for a .NET 6 project. When running the unit tests, the following error message appears:

##[error]Testhost process for source(s) 'D:\a\1\s\Tests\PROJECTNAME.Core.Test\bin\Release\net6.0\Microsoft.TestPlatform.PlatformAbstractions.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'. ##[error]Failed to run as a self-contained app. ##[error] - The application was run as a self-contained app because 'D:\a\1\s\Tests\PROJECTNAME.Core.Test\bin\Release\net6.0\testhost.runtimeconfig.json' was not found. ##[error] - If this should be a framework-dependent app, add the 'D:\a\1\s\Tests\PROJECTNAME.Core.Test\bin\Release\net6.0\testhost.runtimeconfig.json' file and specify the appropriate framework. ##[error]. Please check the diagnostic logs for more information.

The structure of the project is as follows:

The Azure DevOps configuration looks like this:

- task: VSTest@2
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: |
        $(System.DefaultWorkingDirectory)\Tests\**\bin\**\*.Test.dll
        **\*test*.dll
        !**\*TestAdapter.dll
        !**\obj\**
      searchFolder: './Tests'
      platform: '$(buildPlatform)'
      configuration: '$(configuration)'
      codeCoverageEnabled: true
      

What is wrong with the configuration ?

Upvotes: 1

Views: 4055

Answers (1)

Ging Yuan-MSFT
Ging Yuan-MSFT

Reputation: 747

According to the error message, it seems related to the "Test.dll" setting.

You can check the current test name and try to set path to the Test.dll explicitly.

You can try to use "**\*test.dll" or "**\*.test.dll" to check the results.

For more information, you could refer to the similar problem.

Upvotes: 2

Related Questions