【问题标题】:MSBuild and package restore with packages.config使用 packages.config 进行 MSBuild 和包还原
【发布时间】:2018-02-23 21:03:30
【问题描述】:

仅当项目仍在使用 packages.config 时,是否可以在构建期间使用 MSBuild 恢复包?

【问题讨论】:

    标签: msbuild nuget-package


    【解决方案1】:

    https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target

    MSBuild 16.5+ 还支持 packages.config 格式。

    用途:

    msbuild -p:RestorePackagesConfig=true -t:restore
    msbuild -t:build
    

    【讨论】:

      【解决方案2】:

      根据文档[1]:

      restore 目标仅适用于使用 PackageReference 的项目 格式。它适用于使用 packages.config 的项目 格式;请改用 nuget restore。

      因此,您将不得不改用nuget.exe restore。看看我的另一个answer

      [1]https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets

      【讨论】:

        【解决方案3】:

        据我在https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore 上看到的,这是可能的:

        MSBuild:使用 msbuild /t:restore 命令恢复项目文件中列出的包包(仅限 PackageReference)。仅适用于 NuGet 4.x+ 和 MSBuild 15.1+,它们包含在 Visual Studio 2017 中。nuget restoredotnet restore 都将此命令用于适用的项目。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-07-31
          • 1970-01-01
          • 1970-01-01
          • 2017-04-19
          • 2014-04-13
          • 2018-04-20
          • 2015-07-06
          • 2018-03-28
          相关资源
          最近更新 更多