using nuget.exe commandline to install dependency

前端 未结 1 1567
不思量自难忘°
不思量自难忘° 2021-01-04 01:52

I want to use nuget.exe (version 2.5) in my CI build pipeline to install a package which has dependency to another package.

I have following nuspec file.

<         


        
1条回答
  •  北海茫月
    2021-01-04 02:09

    This is not possible. The behavior of the packages.config file is by design. Only things specified in the packages.config are installed, not their dependencies. All dependencies must be explicitly specified as well.

    If you look at the source code you will see that nuget.exe install packages.config (http://nuget.codeplex.com/SourceControl/latest#src/CommandLine/Commands/InstallCommand.cs) uses PackageExtractor.InstallPackage (http://nuget.codeplex.com/SourceControl/latest#src/CommandLine/Common/PackageExtractor.cs):

    public static void InstallPackage(IPackageManager packageManager, IPackage package)
        {
            var uniqueToken = GenerateUniqueToken(packageManager, package.Id, package.Version);
            // Prerelease flag does not matter since we already have the package to install and we ignore dependencies.
            ExecuteLocked(uniqueToken, () => packageManager.InstallPackage(package, ignoreDependencies: true, allowPrereleaseVersions: true));
        }
    

    Note the hard call to ignoreDependencies: true

    0 讨论(0)
提交回复
热议问题