Error CS0234 when creating a solution using TFS 2017 BuildAgent

I ran into the following problem when I was trying to build using the TFS build definition.

When executing assembly for assembly, the agent logs the following errors:

Error CS0234: The type or name of the VisualStudio namespace does not exist in the Microsoft namespace (do you miss the assembly reference?)

Error CS0246: the type name or namespace name 'TestInitializeAttribute' could not be found (do you miss the using directive or assembly references?)

Error CS0246: The type or name of the TestCleanupAttribute namespace could not be found (are you missing the using directive or assembly references?)

Error CS0246: The type or name of the TestCleanup namespace could not be found (are you missing the using directive or assembly references?)

Error CS0246: The type or name of the TestMethodAttribute namespace could not be found (are you missing the using directive or assembly references?)

So, I understand the message in such a way that buildAgent cannot find the following .dll

Microsoft.VisualStudio.TestTools.UnitTesting;

I installed Visual Studio 2017 RC and Visual Studio 2017 Build Tools on a server that runs TFS and Buildagents.

I also installed .net 4.6.1 on this machine.

This accepted answer is not a solution for me.

There must be some solution that does not include in order to copy this dll to the git trunk and reference it from there.

Update

I can locally build the solution using Visual Studio 2017 RC on this machine. But the build agent still causes the same errors.

+6
source share
2 answers

I finally figured out how to solve this problem.

I added the following nuget package as a reference to my project:

https://www.nuget.org/packages/MSTest.TestFramework/

This is the mstestv2 Framework.

Subsequently, I had to remove the old link to the mstestv1 framework.

Build errors have disappeared.

Update:

If you want to test your tests, add the MSTest TestAdapter to your project.

Thanks Maciej for this info.

+10
source

I changed the target structure from 4.7 to 4.6.1 in VS 2017, and was fixed

+1
source

Source: https://habr.com/ru/post/1015336/


All Articles