NuGet 2.7 发行说明NuGet 2.7 Release Notes

Nuget 2.6.1 for WebMatrix 发行说明 | nuget 2.7.1 发行说明NuGet 2.6.1 for WebMatrix Release Notes | NuGet 2.7.1 Release Notes

NuGet 2.7 于8月 22 2013 日发布。NuGet 2.7 was released on August 22, 2013.

致谢Acknowledgements

我们想感谢以下外部参与者对 NuGet 2.7 的重大贡献:We would like to thank the following external contributors for their significant contributions to NuGet 2.7:

  1. Mike Roth(@mxrss)Mike Roth (@mxrss)
    • 列出包时显示许可证 url, 详细信息详细说明。Show License url when listing packages and verbosity is detailed.
  2. Adam Ralph(@adamralph)Adam Ralph (@adamralph)
    • #1956 -将 developmentDependency 属性添加packages.config到中, 并将其用于 pack 命令中, 以仅包含运行时包#1956 - Add developmentDependency attribute to packages.config and use it in pack command to only include runtime packages
  3. Rafael Nicoletti(@tkrafael)Rafael Nicoletti (@tkrafael)
    • 避免在 nuget.exe 包命令中出现重复的属性键。Avoid duplicate Properties key in nuget.exe pack command.
  4. Ben Phegan(@BenPhegan)Ben Phegan (@BenPhegan)
    • #2610 -将计算机缓存大小增加到200。#2610 - Increase machine cache size to 200.
  5. Slava Trenogin(@derigel)Slava Trenogin (@derigel)
    • #3217 -修复在错误的选项卡中显示更新的 NuGet 对话框#3217 - Fix NuGet dialog showing updates in the wrong tab
    • 修复项目。在 ProjectManager 中, TargetFramework 可以为 nullFix Project.TargetFramework can be null in ProjectManager
    • #3248修复了不存在的 packageId 上的 SharedPackageRepository FindPackage/FindPackagesById 将失败#3248 - Fix SharedPackageRepository FindPackage/FindPackagesById will fail on non-existent packageId
  6. 古柯 Boyle(@kevfromireland)Kevin Boyle (@kevfromireland)
    • #3234 -启用对 Nomad 项目的支持#3234 - Enable support for Nomad project
  7. Corin Blaikie(@corinblaikie)Corin Blaikie (@corinblaikie)
    • 在文件不存在时, #3252修复推送命令失败, 退出代码为0。#3252 - Fix push command fails with exit code 0 when file doesn't exist.
  8. 圣马丁 VeselýMartin Veselý
    • 当项目引用数据库项目时, #3226 -修复 BindingRedirect 命令中的 bug。#3226 - Fix bug with Add-BindingRedirect command when a project references a database project.
  9. Miroslav Bajtos(@bajtos)Miroslav Bajtos (@bajtos)
    • #2891 -修复 nuget 的 bug。不正确地对 "exclude" 特性中的通配符进行分析。#2891 - Fix bug of nuget.pack parsing wildcard in the 'exclude' attribute incorrectly.
  10. Justin Dearing(@zippy1981)Justin Dearing (@zippy1981)
    • 在还原包时NuGet.targets , #3307 修复 bug 不会将 $ (Platform) 传递给 nuget.exe。#3307 - Fix bug NuGet.targets does not pass $(Platform) to nuget.exe when restoring packages.
  11. Brian FedericiBrian Federici
    • #3294 -修复 nuget.exe 包命令中的 bug, 该命令允许添加名称相同但大小写不同的文件, 最后导致 "项已存在" 异常。#3294 - Fix bug in nuget.exe package command which would allow adding files with the same name but different casing, eventually causing "Item already exists" exception.
  12. Daniel Cazzulino(@kzu)Daniel Cazzulino (@kzu)
    • #2990 -将版本属性添加到 NetPortableProfile 类。#2990 - Add Version property to NetPortableProfile class.
  13. David SimnerDavid Simner
    • #3460 -修复 bug NullReferenceException if requireApiKey = true, 但标头 X-APIKEY 不存在#3460 - Fix bug NullReferenceException if requireApiKey = true, but the header X-NUGET-APIKEY isn't present
  14. Michael Friis(@friism)Michael Friis (@friism)
    • #3278 -将 NuGet 版本文件修复为, 以使其在 MonoDevelop 上正常工作#3278 - Fixes NuGet.Build targets file to so that it works correctly on MonoDevelop
  15. Pranav Krishnamoorthy(@pranav_km)Pranav Krishnamoorthy (@pranav_km)
    • 通过提高并行度提高还原命令性能Improve Restore command performance by increasing parallelization

