如何避免Nuget包被缓存

时间:2017-03-10 10:32:27

标签: continuous-integration nuget nuget-package nuget-package-restore cakebuild

在恢复Nuget软件包时,软件包将在本地计算机中缓存,下次当我想使用最新的Nuget软件包(使用相同版本,但文件已更新)时,将从我的计算机中检索旧版本。 / p>

我使用以下命令清除本地计算机缓存中的Nuget包:

nuget locals -clear all

可以阻止Nuget包在系统中缓存,而不是这样做。

1 个答案:

答案 0 :(得分:3)

是的,使用可用于

nocache选项

如果你想100%确定你可以将NUGET_PACKAGES环境变量设置为临时路径,它看起来和每次都在新的地方存放。

当你用Cake标记问题时 - 我想你正在使用它,NuGetAliases用于安装&恢复支持NoCache。

要从Cake脚本设置NUGET_PACKAGES环境变量,您可以使用EnvironmentVariables所有Cake工具可用的NuGetInstallSettings属性,包括NuGetRestoreSettingsenter image description here,设置它可能看起来像什么像这样

new NuGetRestoreSettings {
    NoCache = true,
    EnvironmentVariables = new Dictionary<string, string>{
        { "NUGET_PACKAGES", MakeAbsolute(Directory("./some_temp_path")).FullPath }
    }
}