-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
We are requesting a documented feature or MSBuild property that allows users to explicitly ignore an existing packages.lock.json file during the NuGet restore process.
Scenario
We operate projects in two distinct modes:
- "Package Mode": The default, where a committed
packages.lock.jsonfile is used to lock internal, floating-version package references, ensuring deterministic historical builds. - "Project Mode": A specific
Condition(detected by solution name) where we switch fromPackageReferencetoProjectReferencefor internal dependencies (e.g., in a monolith or Aspire application). In this mode, the lock file should be entirely ignored, as direct project references supersede it.
Problem
In previous tooling versions, simply not defining RestorePackagesWithLockFile allowed us to ignore the on-disk lock file seamlessly. In recent .NET SDK and NuGet versions, the presence of a packages.lock.json file automatically triggers validation and modification (adding "type": "Project" entries) during the solution restore phase in Visual Studio and the CLI. This breaks our mode-switching capability and pollutes the repository with unwanted file changes.
Desired Behavior
We require a reliable mechanism (an MSBuild property like <NuGetIgnoreLockFile>true</NuGetIgnoreLockFile>) to disable the lock file feature entirely for a specific restore operation, even if the packages.lock.json file exists on disk.
This would allow us to restore the previous seamless behavior using existing MSBuild property conditions (Directory.Build.props), avoiding complex file-renaming hacks or wrapper scripts that fall outside of standard Microsoft tooling and IDE integration.