Since there is no target to run MSTest for MSBuild you have to do some work at your own to get this working. So first i did some basic setup:And here is the target to run the Test:
The @(TestAssemblies->'/testcontainer:"%(FullPath) part transforms all the items from TestAssemblies into a single string with the string /testcontainer in front of each item. The ‘ ‘ right before the closing bracket will separate each item with a blank.
If you want to run MSTest with each Dll separately you can use a feature from MSBuild called Batching:
The tricky part is escaping the Command right so that everything is still running even if you have spaces in the directory names. I didn’t gave the name of the resultfile here because MSTest throws an error when it starts an the resultfile already exists. So i just let MSTest handle the naming of the resultfile.
More infos on MSBuild Batching can be found here.
A good Book wich covers MSBuild is this one from MS Press.