6

i am trying to execute devenv.exe through windows batch command plugin in Jenkins but it keeps on executing and fails to launch the application.

Console Output :

**In progressConsole Output
Started by user anonymous
Building on master in workspace C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3900292017086958332.bat
C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace>set DEVPATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE 
C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace>set PATH=D:\app\nazopay\product\11.2.0\dbhome_1\bin;D:\app\nazopay\product\11.2.0\client_1;C:\Program Files (x86)\Integrity\IntegrityClient10\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\cde\tools;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_23\bin\;C:\Program Files (x86)\Google\Chrome\Application;C:\MingW;C:\PROGRA~2\INTEGR~1\Toolkit\mksnt;%JAVA_HOME%;,;C:\Program Files\Java\jdk1.6.0_23;,;C:\Program Files\Java\jdk1.6.0_23\bin;%CLASS_PATH%;,;C:\Program Files\Java\jdk1.6.0_23\lib;,;C:\Program Files\Java\jdk1.6.0_23\lib;;C:\Program Files (x86)\M**icrosoft Visual Studio 10.0\Common7\IDE 

C:\Program Files (x86)\Jenkins\jobs\TEMP\workspace>devenv.exe
uncletall
  • 6,609
  • 1
  • 27
  • 52
user3168989
  • 71
  • 2
  • 4

2 Answers2

8

You must execute devenv.com.

The devenv.exe always attempts to open GUI, even when commands are given, and it can't. The devenv.com has output directed to standard output and works fine from Jenkins.

You also must pass arguments.

Without arguments both devenv.com and devenv.exe just start the IDE GUI, which is not what you want. The correct command-line is

devenv.com projectname.sln /Build Release /Project projectname

First is path to the solution you want to build. Then the /Build flag is followed by configuration. If you have multiple platforms, you have to pass configuration and platform combination, e.g. Release|Win32. The /Project flag names project to build (including all dependencies). If omitted, it builds all projects selected for build in given configuration.

Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
3

Why don't you use msbuild?

This would be a good starting point for your windows build script:

call "%VS100COMNTOOLS%\vsvars32.bat"
msbuild projectname.sln /target:Rebuild /l:FileLogger,Microsoft.Build.Engine;logfile=msbuild.log || goto error
goto end
:error
@echo ERROR: Build failed
exit/b 1
:end
exit/b 0

This way you can also capture the output log that you can parse with one of the jenkins plugins. Ofcourse, adjust the VS100COMNTOOLS to your version of MSVS

uncletall
  • 6,609
  • 1
  • 27
  • 52
  • 3
    In MSVS 8.0 (2005) and MSVS 9.0 (2008) this does not work for C++ projects. Since MSVS 10.0 (2010) it should. – Jan Hudec Apr 08 '14 at 15:00
  • MSBuild does not support a few projects like SSRS and maybe SSIS. It did not support the SSDT project initially but now does. – Patrick D'Souza Aug 10 '17 at 13:26
  • And with experience I have now I'd add that since MSVS 10.0 (2010) it does not always work either. Just calling MSBuild will often use different version than the one that comes with Visual Studio, but I've also seen some strange failures when running external commands even though I believe we did get it to invoke the correct version. `devenv.com` works more reliably. – Jan Hudec Jan 28 '19 at 19:06