我是Xunit的新手,我正试图通过MSBuild运行它。在disallows wildcard origin in CORS之后,到目前为止,这是我的构建脚本:
<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>
但是,当我在.csproj上运行MSBuild时,它会给我以下错误:
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'.
我已经检查了它正在寻找的路径,我也遵循了documentation步骤。然而,没有运气。我该怎么做才能解决这个问题?
答案 0 :(得分:0)
此错误通常是由于MSBuild工具版本不匹配造成的。这在<Project>
根元素中定义。您运行的工具版本来自ITask界面的不同于xunit runner的版本,因此没有装配绑定重定向,它不能在不同版本的ITask之间进行转换。