Typescript Recovery Defining Nuget Packages

I am currently working on a new project that uses Typescript for all client side code. I am using several pure JavaScript libraries to make them work with my Typescript. I used Nuget to download * .d.ts files using the following package manager commands.

An example of a package manager command:

Install-Package angularjs.TypeScript.DefinitelyTyped -Version 2.0.2

This works and after installing all my Nuget packages, a packages.config file is created in the project directory :

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="angularjs.TypeScript.DefinitelyTyped" version="2.0.2" targetFramework="net45" />
  <package id="angular-translate.TypeScript.DefinitelyTyped" version="0.9.0" targetFramework="net45" />
  <package id="bootstrap.TypeScript.DefinitelyTyped" version="0.0.9" targetFramework="net45" />
  <package id="jquery.TypeScript.DefinitelyTyped" version="1.4.0" targetFramework="net45" />
</packages>

      

My Visual Studios project now has the following directories after installing packages:

Scripts\
    typings\
        angularjs\         (contains relivant files)
        angular-translate\ (contains relivant files)
        bootstrap\         (contains relivant files)
        jquery\            (contains relivant files)

      

Now my problem is when someone tries to clone my repos, visual studios will try to restore Nuget packages automatically, but install them like this:

Packages\
   angularjs.TypeScript.DefinitelyTyped.2.0.2\
       Content\
           Scripts\
               typings\
                   angularjs\ (contains relivant files)

   angular-translate.TypeScript.DefinitelyTyped.0.9.0\
       Content\
           Scripts\
               typings\
                   angularjs\ (contains relivant files)

   bootstrap.TypeScript.DefinitelyTyped.0.0.9\
       Content\
           Scripts\
               typings\
                   angularjs\ (contains relivant files)

   jquery.TypeScript.DefinitelyTyped.1.4.0\
       Content\
           Scripts\
               typings\
                   angularjs\ (contains relivant files)

      

I've read several stackoverflow threads and Nuget documentation, but really can't seem to find a solution where I can run the command on the new repo machine and it will revert the files back to the configuration I had on the original machine.

Ideally, I would like to avoid having to write and a * .bat file that transforms the file structure the way I want.

+3


source to share


1 answer


I believe you are running into one of Nuget 's common misconceptions . The problem here is that (Automatic) Nuget Restore is not the same as Install-Package. The purpose of Nuget recovery is to download and unpack packages. It will not restore the contents of your projects or solution folders. Read the article for more details on why. There are a lot of people in this behavior, but this is the choice of the Nuget developers.

A number of solutions are mentioned in the comments to this issue . I personally use Install-Package MSBuild.NugetContentRestore

which is all I need to resolve content file issues.



Hope it helps.

+3


source







All Articles