版本中值得注意的功能Notable features in the release

NuGet 2.7 引入了一种新的包还原方法, 还克服了重大障碍:包还原许可默认情况下已启用!NuGet 2.7 introduces a new approach to package restore, and also overcomes a major hurdle: Package restore consent is now on by default! 新方法和隐式许可的组合可大大简化包还原方案。The combination of the new approach and the implicit consent will drastically simplify package restore scenarios.

对于 NuGet 版本2.0、2.1、2.2、2.5 和 2.6, 用户需要在生成过程中显式允许 NuGet 下载缺少的包。With NuGet versions 2.0, 2.1, 2.2, 2.5, and 2.6, users needed to explicitly allow NuGet to download missing packages during build. 如果未显式指定此许可, 则已启用包还原的解决方案在用户授予同意之前无法生成。If this consent had not been explicitly given, then solutions that had enabled package restore would fail to build until the user had granted consent.

从 NuGet 2.7 开始, 默认启用包还原许可, 同时允许用户在需要时使用 NuGet 的 "设置" 中的复选框明确选择退出包还原。Starting with NuGet 2.7, package restore consent is ON by default while allowing users to explicitly opt out of package restore if desired, using the checkbox in NuGet's settings in Visual Studio. 此隐式同意更改会影响以下环境中的 NuGet:This change for implicit consent affects NuGet in the following environments:

  • Visual Studio 2013 预览版Visual Studio 2013 Preview
  • Visual Studio 2012Visual Studio 2012
  • Visual Studio 2010Visual Studio 2010
  • nuget.exe 命令行实用程序nuget.exe Command-Line Utility

Visual Studio 中的自动包还原Automatic Package Restore in Visual Studio

从 NuGet 2.7 开始, NuGet 将在 Visual Studio 中生成期间自动下载缺少的包, 即使未对该解决方案显式启用包还原也是如此。Starting with NuGet 2.7, NuGet will automatically download missing packages during build in Visual Studio, even if package restore hasn't been explicitly enabled for the solution. 在生成项目或解决方案时, 但在调用 MSBuild 之前, 将在 Visual Studio 中执行此自动包还原。This Automatic Package Restore happens in Visual Studio when you build a project or the solution, but before MSBuild is invoked. 这产生了几个重要的好处:This yields a few significant benefits:

  1. 不再需要在解决方案中使用 "启用 NuGet 包还原" 手势No further need to use the "Enable NuGet Package Restore" gesture on your solution
  2. 不需要修改项目, 并且 NuGet 不会对项目进行更改, 以确保启用包还原Projects don't need to be modified, and NuGet won't make changes to your project to ensure package restore is enabled
  3. 所有 NuGet 包 (包括包含属性/目标文件的 MSBuild 导入的文件) 将在调用 MSBuild之前还原, 并确保在生成过程中正确识别这些属性/目标All NuGet packages, including those that included MSBuild imports for props/targets files, will be restored before MSBuild is invoked, ensuring those props/targets are properly recognized during the build

若要在 Visual Studio 中使用自动包还原, 只需执行一个 (在中) 操作:In order to use Automatic Package Restore in Visual Studio, you only need to take one (in)action:

  1. 不签入您packages的文件夹Don't check in your packages folder

