两个用户如何在 Linqpad 中共享公共 nuget 缓存

问题描述 投票:0回答:1

我在 Windows 服务器上使用 Linqpad 通过 lprun 将脚本作为计划任务运行。计划任务作为服务 Windows 帐户运行。我想更新这些脚本使用的 nuget 包。通常,我会打开 Linqpad,转到 NuGet 管理器,然后单击每个包上的“更新”。这会将最新版本下载到本地 NuGet 缓存文件夹。但是,我需要在不作为服务帐户登录服务器的情况下执行此操作(InfoSec 不喜欢作为服务帐户进行交互式登录)。

我尝试使用指向同一文件夹的

NUGET_PACKAGES
环境变量(例如,
D:\nuget\packages
)来设置我的普通 Windows 帐户和服务帐户。当我以用户身份更新包时,我看到新的文件夹版本出现在公共缓存文件夹中,但是当我作为服务帐户运行脚本时,它仍然尝试使用以前版本的 nuget。当新版本的 nuget 具有脚本依赖的新方法时,很容易重现这一点。它只是无法运行。

共享一个通用的 nuget 缓存文件夹似乎还不够。每个用户仍然可以参考一些他认为的最新版本的软件包,但我无法找到它在哪里。

我不知道这是否重要,但其中一些软件包来自私人 nuget 存储库。我已在 Linqpad 中使用相同的连接详细信息和令牌设置两个用户。

我缺少什么想法吗?

c# nuget linqpad
1个回答
0
投票

LINQPad 维护自己的缓存,告诉它成功下载的每个包的最新版本(带有依赖项)。您可以通过使用

-nunuget
开关调用 LPRun 来强制刷新它。以下是所有命令行选项:

>LPRun7
Usage: lprun7 [<options>] <scriptfile> [<script-args>]

options: (all case-insensitive)
 -format={text|html|htmlfrag|csv|csvi}   Output format. csvi=invariant CSV.
 -cxname=<connection-name>               Sets/overrides a script's connection.
 -lang=<language>                        Sets/overrides a script's language.
 -warn                                   Writes compiler warnings (to stderr).
 -optimize                               Enables compiler optimizations.
 -compileonly                            Just checks that query will compile.
 -recompile                              Ignores compiler cache, forces build.
 -nunuget                                Freshens NuGet references to latest.
 -fx=<major.minor>                       Run under specified .NET version.

scriptfile: Path to script. If it's a .linq file, -lang & -cxname are optional.

script-args: Args following <script-filepath> are passed to the script itself.

Examples:
  lprun7 TestScript.linq
  lprun7 TestScript.linq > results.txt
  lprun7 script1.linq | lprun7 script2.linq
  lprun7 -format=csv script.linq HelloWorld

Go to http://www.linqpad.net/lprun.aspx for detailed help.

另一个解决方案是在脚本中引用特定版本的 NuGet 包。那么 LPRun 将不会依赖其缓存来知道要使用哪个版本。

© www.soinside.com 2019 - 2024. All rights reserved.