Windows systemprofile 目录根据用户显示不同

标签 windows powershell jenkins msbuild nuget

上下文:

我正在尝试在 Windows Server 2012 R2 上设置 Jenkins (2.223) 构建服务器(在本例中使用 msbuild 进行构建)。 Jenkins 设置为服务并以 Local System 身份运行.

问题:

我遇到了一个问题,当我以管理员用户身份使用 RDP 时可以运行构建脚本,但无法通过 Jenkins 运行相同的脚本。经过一番挖掘,我发现 Jenkins 找不到具有所需构建引用的目录( C:\Windows\System32\config\systemprofile\.nuget\packages )。经过更多调查,我发现目录 C:\Windows\System32\config\systemprofile看起来不一致。

我可以运行命令dir C:\Windows\System32\config\systemprofile通过我的管理员帐户,我得到:

     Directory: C:\Windows\System32\config\systemprofile


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         3/11/2020   9:43 AM            .dotnet
d----         3/11/2020   2:27 PM            .nuget
d----          3/9/2020   1:49 PM            .ssh
d----         8/22/2013   6:36 AM            AppData
-a---          3/2/2020   3:41 PM     262144 ntuser.dat

我可以通过 Jenkins 运行相同的命令 ( dir C:\Windows\System32\config\systemprofile ),我得到:

    Directory: C:\Windows\System32\config\systemprofile


Mode                LastWriteTime     Length Name                              
----                -------------     ------ ----                              
d----          3/9/2020   1:49 PM            .config                           
d----          3/6/2020   2:50 PM            .groovy                           
d----         8/22/2013   8:39 AM            AppData

我需要...\systemprofile\.nuget\packages\内的引用文献Jenkins 可以看到以便完成构建(引用由 Jenkins 服务运行的 nuget restore 命令放置在那里,所以这对我来说似乎是合理的)。老实说,我对 dir 的概念并不熟悉。给出不同的结果。我怀疑 Windows 恶作剧,但我很好奇到底发生了什么 - 为什么我会根据运行命令的用户得到不同的结果?

其他信息:

  • 我能够毫无麻烦地在我的本地 Windows 10 桌面上运行此功能。执行 dir 时我仍然得到不同的结果作为我的用户与 Jenkins 服务的命令,但它们都恰好有 systemprofile\.nuget\packages目录可用。

  • 在 2012 服务器上,我的管理员用户的 $env:UserName 和 $env:ComputerName 为 AdministratorWIN-64VG7CF1QK3分别。 Jenkin 的本地系统 $env:UserName 和 $env:ComputerName 都是 WIN-64VG7CF1QK3 .

最佳答案

对我的问题的两条评论(mklement0zett42)很好地回答了这个问题,使用它们我能够更好地理解和解决我的问题。

事实证明,Jenkins 默认安装了 32 位 JRE - 最终会默默地查看 SysWOW64 而不是 System32(但仅在 msbuild 期间) 命令而不是 nuget Restore 命令?)。

无论如何,解决方案是按照 zett42 的建议将 Jenkins 配置为使用 64 位 JRE。 See this answer .

关于Windows systemprofile 目录根据用户显示不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60657624/

相关文章:

linux - 无法启动 : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop

windows - 下载旧版本的 git for windows

powershell - 在powershell中对文本进行数字排序

iis - 如何使用 Powershell 操作远程服务器上的 IIS 应用程序池列表?

ios - HockeyApp 错误 bundle 版本不匹配

C++ Winsock 接受内存泄漏/资源泄漏

windows - 如何使批处理文件全屏显示?

string - Powershell中字符串内变量的替代成员

linux - Jenkins作业因测试失败而失败。测试的源代码包括AWT GUI测试,如何使用Xvfb插件

java - 使用 `new EdgeOptions()` 优于 `DesiredCapabilities.edge()` 通过 Jenkins 和 Selenium 启动远程 Microsoft Edge 浏览器错误