有多种方法可以从源代码管理packages中省略文件夹。There are several ways to omit your packages folder from source control. 有关详细信息, 请参阅包和源代码管理主题。For more information, see the Packages and Source Control topic.

虽然所有用户都隐式选择自动包还原许可, 但你可以轻松地通过 Visual Studio 中的包管理器设置进行选择。While all users are implicitly opted into Automatic Package Restore consent, you can easily opt out through the Package Manager settings in Visual Studio.

程序包管理器设置

从命令行简化包还原Simplified Package Restore from the Command-Line

NuGet 2.7 为 nuget.exe 引入了一项新功能:nuget.exe restoreNuGet 2.7 introduces a new feature for nuget.exe: nuget.exe restore

这一新的 "还原" 命令可让你使用单个命令轻松还原解决方案的所有包, 方法是接受解决方案文件或文件夹作为参数。This new Restore command allows you to easily restore all packages for a solution with a single command, by accepting a solution file or folder as an argument. 此外, 当当前文件夹中只有一个解决方案时, 该参数是隐含的。Furthermore, that argument is implied when there's only a single solution in the current folder. 这意味着, 从包含单个解决方案文件 (MySolution) 的文件夹中执行以下所有操作:That means the following all work from a folder that contains a single solution file (MySolution.sln):

  1. nuget.exe restore MySolutionnuget.exe restore MySolution.sln
  2. nuget.exe 还原。nuget.exe restore .
  3. nuget.exe 还原nuget.exe restore

Restore 命令将打开解决方案文件并查找解决方案中的所有项目。The Restore command will open the solution file and find all projects within the solution. 然后, 它将查找packages.config每个项目的文件, 并还原找到的所有包。From there, it will find the packages.config files for each of the projects and restore all of the packages found. 它还将还原在.nuget\packages.config文件中找到的解决方案级别包。It also restores solution-level packages found in the .nuget\packages.config file. 有关新还原命令的详细信息, 请参阅命令行参考More information about the new Restore command can be found in the Command-Line Reference.

新的包还原工作流The New Package Restore Workflow

我们对包还原进行了这些更改, 因为它引入了一个新的工作流。We are excited about these changes to Package Restore, as it introduces a new workflow. 如果要从源代码管理中省略包, 只需提交packages文件夹。If you want to omit your packages from source control you simply don't commit the packages folder. 打开并生成解决方案的 Visual Studio 用户将看到包自动还原。Visual Studio users who open and build the solution will see the packages automatically restored. 对于命令行生成, 只需在nuget.exe restore调用msbuild之前调用。For command-line builds, simply invoke nuget.exe restore before invoking msbuild. 不再需要记得在解决方案上使用 "启用 NuGet 包还原" 手势, 而不再需要修改项目来更改生成。You no longer need to remember to use the "Enable NuGet Package Restore" gesture on your solution, and we'll no longer need to modify your projects to alter the build. 这还为包含 MSBuild 导入的包带来了更好的体验, 特别是通过 NuGet 的最新功能添加的导入, 可自动导入 \build 文件夹中的属性/目标文件And this also yields a much improved experience for packages that include MSBuild imports, especially for imports added through NuGet's recent feature for automatically importing props/targets files from the \build folder.

