2016-07-15 30 views
1

は2.5.0にバージョン9.0.0とReactJS.NetパッケージにNewtonsoft.Jsonをアップグレードした後、TransformBabel.projは動作を停止:MSBuildの参照を見つけることができません - ReactJs.NET

次を返す
<?xml version="1.0" encoding="utf-8" ?> 
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="TransformBabel"> 
     <!-- ReactJS.NET - Transpile JavaScript via Babel --> 
     <UsingTask AssemblyFile="$(OutputPath)\React.MSBuild.dll" TaskName="TransformBabel" /> 
     <Target Name="TransformBabel"> 
      <TransformBabel SourceDir="$(MSBuildProjectDirectory)" /> 
     </Target> 
    </Project> 

を:

TransformBabel.proj(6, 3): error MSB4018: The "TransformBabel" task failed unexpectedly. 
[Exec] TransformBabel.proj(6, 3): error MSB4018: React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.IReactSiteConfiguration ---> System.TypeInitializationException: The type initializer for 'React.ReactSiteConfiguration' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. 

Newtonsoft 6.0.0.0のバージョンを読み込めないようです。 web.configファイルは、アセンブリのリダイレクトがあります。

<dependentAssembly> 
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> 
    </dependentAssembly> 

をしかし、私はそれが無視されている場合、それは、新しいMSBuildのプロセスを開始しているように、ということを確認していません。私はアセンブリの場所をmsbuildに伝えたいが、今までは成功していない。

+0

Newtonsoft.Json.dllは '$(OutputPath)'に存在しますか? – KMoraz

+0

@KMorazはい、バージョン6.0.0.0ではありません。 –

+0

これはそのエラーを説明しています。 React.MSBuild.dllをプロジェクトの出力パスではなく、その起点から消してください。 [usage](https://github.com/babel/babel.github.io/blob/845d86b6c08dbc066859ad9611b554f606801d41/_includes/tools/msbuild/usage.md)を参照してください。 – KMoraz

答えて

1

ここでパーティーに少し遅れましたが、うまくいけば私の経験は同じ問題を抱えている他の誰かに役立つでしょう。

私は最近、React.MSBuild 3.1.0.と同じ問題を経験しました。Newtonsoft.JsonをNuGetを使用して最新(10.0.3)にアップデートしてリダイレクトを正しく設定したため、特定のバージョンがハードコードされているようですが、あなたが言ったのと同じエラーです。

私がやったことは、単純に全く反応したパッケージ(のMSBuildとコア)ともNewtonsoft.Json(他の依存関係があったとして-forceを使用して)をアンインストールしてから、NuGetが再びReact.MSBuildをインストールしてみましょうさ。それはすべての依存関係を持ってインストールされました。Newtonsoft.Json 9.0.1.

Newtonsoft.Jsonライブラリを特定のバージョンに制限する理由はわかりませんが、開発者を反応させるのはもっと問題です。最新の(または他の特定のバージョン)が必要な場合を除き、これで問題は解決されます。

+0

私はあなたの助けに感謝しますが、Newtonsoft.Jsonのバージョン10以上が必要なので、問題は解決しません。ベスト! –

0

私は、これは古い記事です知っている...しかし、ここに私の問題を回避するには、次のとおりです。

私はプロジェクトディレクトリにToolsの相対ディレクトリにNewtonsoft.Json.dll v6.0.0.0を入れて、TransformBabelタスクの条件を満たすように$(OutputPath)にMSBuildのは、それをコピーしてみましょう。
TransformBabel.projは、次のようになります。v8.0.3:このTransformBabelタスクが完了する

<?xml version="1.0" encoding="utf-8" ?> 
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="TransformBabel"> 
    <!-- ReactJS.NET - Transpile JavaScript via Babel --> 
    <UsingTask AssemblyFile="$(OutputPath)\React.MSBuild.dll" TaskName="TransformBabel" /> 
    <Target Name="TransformBabel"> 
    <Copy SourceFiles="$(MSBuildProjectDirectory)\Tools\Newtonsoft.Json.dll" DestinationFolder="$(OutputPath)" /> 
    <TransformBabel SourceDir="$(MSBuildProjectDirectory)" /> 
    </Target> 
</Project> 

た後で、MSBuildのは、私のプロジェクトは、実際に、EXを使用しているものは何でもNewtonsoft.Json.dllバージョンで$(OutputPath)Newtonsoft.Json.dll v6.0.0.0を上書きしてみましょう。

<ItemGroup> 
    ... 
    <Reference Include="React.MSBuild, Version=2.3.0.0, Culture=neutral, PublicKeyToken=9aed67b161f7db78, processorArchitecture=MSIL"> 
    <HintPath>Tools\React.MSBuild.dll</HintPath> 
    <Private>True</Private> 
    </Reference> 
    ... 
</ItemGroup> 
... 
<ItemGroup> 
    ... 
    <Content Include="Tools\Newtonsoft.Json.dll" /> 
    <Content Include="Tools\React.MSBuild.dll" /> 
    ... 
</ItemGroup> 
... 
<Target Name="TransformBabel" AfterTargets="Build"> 
    <Exec Command="&quot;$(msbuildtoolspath)\msbuild.exe&quot; $(ProjectDirectory)TransformBabel.proj /p:OutputPath=$(OutputPath) /nr:false" /> 
</Target> 

<Target Name="AfterTransformBabel" AfterTargets="TransformBabel"> 
    <Copy SourceFiles="..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll" DestinationFolder="$(OutputPath)" /> 
</Target> 

は、あなたのニーズに AfterTransformBabelタスク内のパス Newtonsoft.Json.8.0.3を交換してください:
だから、メインプロジェクト .csprojに、私はこのような何かを持っています。

関連する問題