如何使用NuGet包管理器訪問ASP.NET 5中的TypeScript定義?

[英]How do I access TypeScript definitions in ASP.NET 5 with the NuGet package manager?


I am having trouble understanding how I can access the TypeScript definition files which I installed with the NuGet package manager. I installed the TypeScript definition files for Angular with the following command:

我無法理解如何訪問我使用NuGet包管理器安裝的TypeScript定義文件。我使用以下命令為Angular安裝了TypeScript定義文件:

Install-Package angularjs.TypeScript.DefinitelyTyped

And it shows up in the project.json file:

它出現在project.json文件中:

"dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta3",
    "Microsoft.AspNet.Mvc": "6.0.0-beta3",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta3",
    "angularjs.TypeScript.DefinitelyTyped": "3.2.5"
},

And a reference has been placed under 'References', linking to:

參考文獻已放在“參考文獻”下,鏈接到:

C:\Users\.k\packages\angularjs.TypeScript.DefinitelyTyped\3.2.5

C:\ Users \用戶.K \​​包\ angularjs.TypeScript.DefinitelyTyped \ 3.2.5

I am able to reference to this by using the absolute path, but this won't work:

我可以通過使用絕對路徑來引用它,但這不起作用:

/// <reference path="C:\Users\<user>\.k\packages\angularjs.TypeScript.DefinitelyTyped\3.2.5\Content\Scripts\typings\angularjs\angular.d.ts" />

Angular depends on jQuery, which it will look for in:

Angular依賴於jQuery,它將在以下內容中尋找:

'C:/Users//.k/packages/angularjs.TypeScript.DefinitelyTyped/3.2.5/Content/Scripts/typings/jquery/jquery.d.ts'

'C:/用戶// K /包/ angularjs.TypeScript.DefinitelyTyped / 3.2.5 /內容/腳本/分型/ jquery的/ jquery.d.ts'

So my question is: how can I reference to TypeScript definition files installed as a NuGet package?

所以我的問題是:如何引用作為NuGet包安裝的TypeScript定義文件?

1 个解决方案

#1


11  

Currently angularjs.TypeScript.DefinitelyTyped nuget package supports only ASP.NET 4 folders structure. It puts files in your ~\Scripts\typings\angularjs\, (see nuget-automation source) folder you can reference it from there like this:

目前angularjs.TypeScript.DefinitelyTyped nuget包僅支持ASP.NET 4文件夾結構。它將文件放在〜\ Scripts \ typings \ angularjs \中,(參見nuget-automation source)文件夾,你可以從那里引用它,如下所示:

/// <reference path="../scripts/typings/angularjs/angular.d.ts" />

In order to use typings in ASP.NET 5 you have to just copy *.d.ts files from \packages\angularjs.TypeScript.DefinitelyTyped\[VERSION] to any folder accessible from your project and change reference path accordingly.

為了在ASP.NET 5中使用輸入法,您只需將* packages \ angularjs.TypeScript.DefinitelyTyped \ [VERSION]中的* .d.ts文件復制到可從項目訪問的任何文件夾,並相應地更改參考路徑。

P.S. Feel free to create new issue in NugetAutomation on GitHub.

附:隨意在GitHub上的NugetAutomation中創建新問題。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/04/22/390069305533239c43dbd632daddc5cc.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com