除了我们亲自完成的工作外, 我们还与一些重要合作伙伴合作, 将此新方法舍入。对于其中的任何一种情况, 我们都没有具体的时间表, 但每个合作伙伴都非常兴奋。In addition to the work we've done ourselves, we're also working with some important partners to round this new approach out. We don't have concrete timelines for any of these yet, but each partner is as excited as we are about the new approach.

  • Team Foundation Service-他们正在努力将对nuget.exe restore的调用集成到默认生成方案。Team Foundation Service - They are working to integrate the call to nuget.exe restore into the default build scenarios.
  • Microsoft Azure 网站-他们正在努力, 使你能够将项目推送到 Azure, 并nuget.exe restore在构建你的网站之前调用它。Windows Azure Web Sites - They are working to allow you to push your project to Azure and have nuget.exe restore called before your web site is built.
  • TeamCity-他们正在为 TeamCity 3.x 更新 NuGet 安装程序插件TeamCity - They are updating their NuGet Installer plugin for TeamCity 8.x
  • AppHarbor-它们的作用是使你能够将存储库推送到 AppHarbor, nuget.exe restore并在构建解决方案之前调用它。AppHarbor - They are working to allow you to push your repo to AppHarbor and have nuget.exe restore called before your solution is build.

对于上述每个合作伙伴, 他们将使用自己的 nuget.exe 副本, 而不需要在解决方案中携带 nuget.exe。With each of the partners above, they would use their own copy of nuget.exe and you would not need to carry nuget.exe in your solution.

已知问题Known Issues

使用初始2.7 版本时, nuget.exe 还原有两个已知问题, 但在9/6/2013 上已修复了这些问题, 并更新了Nuget 命令行包There were two known issues with nuget.exe restore with the initial 2.7 release, but they were fixed on 9/6/2013 with an update to the NuGet.CommandLine package. CodePlex 上的NuGet 2.7 下载页面上也提供了此更新。This update is also available on the NuGet 2.7 download page on CodePlex. 运行nuget.exe update -self将更新到最新版本。Running nuget.exe update -self will update to the latest release.

固定的是:The fixed were:

  1. 使用 SLN 文件时, 新包还原不适用于 MonoNew package restore doesn't work on Mono when using SLN file
  2. 新包还原不适用于 Wix 项目New package restore doesn't work with Wix projects

新的包还原工作流也存在一个已知问题, 即对于解决方案文件夹下的项目, 自动包还原不起作用There is also a known issue with the new package restore workflow whereby Automatic Package Restore does not work for projects under a solution folder. 此问题已在 NuGet 2.7.1 中修复。This issue was fixed in NuGet 2.7.1.

项目重定目标和升级生成错误/警告Project Retargeting and Upgrade Build Errors/Warnings

在重定目标或升级项目后多次, 你会发现某些 NuGet 包不能正常工作。Many times after retargeting or upgrading your project, you find that some NuGet packages aren't functioning properly. 遗憾的是, 没有任何迹象, 就如何解决此情况没有任何帮助。Unfortunately, there is no indication of this and then there's no guidance on how to address it. 使用 NuGet 2.7, 我们现在使用一些 Visual Studio 事件来识别你的项目重定向或升级的方式, 这种方式会影响你安装的 NuGet 包。With NuGet 2.7, we now use some Visual Studio events to recognize when you've retargeted or upgraded your project in a way that affects your installed NuGet packages.

如果检测到你的任何包受重定目标或升级的影响, 我们将生成即时生成错误以通知你。If we detect that any of your packages were affected by the retargeting or upgrade, we'll produce immediate build errors to let you know. 除了立即生成错误外, 还会在requireReinstallation="true" packages.config文件中为受重定目标影响的所有包保留一个标志, 并且 Visual Studio 中的每个后续生成将引发这些包的生成警告。In addition to the immediate build error, we also persist a requireReinstallation="true" flag in your packages.config file for all packages that were affected by the retargeting, and each subsequent build in Visual Studio will raise build warnings for those packages.

尽管 NuGet 不能执行自动操作来重新安装受影响的包, 但我们希望这一指示和警告将引导你在需要重新安装包时了解相关信息。Although NuGet cannot take automatic action to reinstall affected packages, we hope this indication and warning will guide help you discover when you need to reinstall packages. 我们还致力于在包重新安装指南文档中, 将这些错误消息定向到。We are also working on package reinstallation guidance documentation that these error messages direct you to.

