【发布时间】:2021-03-29 12:45:04
【问题描述】:
在 Jenkins 的 Freestyle 项目中使用 MSBuild 时出现以下错误
我想要的工作流程如下:
- git clone repo 到工作区(成功)
- MSbuild 来自 repo 的 SLN 文件(显然失败了。
- 构建成功后,将文件移动到网络映射文件夹
我安装了 MSbuild 插件,并将整个路径粘贴到它克隆 repo 后存在的 SLN 文件。
我做错了什么?
编辑:
这是整个构建日志:
Building in workspace C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\TAPPISAFE-Pipeline
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
The recommended git tool is: NONE
using credential JenkinsGitbucket
Cloning the remote Git repository
Cloning repository https://agile.tappi.org/gitbucket/git/root/TAPPISAFE.git
> git.exe init C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\TAPPISAFE-Pipeline # timeout=10
Fetching upstream changes from https://agile.tappi.org/gitbucket/git/root/TAPPISAFE.git
> git.exe --version # timeout=10
> git --version # 'git version 2.11.1.windows.1'
using GIT_ASKPASS to set credentials Jenkins Gitbucket
> git.exe fetch --tags --progress -- https://agile.tappi.org/gitbucket/git/root/TAPPISAFE.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git.exe config remote.origin.url https://agile.tappi.org/gitbucket/git/root/TAPPISAFE.git # timeout=10
> git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
Checking out Revision 03661da9c578e2dfc33ca5594b3e16dd8cf0650a (refs/remotes/origin/master)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f 03661da9c578e2dfc33ca5594b3e16dd8cf0650a # timeout=10
Commit message: "Merge pull request #1 from root/brenden-master"
> git.exe rev-list --no-walk 03661da9c578e2dfc33ca5594b3e16dd8cf0650a # timeout=10
Path To MSBuild.exe: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
Executing the command cmd.exe /C " chcp 1252 & C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe Tappisafe.Web.sln " && exit %%ERRORLEVEL%% from C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\TAPPISAFE-Pipeline
[TAPPISAFE-Pipeline] $ cmd.exe /C " chcp 1252 & C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe Tappisafe.Web.sln " && exit %%ERRORLEVEL%%
Active code page: 1252
Microsoft (R) Build Engine version 4.8.3761.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1009: Project file does not exist.
Switch: Tappisafe.Web.sln
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Finished: FAILURE```
【问题讨论】:
-
切换:C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\TAPPISAFE-Pipeline\Tappisafe.Web.sln 这看起来不像是一个有效的文件夹.我怀疑你有你的 .sln :)。您能否提供有关您的 Jenkins 和 MSBuild 设置的更多信息?
-
所以在 MSbuild 设置中,我提供了 SLN 文件的确切路径,该文件确实存在。我还尝试为 SLN 文件提供相对路径(在工作空间内),但它给出了相同的错误。该项目只是克隆一个 git repo,然后 MSbuild 构建相应的 SLN 文件,或者更确切地说,它应该构建。
-
对于 FreeStyle Jenkins 作业,在每个作业构建完成后,您可以检查作业工作区中的文件/文件夹。就像从 repo 克隆源代码文件,或者构建工件等一样。所以你可以打开你的 Jenkins 作业并单击侧边栏右侧的
WorkSpace链接并关闭页面顶部。确认您将正确的Tappisafe.Web.sln文件提供给 msbuild -
是的,解决方案文件在那里,所以我没有看到问题所在。 “Tappisafe.Web.sln”是工作区中的有效文件。
标签: c# jenkins msbuild jenkins-pipeline