Tfs 和 nuget:项目文件在使用 restore nuget 包构建后永远处于检出状态

Tfs and nuget: project files are forever in check out after build with restore nuget packages

MS 对比 2012
我在启用了 nuget 包恢复的 tfs 中有解决方案。每次我构建解决方案时,我的所有项目文件都会通过以下更改检出:

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

如何解决此问题?

自 NuGet v2.7 起,MSBuild 集成包还原 已弃用并替换为 自动包还原

查看有关如何将您的解决方案迁移到新功能的文档:Migrating MSBuild-Integrated solutions to use Automatic Package Restore

要了解有关自动包还原的更多信息,请参阅 NuGet Package Restore

两篇文章都讨论了这对 TFS 集成的影响。