24

1.共享违规

在关注http://programmaticponderings.wordpress.com/2012/08/08/convert-vs-2010-database-project-to-ssdt-and-automate-publishing-with-jenkins-part-33/

    echo 'Copying Adventure Works Solution to Jenkins workspace...'
xcopy /s /E /H /Y /R "C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3" "C:\Program Files (x86)\Jenkins\jobs\testing003\workspace" 

echo 'Deleting artifacts from previous builds...'
del "%WORKSPACE%\*_publish.zip" /F /Q

2.用MS build构建ms项目

添加 C:\Windows\Microsoft.NET\Framework\v4.0.30319\ 环境变量路径并在 Jenkins 中设置构建 C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe

'C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.sqlproj' /p:Configuration=Database3 /p:Platform=AnyCPU /t:Build;Publish /p:SqlPublishProfilePath='C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.publish.xml' /p:UpdateDatabase=False


Executing the command cmd.exe /C msbuild.exe "C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.sqlproj" /p:Configuration=Database3 /p:Platform=AnyCPU /t:Build;Publish "/p:SqlPublishProfilePath=C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.publish.xml" /p:UpdateDatabase=False C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe && exit %%ERRORLEVEL%% from C:\Program Files (x86)\Jenkins\jobs\testing003\workspace
[workspace] $ cmd.exe /C msbuild.exe "C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.sqlproj" /p:Configuration=Database3 /p:Platform=AnyCPU /t:Build;Publish "/p:SqlPublishProfilePath=C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.publish.xml" /p:UpdateDatabase=False C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe && exit %%ERRORLEVEL%%
'msbuild.exe' is not recognized as an internal or external command,


C:\Users\User2>cmd.exe /C msbuild.exe "C:\Users\LAB-User2\Documents\Visual S
tudio 2012\Projects\Database3\Database3.sqlproj" /p:Configuration=Database3 /p:P
latform=AnyCPU /t:Build;Publish "/p:SqlPublishProfilePath=C:\Users\LAB-User2\Doc
uments\Visual Studio 2012\Projects\Database3\Database3.publish.xml" /p:UpdateDat
abase=False C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe && exit %%
ERRORLEVEL%% from C:\Program Files (x86)\Jenkins\jobs\testing003\workspace
Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.18034]
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1008: Only one project can be specified.
Switch: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe

For switch syntax, type "MSBuild /help"

更新 完整控制台输出

Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\testing003\workspace
[workspace] $ cmd /c call C:\Windows\TEMP\hudson1045566609826009314.bat

C:\Program Files (x86)\Jenkins\jobs\testing003\workspace>echo 'Copying Adventure Works Solution to Jenkins workspace...' 
'Copying Adventure Works Solution to Jenkins workspace...'

C:\Program Files (x86)\Jenkins\jobs\testing003\workspace>xcopy /s /E /H /Y /R "C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3" "C:\Program Files (x86)\Jenkins\jobs\testing003\workspace"  
C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.sln
C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.v11.suo
C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\excludefiles.txt
C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3\Database3.dbmdl
Sharing violation

C:\Program Files (x86)\Jenkins\jobs\testing003\workspace>echo 'Deleting artifacts from previous builds...' 
'Deleting artifacts from previous builds...'

C:\Program Files (x86)\Jenkins\jobs\testing003\workspace>del "C:\Program Files (x86)\Jenkins\jobs\testing003\workspace\*_publish.zip" /F /Q 
Could Not Find C:\Program Files (x86)\Jenkins\jobs\testing003\workspace\*_publish.zip

C:\Program Files (x86)\Jenkins\jobs\testing003\workspace>exit 0 
Path To MSBuild.exe: msbuild.exe
Executing the command cmd.exe /C msbuild.exe "C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.sqlproj" /p:Configuration=Database3 /p:Platform=AnyCPU /t:Build;Publish "/p:SqlPublishProfilePath=C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.publish.xml" /p:UpdateDatabase=False C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe && exit %%ERRORLEVEL%% from C:\Program Files (x86)\Jenkins\jobs\testing003\workspace
[workspace] $ cmd.exe /C msbuild.exe "C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.sqlproj" /p:Configuration=Database3 /p:Platform=AnyCPU /t:Build;Publish "/p:SqlPublishProfilePath=C:\Users\LAB-User2\Documents\Visual Studio 2012\Projects\Database3\Database3.publish.xml" /p:UpdateDatabase=False C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe && exit %%ERRORLEVEL%%
'msbuild.exe' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Finished: FAILURE

在此处输入图像描述

4

5 回答 5

45

如果要使用 Jenkins 构建 .NET 项目,请按照以下步骤操作:

  1. 安装MsBuild 插件

  2. 转到Jenkins -> Manage Jenkins -> Configure System (在较新版本上Jenkins -> Manage Jenkins -> Global Tool Configuration -> MSBuild:) 构建

  3. 在 MSBuild 部分中,单击AddMsBuild按钮并指定详细信息:

    • 名称:MsBuild 的名称
    • MsBuild 的路径:指定 msbuild.exe 的路径。例子:C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe
  4. 保存并应用更改。

  5. 选择你的工作。

  6. 选择添加构建步骤

  7. 选择 MsBuild 版本。

  8. 指定项目文件的路径(.csproj 或 .sln)

项目中的 msbuild

  1. 构建您的项目。
于 2013-09-03T12:30:53.837 回答
7

对于较新版本的 Jenkins,此选项在此部分下可用。

Manage Jenkins -> Global Tool Configuration ->  MSBuild

从这个答案:https ://stackoverflow.com/a/37939483/2880781

于 2018-02-17T08:51:18.923 回答
1

对于最新版本的 jenkins (3.0),您必须在Tools>Manage Jenkins菜单中配置 MSBuild。在这里命名一个工作,例如:msbuild。一旦完成,就去工作。在 MSBuild 模块下选择构建(在本例中msbuild),然后开始工作。你应该很高兴。

于 2016-12-06T18:49:06.800 回答
0

在作业的配置中选择 MSBuild 版本,MSBuild 版本在您的 jenkins 配置系统中配置。

于 2016-04-29T08:06:35.863 回答
0
  1. 在服务器上安装 Visual Studio
  2. 登录你的詹金斯
  3. 安装 MSBuild 插件
  4. 转到 Jenkins > 管理 Jenkins > 全局工具配置
  5. 单击 MSBuild 安装
  6. 单击添加 MSBuild
  7. 名称:Visual Studio(即Visual Studio 2019 Community)
  8. MSBuild 的路径(即 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin) 在此处输入图像描述
  9. 点击保存
  10. 转到您的 Jenkins 项目
  11. 单击配置
  12. 去建造
  13. 选择您的 MSBuild 版本
  14. 输入您的解决方案文件的名称 在此处输入图像描述
于 2020-09-11T14:47:59.633 回答