如果您正在使用TFS
请从解决方案的.nuget
文件夹中删除NuGet.exe
和NuGet.targets
文件。确保也将这些文件从解决方案工作区中删除。
保留NuGet.Config
文件,以便继续绕过将软件包添加到源代码控制中。
编辑解决方案中的每个项目文件(例如 .csproj、.vbproj),并删除对NuGet.targets
文件的任何引用。在所选编辑器中打开项目文件,并删除以下设置:
<RestorePackages>true</RestorePackages>
...
<Import Project="$(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>
如果你没有使用TFS
从你的解决方案中删除.nuget
文件夹。确保文件夹本身也从解决方案工作区中删除。
编辑解决方案中的每个项目文件(例如.csproj、.vbproj)并删除对NuGet.targets
文件的任何引用。在所选编辑器中打开项目文件并删除以下设置:
<RestorePackages>true</RestorePackages>
...
<Import Project="$(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>
参考:将基于 MSBuild 的解决方案迁移到自动包恢复