13

在我的一些文件的csproj我有这个,但一些不要:EnsureNuGetPackageBuildImports目标是什么?

<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> 

到底是什么这一点,我为什么需要它?我的其他项目正在恢复他们的软件包就好了没有它

我正在使用VS2013和NuGet 2.8。

回答

4

它确保导入的.props和.targets文件确实被导入。自从2.5以来,NuGet已经支持NuGet MSBuild支持。 EnsureNuGetPackageBuildImports代码是在9月份添加的,但我认为这是一个2.8的变化。不幸的是,它看起来像一个非向后兼容的变化。我们有一些2.7的开发者现在需要升级到2.8。我在line 11上找到了CommonNode/MsBuildProjectUtility.cs中的EnsureNuGetPackageBuildImports。

+0

我想知道“ctaggart/nuget”存储库(你链接的)是否真的准确。也许你会链接到“NuGet/NuGet.Client”。它还有[MSBuildProjectSystem.cs文件](https://github.com/NuGet/NuGet.Client/blob/fee9da08b687e9d18073243d46f6d46ad660dd4c/src/NuGet.Clients/NuGet.CommandLine/Common/MSBuildProjectSystem.cs)与EnsureNuGetPackageBuildImports和它似乎是官方的nuget来源。 –