本文介绍了如何使用NuGet程序包管理器访问ASP.NET 5中的TypeScript定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解如何访问通过NuGet软件包管理器安装的TypeScript定义文件.我使用以下命令为Angular安装了TypeScript定义文件:

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:

Install-Package angularjs.TypeScript.DefinitelyTyped

它显示在project.json文件中:

And it shows up in the project.json file:

"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:

我可以使用绝对路径来引用它,但是这行不通:

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依赖于jQuery,它将在以下位置查找

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

所以我的问题是:如何引用作为NuGet软件包安装的TypeScript定义文件?

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

推荐答案

当前 angularjs.TypeScript.DefinitelyTyped nuget包仅支持ASP.NET 4文件夹结构.它将文件放入您的〜\ Scripts \ typings \ angularjs \ 中(请参阅 nuget-automation源)文件夹中,您可以像这样从那里引用它:

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:

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

为了在ASP.NET 5中使用键入内容,您只需从 \ packages \ angularjs.TypeScript.DefinitelyTyped \ [VERSION] *.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.

P.S.随时在GitHub上的 NugetAutomation 中创建新问题.

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

这篇关于如何使用NuGet程序包管理器访问ASP.NET 5中的TypeScript定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 05:33