Converting from NuGet
Automatic NuGet conversion
Paket comes with a command that helps to convert existing solution from NuGet's
packages.config format to Paket's format.
- Please start by making a backup of your repository
- Download Paket and it's bootstrapper as described in the "Get started" tutorial
- Run the
convert-from-nugetcommand:
1:
|
|
Or if you're not using .NET Core:
1:
|
|
Read more about the details and parameters for
convert-from-nuget.
Preparation
Choose a directory to run the conversion from that is parent to all the projects to be converted.
When NuGet package restore is enabled, the packages directory is located next
to the solution. It is also possible that the parent directory of packages is
not also parent to all the projects in the solution.
A solution is effectively acting as a symlink, but this indirection via the
solution is not possible with Paket because Paket manages projects and not
solutions. In the example below, it would not be possible to run the
paket convert-from-nuget command from the Build directory but it would be
from the root directory.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: |
|
After running the conversion from the root directory:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: |
|
Command steps
The paket convert-from-nuget command:
-
Finds all
packages.configfiles, generates a paket.dependencies file in the solution root and replaces eachpackages.configwith an equivalentpaket.referencesfile. -
If there is a solution-level
packages.config, then it will be removed and its dependencies will be included in thepaket.dependenciesfile. -
If you use NuGet Package Restore (MSBuild-Integrated or Automatic Visual Studio Package Restore), then the
paket auto-restore oncommand will be invoked. -
Unless
--no-installis specified, thepaket installprocess will be executed. This will- analyze the dependencies,
generate a
paket.lockfile,-
remove all the old package references from your project files and install new references in Paket's syntax.
-
If you specify
--force, the conversion will attempt to infer additional dependencies from newly added or previously unprocessedpackages.configfiles and-
add any newly discovered dependencies to the end of an existing
paket.dependenciesfile, -
add references from the
packages.configfiles topaket.referencesfiles.
-
Migrating NuGet source credentials
If you are using authorized NuGet feeds, convert-from-nuget will automatically
migrate the credentials for you. Following are valid modes for the
--migrate-credentials option:
-
encrypt: Encrypt credentials and save them in the Paket configuration file. -
plaintext: Include credentials in plaintext in thepaket.dependenciesfile. See example. -
selective: Use this option if have more than one authorized NuGet feed and you want to apply different modes for each of them.
Simplify to direct dependencies
After converting your solution from NuGet, you may end up with many
transitive dependencies in your Paket files. Consider
using paket simplify to remove unnecessary
transitive dependencies from your
paket.dependencies and
paket.references files.
Partial NuGet conversion
convert-from-nuget will not work if it
discovers that the codebase already utilizes Paket (i.e.
paket.dependencies file is found). However, if for
some reason you happen to have a mixture of projects already migrated to Paket
and projects still using NuGet, you can pass the --force flag to
convert-from-nuget for the remaining projects.