ASP.NET Core project.json importsってどういう意味ですか?

3758 ワード

サンプルコード:
"frameworks": { 
    "netcoreapp1.0.0": { "imports" : "portable-net45+win81" } 
} 
imports is a way to use packages that were not designed for that framework. Basically you tell it "Use those targets even though they don't seem to be supported. I know what I'm doing".
注意:Frameworks and imports sections in projectから抜粋します.json: what are they?
上の説明はどういう意味ですか.importsはパッケージを使用する方法の一つです.このようなフレームワークのために設計されているわけではありませんが、基本的には「これらのターゲットフレームワークを使用して、サポートされていないように見えても、私は何をしているか知っています」と教えてくれます.翻訳は硬く、importsの役割は各プラットフォーム間の互換処理であり、サポートされていないパッケージを対象としています.
概念理解にはまだ問題があるので、次の解釈を見てみましょう.
抜粋:What it says right here is that I’m targeting the netcoreapp 1.0 framework (which is the default framework for a .NET Core application). With the “imports” bit I’m also stating that any dependency I want to include that targets dnxcore50 should be treated as compatible with netcoreapp1.0. Basically I’m instructing the tooling to ignore the fact that dnxcore50 isn’t the same thing as netcoreapp1.0 because I know it is the same thing (or more precisely Microsoft knows that they are the same).
翻訳:ターゲットフレームワークプラットフォームがnetcoreapp 1である場合、説明する必要があります.0,imports dnxcore50を用いる、netcoreapp 1を使用することができる.0はdnxcore 50プラットフォームと互換性があり、netcoreapp 1を無視する.0はdnxcore 50とは異なる事実です.私はそれが同じことであることを知っています(または、より正確なMicrosoftは彼らが同じであることを知っています).
例としてWebApi.Clientパッケージは、それぞれnetcoreapp 1を実現する.0とnet 451のプラットフォームバージョン(コードはまったく同じで、ベースのプラットフォームが異なるだけ)で、netcoreapp 1というアプリケーションがあります.0プラットフォームで、net 451プラットフォームのWebApiを参照します.Clientパッケージは、VS 2015でプラットフォームエラーをサポートしていないと報告されます.2つのプラットフォームバージョンのコードは完全に同じですが、プラットフォームをまたいで飲むことはできません.importsはこの問題を解決し、VS 2015にこのエラーを無視させます.
抜粋:A word of warning is in order here though.Theoretically I could “import” any framework that’s currently out there I can install pretty much any package into my project. However, that doesn’t mean that my application will actually run and work. If a package I installed into my project is using an API that’s not available on the platform that my application will be running on it will simply fail at runtime. Therefore you should be careful when using “imports” and make sure that you test your application properly on the actual framework it will be running on. Think of it as when you’re using “imports” you’ve turned off the tooling and you are on your own and its your job to make sure that your application works correctly.
ここで警告します.理論的には、importsの任意のフレームワークプラットフォームをインストールし、すべてのプラットフォームのパッケージをインストールすることができます.しかし、これは私のアプリケーションが実際に実行され、動作できるという意味ではありません.もし私がプロジェクトのパッケージにインストールしたら、このプラットフォームでAPIが使用できないので、私のアプリケーションは実行時に失敗します.したがって、importsを使用する場合は、プラットフォームフレームワーク上でアプリケーションが実際に正常に動作することを確認することに注意してください.想像してみてください.importsを使用すると、VS 2015のヒントを閉じて、正常に動作していることを確認します.
例としてWebApi.Clientパッケージは、それぞれnetcoreapp 1を実現する.0とnet 451のプラットフォームバージョン(コードは全く異なり、内部実装では異なるプラットフォームを使用するAPIが実装されている)、その後、netcoreapp 1というアプリケーションがある.0プラットフォームで、net 451プラットフォームのWebApiを参照します.Clientパッケージは、imports net451を使用する必要があり、VS 2015でコンパイルするのは全く問題ありませんが、netcoreapp 1.0プラットフォームが実際に稼働すると、異なるプラットフォームのWebApiがエラーになります.Clientパッケージは、異なるプラットフォームのAPIを使用しています.
注:抜粋:NET Platform Standard and the magic of “imports”
翻訳が下手ですが、大体の意味は分かりました.総じて言えば、importsを使って、VS 2015でプラットフォームがサポートしていないエラーメッセージを解決しただけですが、実際に正常に運行しているとは限らないので、実際の運行環境で、他のプラットフォームのパッケージを引用して、実行に問題があるかどうかをテストします.