Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

Install-Package angularjs.TypeScript.DefinitelyTyped

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:

C:\Users\.k\packages\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:

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

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

like image 700
Daan van Hulst Avatar asked Apr 22 '15 14:04

Daan van Hulst


People also ask

How do I use TypeScript in .NET core?

Create an ASP.NET Core project. Add the NuGet package for TypeScript support. Add some TypeScript code. Run the app.

How do I install Microsoft TypeScript MSBuild?

right-click the project node and choose Manage NuGet Packages. In the Browse tab, search for Microsoft. TypeScript. MSBuild, and then click Install on the right to install the package.

How use NuGet package in asp net core?

Right-click the folder in the project, and then select Add Packages… Select the NuGet.org from the Package source drop-down. The Syncfusion ASP.NET Core NuGet packages are listed and available. Search and install the required packages in your application, by clicking the Add Package button.

What is the purpose of the NuGet package manager in asp net core?

The NuGet Package Manager will download and install the ASP.NET Core and will update the project. json file and the associated references.


1 Answers

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

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. Feel free to create new issue in NugetAutomation on GitHub.

like image 141
Max Brodin Avatar answered Sep 28 '22 16:09

Max Brodin