花了太长时间,但我终于在Migrating MSBuild-Integrated solutions to Automatic Package Restore上找到了这个文档,我能够使用这里描述的方法解决这个问题.
- 从解决方案中删除
'.nuget'
解决方案目录
- 从
.csproj
或.vbproj
文件中删除对nuget.targets
的所有引用.虽然没有官方支持,但如果你有很多需要清理的项目,该文档会链接到PowerShell script.我手工编辑了我的,所以我不能给出任何关于我使用它的经验的反馈.
手工编辑文件时,您需要的是:
Solution File (.sln)
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F4AEBB8B-A367-424E-8B14-F611C9667A85}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project File (.csproj / .vbproj)
<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>