一尘不染

在Jenkins中生成后无法识别msbuild.exe命令

jenkins

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"

update Full Console output

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

阅读 537

收藏
2020-07-25

共1个答案

一尘不染

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

  1. Install MsBuild Plugin

  2. Go to Jenkins -> Manage Jenkins -> Configure System (On newer versions: Jenkins -> Manage Jenkins -> Global Tool Configuration -> MSBuild)

  3. In the MSBuild section click the AddMsBuild button and specify the details:

    • Name: Name of the MsBuild
    • Path to MsBuild: Specify the path of msbuild.exe. Example: C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe
    • Save and apply the changes.
  4. Select your job.

  5. Select Add Build Step.

  6. Select MsBuild version.

  7. Specify the path to the project file (.csproj or .sln)

  8. Build your project.

2020-07-25