简体   繁体   中英

XUnit doesn't work during MSBuild

I'm a newcomer to Xunit and I'm trying to run it via MSBuild. Following the documentation , here is my build script so far:

<UsingTask AssemblyFile="..\packages\xunit.runner.msbuild.*\build\*\xunit.runner.msbuild.dll"
           TaskName="Xunit.Runner.MSBuild.xunit"/>
<Target Name="Test">
    <xunit Assemblies="bin\$(Configuration)\Core.dll"/>
</Target>

When I run MSBuild on the .csproj, however, it gives me the following error:

error MSB4127: The "Xunit.Runner.MSBuild.xunit" task could not be instantiated from the
assembly "C:\Users\James\libvideo\tests\Core\packages\xunit.runner.msbuild.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.runner.msbuild.dll".
Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework
assembly as the one installed on your computer and that your host application is not missing
a binding redirect for Microsoft.Build.Framework. Unable to cast object of type
'Xunit.Runner.MSBuild.xunit' to type 'Microsoft.Build.Framework.ITask'.

I've checked that the path it's looking for exists, and I've also followed the steps here . No luck, however. What can I do to resolve this?

This error is normally due to a mismatch in your MSBuild Tools Version. This is defined in the <Project> root element. The tools version you are running is from a version of the ITask interface different from that of the xunit runner so without an assembly binding redirect, it cannot cast between the different versions of ITask.

https://msdn.microsoft.com/en-us/library/bb383796.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM