【问题标题】:Does nuget still require these entries in Visual Studio projects?nuget 是否仍需要 Visual Studio 项目中的这些条目?
【发布时间】:2015-03-05 20:42:20
【问题描述】:

我注意到没有这些 nuget 指令的新 .csproj 项目似乎可以正常工作。 这些是可以从项目中删除的过去的遗物吗? 我扫描了 nuget FAQ,但没有找到与此相关的任何内容。

我正在运行 Visual Studio 2013 以及最近构建的 Xamarin Studio。

  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
  </Target>

【问题讨论】:

    标签: visual-studio-2013 nuget xamarin-studio csproj


    【解决方案1】:

    如果您使用了启用 NuGet 包还原 菜单选项,则会添加这些特定目标。在这种情况下,可以删除这些目标。如果你安装了最新版本的 NuGet,Visual Studio 将自动恢复 NuGet 包,而无需这些额外的目标。 NuGet 团队已弃用此菜单选项,我相信它会在某个时候被删除。

    请注意,如果您在构建服务器上构建项目,您将需要创建一个额外的步骤来恢复 NuGet 包,使用 NuGet.exe 恢复,当解决方案在构建服务器上构建时会自动恢复由 MSBuild 提供。

    另请注意,如果您添加包含其自己的 MSBuild .targets 文件(例如 Microsoft.Bcl.Build)的 NuGet 包,NuGet 将添加非常相似的目标。在这种情况下,该项目将在没有 EnsureNuGetPackageBuildImports 目标的情况下工作,但需要导入 MSBuild .targets 文件的 Import 元素。将 EnsureNuGetPackageBuildImports 目标保留在项目中确实会给您一个可能更有用的错误消息,说明如果 NuGet 包未恢复,构建可能会失败的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      相关资源
      最近更新 更多