question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure Pipelines VSTest task fails after Microsoft.NET.Test.Sdk is updated from 16.2 to 16.3

See original GitHub issue

Description

Starting with the most recent commit to my project Stein the CI build provided by Azure Pipelines fails. The build in question: https://dev.azure.com/nkristek/Stein/_build/results?buildId=148

Specifically the VSTest task fails with the error:

##[error]Testhost process exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'd:\a\1\s\test\Stein.ViewModels.Tests\bin\Release\netcoreapp2.1\'.
##[error]Failed to run as a self-contained app. If this should be a framework-dependent app, add the d:\a\1\s\test\Stein.ViewModels.Tests\bin\Release\netcoreapp2.1\testhost.runtimeconfig.json file specifying the appropriate framework.

Previously everything ran fine, this commit updated dependencies. Specifically the Microsoft.NET.Test.Sdk was updated from 16.2 to 16.3. I reran the previous commit with success: https://dev.azure.com/nkristek/Stein/_build/results?buildId=149 This seems to indicate that the new version of Microsoft.NET.Test.Sdk produces this error.

Steps to reproduce

Run Azure Pipelines build with the following repository and settings: Repository: https://github.com/nkristek/Stein Configuration: https://github.com/nkristek/Stein/blob/master/azure-pipelines.yml

Expected behavior

The VSTest task succeeds.

Actual behavior

The VSTest task fails with the error:

##[error]Testhost process exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'd:\a\1\s\test\Stein.ViewModels.Tests\bin\Release\netcoreapp2.1\'.
##[error]Failed to run as a self-contained app. If this should be a framework-dependent app, add the d:\a\1\s\test\Stein.ViewModels.Tests\bin\Release\netcoreapp2.1\testhost.runtimeconfig.json file specifying the appropriate framework.

Diagnostic logs

Please share test platform diagnostics logs. Instructions to collect logs are here.
The logs may contain test assembly paths, kindly review and mask those before sharing.

Environment

Configuration: https://github.com/nkristek/Stein/blob/master/azure-pipelines.yml:

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

pool:
  vmImage: 'VS2017-Win2016'

variables:
  solution: '**/*.sln'
  
strategy:
  maxParallel: 2
  matrix:
    x86:
      buildPlatform: 'x86'
      buildConfiguration: 'Release'
    x64:
      buildPlatform: 'x64'
      buildConfiguration: 'Release'

steps:
- task: DotNetCoreInstaller@0
  displayName: 'Install .NET Core 2.1'
  inputs:
    version: '2.1.300'

- task: NuGetToolInstaller@1
  displayName: 'Install NuGet'

- task: NuGetCommand@2
  displayName: 'Restore NuGet packages'
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  displayName: 'Build'
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    clean: true

- task: VSTest@2
  displayName: 'Test'
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    codeCoverageEnabled: true
    runSettingsFile: '$(Build.SourcesDirectory)\test\test.runsettings'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mayankbansal018commented, Oct 10, 2019

@nkristek we have identified this issue, & it’s happening because in the latest SDK we also drop testhost.dll along with the test assembly. Now since your test filter says to pick any test..dll we also try to run test for testhost.dll which is failing abruptly. We apologize for this, & we have already raised a PR to fix this https://github.com/microsoft/vstest/pull/2206

To help you mitigate it for now we recommend that you either downgrade the SDK version, or modify your test filter to exclude testhost*.

1reaction
nibeditadancommented, Aug 4, 2020

Yes I updated to newest version. It is working fine

On Tue, 4 Aug, 2020, 7:33 PM Rob Smitha, notifications@github.com wrote:

Removing AnyCPU from my unit test project’s csproj fixed this issue for me and my tests are running in the pipeline. I’m thinking this AnyCPU PlatformTarget setting would default to x64 on the build server causing a mismatch in bitness, therefore the library found was mismatched. Hope this helps someone.

netcoreapp2.1 Runtime: 2.1.19 win10-x86 Microsoft.NET.Test.Sdk 16.6.1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/vstest/issues/2218#issuecomment-668615686, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGQE5CS633SCBWUCREZX7CTR7AIL7ANCNFSM4I6RUDQQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Test failing in Pipelines with missing 'Microsoft.NET. ...
The problem comes when I add the test step. Also, using the standard Azure Repos build template runs perfectly, but won't run the...
Read more >
Failed Tests in DevOps Pipeline due to "could not find ...
Hi , I am facing the below issue while deploying my Azure Functions. There are tests written in the pipeline which are failing...
Read more >
VSTest@2 - Visual Studio Test v2 task
Use this task to run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VSTest) runner.
Read more >
Unit tests not detected in .NET Core test project with Microsoft ...
NET Core 2.1 test project using either NUnit (3.12.0) or xUnit (2.4.1); Ensure the Microsoft.NET.Test.Sdk NuGet package is at version 16.3.0 or higher....
Read more >
Errors running Unit Tests in Azure Pipeline #7911
This one is resolved now. I updated Microsoft.NET.Test.Sdk to 16.3.0 (from 16.2.0). This changed the error messages, which led me ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found