'Running Visual Studio 2019 unit tests in Azure Dev Ops on Linux agent

Similar to this question but a bit more info and maybe it is different.

I have a Test project that uses Microsoft.VisualStudio.TestTools.UnitTesting for typical unit test stuff ([TestClass],[TestInitialize()], [TestCase], Category("SMOKE")] etc). I can create an Azure Dev Ops (ADO) pipeline with Visual Studio tasks and Visual Studio Test tasks and everything is fine when ran on Windows (in Net Framework 4.6.1 and NetCore3.1). However those tasks don't work when using a Linux Agent (made for Windows only). I swap out the Visual Studio Build with a "dotnet build" task and set the --framework netcoreapp3.1 (because need NetCore to run on Linux). Before that step, I do a Nuget Restore on the project before. still get the error in the dotnet build task: Error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?). My next step would be dotnet test but I get the same error.

I don't know what I am doing wrong here as I can get Windows working just fine and that is what I am used to so I could be overlooking something that is obvious to Linux people.

Bottom line, I want to be able to run the same tests on Windows and on Linux. I can't even get the test projects to build and I haven't even started to try running the tests so I feel I have a long road ahead.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source