NuGet 配置默认值NuGet Configuration Defaults

许多公司都在内部使用 NuGet, 但我们已在很大时间向开发人员提供了使用内部包源 (而不是 nuget.org) 的指导。NuGet 2.7 引入了 "配置默认值" 功能, 该功能允许为以下项指定计算机范围的默认值:Many companies are using NuGet internally, but have had a hard time guiding their developers to use internal package sources instead of nuget.org. NuGet 2.7 introduces a Configuration Defaults feature that allows machine-wide defaults to be specified for:

  1. 启用的包源Enabled package sources
  2. 已注册, 但已禁用包源Registered, but disabled package sources
  3. 默认的 nuget.exe 推送源The default nuget.exe push source

现在, 其中的每个可在位于%ProgramData%\NuGet\NuGetDefaults.Config的文件中进行配置。Each of these can now be configured within a file located at %ProgramData%\NuGet\NuGetDefaults.Config. 如果此配置文件指定了包源, 则将不会自动注册默认的 nuget.org 包源, 而是改NuGetDefaults.Config为注册中的包源。If this config file specifies package sources, then the default nuget.org package source will not be registered automatically, and the ones in NuGetDefaults.Config will be registered instead.

尽管不需要使用此功能, 但我们希望公司使用组策略NuGetDefaults.Config部署文件。While not required to use this feature, we expect companies to deploy NuGetDefaults.Config files using Group Policy.

请注意, 此功能永远不会导致包源从开发人员的 NuGet 设置中删除。这意味着, 如果开发人员已使用 NuGet, 并因此注册了 nuget.org 包源, 则不会在创建NuGetDefaults.Config文件后将其删除。Note that this feature will never cause a package source to be removed from a developer's NuGet settings. That means if the developer has already used NuGet and therefore has the nuget.org package source registered, it won't be removed after the creation of a NuGetDefaults.Config file.

有关此功能的详细信息, 请参阅NuGet 配置默认值See NuGet Configuration Defaults for more information about this feature.

重命名默认包源Renaming the Default Package Source

NuGet 始终注册一个指向 nuget.org 的默认包源, 名为 "NuGet 官方包源"。该名称是详细的, 它也不指定实际指向的位置。NuGet has always registered a default package source called "NuGet official package source" that points to nuget.org. That name was verbose and it also didn't specify where it was actually pointing. 若要解决这两个问题, 我们已将此包源重命名为 UI 中的 "nuget.org"。To address those two issues, we've renamed this package source to simply "nuget.org" in the UI. 包源的 URL 也已更改为包含 "www"。The URL for the package source was also changed to include the "www." 前缀。prefix. 使用 NuGet 2.7 后, 现有的 "NuGet 官方包源" 将自动更新为 "nuget.org" 作为其名称, 将 "https://www.nuget.org/api/v2/" 作为其 URL。After using NuGet 2.7, your existing "NuGet official package source" will automatically be updated to "nuget.org" as its name and "https://www.nuget.org/api/v2/" as its URL.

性能改进Performance Improvements

我们在2.7 中进行了一些性能改进, 从而降低了内存占用, 减少了磁盘使用量, 并加快了包安装。We made some performance improvement in 2.7 which will yield smaller memory footprint, less disk usage and faster package installation. 我们还为基于 OData 的源进行了更智能化的查询, 这将减少总体负载。We also made smarter queries to OData-based feeds which will reduce the overall payload.

新的扩展性 ApiNew Extensibility APIs

我们向扩展性服务添加了一些新的 Api, 以弥补以前版本中缺少的功能的差距。We added some new APIs to our extensibility services to fill the gap of missing functionalities in previous releases.

IVsPackageInstallerServicesIVsPackageInstallerServices

```cs
// Checks if a NuGet package with the specified Id and version is installed in the specified project.
bool IsPackageInstalledEx(Project project, string id, string versionString);

// Get the list of NuGet packages installed in the specified project.
IEnumerable<IVsPackageMetadata> GetInstalledPackages(Project project);
```

