Azure-pipelines-tasks: Settting locked mode in nuget restore task to enable caching

Created on 12 May 2020  路  1Comment  路  Source: microsoft/azure-pipelines-tasks

Question, Bug, or Feature?
Type: Question

Enter Task Name: NuGetCommand

Environment

  • Server - Azure Pipelines
  • Agent - Hosted, windows-latest

Issue Description

I'm following this documentation to enable caching for the nuget restore task of my pipeline. The idea is to use the packages.lock.json file as the key to the caching task, which gets generated when the package list is updated and nuget restore is run. This should normally happen in the dev machine only, not in the CI pipeline.
To support this distinction, I see from this document that a locked mode was introduced in nuget and msbuild, which makes the restore process use packages.lock.json. When set in a pipeline, this mode prevents it from inadvertently updating the lock file, which may cause the cache task to start writing to the wrong key. If there is a mismatch between the lock file and the packages list from the project, an error is thrown instead, which is the expected behavior in a build enviroment.
Currently, I couldn't find a way of specifying the locked mode in the nuget restore task. The current behavior causes the pipeline to regenerate the lock file, which is not supposed to happen. Should there be an option to enable this locked mode in nuget restore, or am I missing some other task that is suitable for this scenario?

Artifacts question

Most helpful comment

We're phasing out the nuget restore "heavyweight" task in favor of a new flow with the NuGet Tool Installer followed by the NuGet Authenticate Task followed by a command line task to use NuGet.exe. This allows you to take advantage of the latest NuGet features without us having to re-implement them in the task. This flow should immediately allow you to use the lock file

>All comments

We're phasing out the nuget restore "heavyweight" task in favor of a new flow with the NuGet Tool Installer followed by the NuGet Authenticate Task followed by a command line task to use NuGet.exe. This allows you to take advantage of the latest NuGet features without us having to re-implement them in the task. This flow should immediately allow you to use the lock file

Was this page helpful?
0 / 5 - 0 ratings