Jam*_* Ko 6 .net c# msbuild xunit xunit.net
我正在尝试通过MSBuild运行我的第一个xUnit.net测试,我在这里遵循文档.这是我的项目文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build;Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.msbuild.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.runner.msbuild.props"
Condition="Exists('..\packages\xunit.runner.msbuild.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.runner.msbuild.props')" />
<!--Extra lines omitted for brevity-->
<UsingTask AssemblyFile="xunit.runner.msbuild.dll"
TaskName="Xunit.Runner.MSBuild.xunit"/>
<Target Name="Test">
<xunit Assembly="bin\$(Configuration)\Core.dll"/>
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud)
但是,当我运行MSBuild时,它会给我以下错误:
C:\Users\James\libvideo\tests\Core\Core\Core.csproj(85,5):
error MSB4127: The "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'.
Run Code Online (Sandbox Code Playgroud)
我已经检查过拼写是否正确,但它仍然给我这个错误.xUnit.net文档没有说明这一点(或者至少从我看过的地方),所以我现在无法做什么.它告诉我,我可以检查程序集的MSBuild版本,但是我该怎么做?MSBuild甚至需要构建程序集吗?
(MSBuild说这是版本14.0.23107.0,如果这很重要,我有VS2015.)
谢谢!
小智 6
MSBuild基于任务和目标.您可以在.csproj中查看它的外观,通常在最后.任务对象在您正在使用的MSBuild版本中定义,例如,位于C:\Program Files (x86)\MSBuild\12.0\Bin
.
MSBuild的版本通常遵循.NET框架,如下所示:
version 1.0: 2006
version 2.0:
version 3.5: 2011
Run Code Online (Sandbox Code Playgroud)
您可能错过了正确版本的MSBuild.或者您可以尝试使用不同的版本ToolsVersion="14.0"
.
归档时间: |
|
查看次数: |
18555 次 |
最近记录: |