azure-devopsnuget-packageazure-pipelinesvisual-studio-cordova

How to install packages to Scrip folder


I have my app (Tools for Apache Cordova) in Azure DevOps. I want to build the app in Azure DevOps. I added NuGet Tool Installer and NuGet restore tasks.

But NuGet restores tasks and put files in packages folder only (for example AngularJs).

In Microsoft Visual Studio I use Update-Package -reinstall command in Package Manager Console for put files to the "scripts" folder. and those files are had references by other ts files.

How can I rewrite command Update-Package -reinstall to Azure DevOps task?

I tried to add NuGet custom task with command install. It's working without error even not found packages.

UPD:

packages and scripts have different hierarchy


Solution

  • How can I rewrite command Update-Package -reinstall to Azure DevOps task?

    First, you could not use this command line Update-Package -reinstall to Azure DevOps task. That because package manager console is providing is access to visual studio objects:

    https://github.com/NuGet/Home/issues/1512

    So, we could not use the Package manager console powershell outside visual studio.

    How to install packages to Scrip folder

    Since nuget restore task only restores files in the packages directory (\packages folder ), but does not restore files inside your project or otherwise modify your project. We have to copy those .js to the /scripts folder manually.

    To resolve this issue, we could add a copy task to the Azure DevOps after nuget restore to copy those files from /packages folder to the /scripts folder. Or you could add those .js to the source control.

    Besides, the usage of NuGet for css/javascript libraries is discouraged. You should use the npm (Node Package Manager) to add the JavaScript libraries instead of using NuGet.

    Nuget Problems Downloading Scripts

    If you are interested, please see this document and this document for some more details.

    Hope this helps.