web-dev-qa-db-fra.com

msbuild.exe n'est pas reconnu après la construction de Jenkins

1. violation de partage

après avoir suivi 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.Build projet avec MS build

Après avoir ajouté le chemin des variables d’environnement C:\Windows\Microsoft.NET\Framework\v4.0.30319 \. Et définir la génération C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe dans Jenkins

'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 Sortie de la console complète

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

enter image description here

20
Martin

Si vous souhaitez générer un projet .NET à l'aide de Jenkins, procédez comme suit:

  1. Installer Plugin MsBuild

  2. Allez à Jenkins -> Manage Jenkins -> Configure System (Sur les versions plus récentes: Jenkins -> Manage Jenkins -> Global Tool Configuration -> MSBuild)  msbuild

  3. Dans la section MSBuild, cliquez sur le bouton AddMsBuild et spécifiez les détails:

    • Nom: Nom du MsBuild
    • Chemin d'accès à MsBuild: spécifiez le chemin d'accès de msbuild.exe. Exemple: C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe
  4. Enregistrez et appliquez les modifications.

  5. Sélectionnez votre travail.

  6. Sélectionnez Ajouter l'étape de construction.

  7. Sélectionnez la version de MsBuild.

  8. Spécifiez le chemin d'accès au fichier de projet (.csproj ou .sln)

 msbuild in project

  1. Construisez votre projet. 
39
Sumeshk

Pour la nouvelle version de Jenkins, cette option est disponible dans cette section.

Manage Jenkins -> Global Tool Configuration ->  MSBuild

De cette réponse: https://stackoverflow.com/a/37939483/2880781

7
Srijani Ghosh

Pour la dernière version de jenkins (3.0), vous devez configurer MSBuild dans le menu Tools>Manage Jenkins. Nommez un travail ici, par exemple: msbuild. Une fois que c'est fait, allez au travail. Sous le module MSBuild, sélectionnez la construction (dans ce cas, msbuild) et lancez le travail. Vous devriez être prêt à partir.

1
user7258708

sélectionnez la version MSBuild dans la configuration du travail et la version MSBuild est configurée dans le système de configuration de votre jenkins.

0
Zav