0
votes

I have an Azure Function v1 that has working build and release pipelines in Azure DevOps. There hasn't been any unit tests yet, until now. Tests run smoothly on my local Visual Studio 2019. But I can't make them run on build pipeline in Azure DevOps.

I am using Visual Studio build, not dotnet.exe, in build pipeline because that is how I've made it work there.

When I try to add dotnet test, there will be following error:

...\Roslyn\Microsoft.CSharp.Core.targets(59,5): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc"
task could not be loaded from the assembly ...\Roslyn\Microsoft.Build.Tasks.CodeAnalysis.dll.
Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct,
that the assembly and all its dependencies are available, and that the task contains
a public class that implements Microsoft.Build.Framework.ITask.

When I try to run tests with Visual Studio Test I get following error:

"An exception occurred while invoking executor 'executor://mstestadapter/v2':
Method 'get_DataRow' in type 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation'
from assembly 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation."

What should I do to make my build pipeline run my tests for Azure Function v1?

2
Which Unit Test framework are you using? Have you added the NuGet package Microsoft.NET.Test.Sdk? If so, which version?rickvdbosch
Test framework is MSTest. I have nuget package Microsoft.NET.Test.Sdk 16.3.0. And MSTest.TestAdapter are MSTest.TestFramework both 2.0.0.Lassi Autio

2 Answers

2
votes

Solution was to downgrade MSTest.TestAdapter and MSTest.TestFramework nugets from 2.0.0 to 1.4.0 and tests started to run (and passed also).

1
votes

You need to add the Visual Studio Test task:

Visual Studio Test