web-dev-qa-db-ja.com

アセンブリがビルドされたMSBuildのバージョンを確認するにはどうすればよいですか?

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>

ただし、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'.

スペルが正しいことを確認しましたが、それでもこのエラーが発生します。 xUnit.netのドキュメントには、これについて(または、少なくとも私が見たところからは)何も書かれていないので、今何をすべきか悩んでいます。アセンブリがビルドされたMSBuildのバージョンを確認できると表示されますが、どうすればよいですか?アセンブリをビルドするためにMSBuildも必要ですか?

(MSBuildはバージョン14.0.23107.0だと言っていますが、それが重要な場合はVS2015を使用しています。)

ありがとうございました!

7
James Ko

MSBuildは、タスクとターゲットに基づいています。通常は最後に、.csprojでどのように表示されるかを確認できます。タスクオブジェクトは、使用しているMSBuildのバージョンで定義されており、たとえばC:\Program Files (x86)\MSBuild\12.0\Binにあります。

MSBuildのバージョンは通常、次のような.NETフレームワークに従います。

version 1.0: 2006
version 2.0:
version 3.5: 2011

おそらく、MSBuildの正しいバージョンを見逃しているでしょう。または、ToolsVersion="14.0"とは異なるバージョンで試すこともできます。

6
dolomitt