IVsPackageInstallerIVsPackageInstaller

```cs
// Installs one or more packages that exist on disk in a folder defined in the registry.
void InstallPackagesFromRegistryRepository(string keyName, bool isPreUnzipped, bool skipAssemblyReferences, Project project, IDictionary<string, string> packageVersions);

// Installs one or more packages that are embedded in a Visual Studio Extension Package.
void InstallPackagesFromVSExtensionRepository(string extensionId, bool isPreUnzipped, bool skipAssemblyReferences, Project project, IDictionary<string, string> packageVersions);
```

仅限开发的依赖项Development-Only Dependencies

此功能由Adam Ralph提供, 它允许包作者声明仅在开发时使用的依赖项, 而无需包依赖项。This feature was contributed by Adam Ralph and it allows package authors to declare dependencies that were only used at development time and don't require package dependencies. 通过将developmentDependency="true"属性添加到中packages.config的包, nuget.exe pack将不再包含该包作为依赖项。By adding a developmentDependency="true" attribute to a package in packages.config, nuget.exe pack will no longer include that package as a dependency.

删除了对 Visual Studio 2010 Express for Windows Phone 的支持Removed Support for Visual Studio 2010 Express for Windows Phone

2.7 中的新包还原模型是通过与主 NuGet VSPackage 不同的新 VSPackage 实现的。The new package restore model in 2.7 is implemented by a new VSPackage which is different from the main NuGet VSPackage. 由于技术问题, 在Visual studio 2010 Express for Windows Phone SKU 中, 此新的 VSPackage 无法正常工作, 因为我们与其他受支持的 Visual studio sku 共享相同的代码库。Due to a technical issue, this new VSPackage doesn't work correctly in the Visual Studio 2010 Express for Windows Phone SKU as we share the same code base with other supported Visual Studio SKUs. 因此, 从 NuGet 2.7 开始, 我们将从已发布的扩展中删除对Visual Studio 2010 Express for Windows Phone的支持。Therefore, starting with NuGet 2.7, we are dropping support for Visual Studio 2010 Express for Windows Phone from the published extension. 支持Visual studio 2010 Express For Web仍包含在发布到 Visual Studio 扩展库的主扩展中。Support for Visual Studio 2010 Express for Web is still included in the primary extension published to the Visual Studio Extension Gallery.

由于我们不确定开发人员在该版本的 Visual Studio 中仍使用 NuGet 的多少开发人员, 我们将专门为这些用户发布单独的 Visual Studio 扩展, 并将其发布到 CodePlex (而不是 Visual Studio 扩展库).Since we are unsure how many developers are still using NuGet in that version/edition of Visual Studio, we are publishing a separate Visual Studio extension specifically for those users and publishing it on CodePlex (rather than the Visual Studio Extension Gallery). 我们不打算继续维护该扩展, 但如果这样会影响你, 请在 CodePlex 上存档问题, 告诉我们。We don't plan to continue to maintain that extension, but if this affects you please let us know by filing an issue on CodePlex.

若要下载 NuGet 包管理器 (对于 Visual Studio 2010 Express for Windows Phone), 请访问nuget 2.7 下载页。To download the NuGet Package Manager (for Visual Studio 2010 Express for Windows Phone), visit the NuGet 2.7 Downloads page.

Bug 修复Bug Fixes

除了这些功能以外, 此版本的 NuGet 还包括许多其他 bug 修复。In addition to these features, this release of NuGet also includes many other bug fixes. 此版本中解决了97的总问题。There were 97 total issues addressed in the release. 有关 NuGet 2.7 中已修复的工作项的完整列表, 请查看此版本的 NuGet 问题跟踪程序For a full list of work items fixed in NuGet 2.7, please view the NuGet Issue Tracker for this release.