3

I'm setting up a Jenkins job for a Windows 10 application. I need to compile one of the four projects inside the solution with devenv.com executable because it is a project with .vdproj extension (setup project). The other projects are built successfully with MSBuild without any problem.

The Jenkins job ends successfully when I'm logged in as root on a Jenkins target node, but, fails when I run the job from Jenkins and I'm not logged in.

Need your help or workaround to solve the issue.

PS: we are using ant as task runner and we have a specific task that start the build process.

EDIT 26/01/2017

I would like to provide you other informations like the error message and one step that I've skipped before.

The error message provides a link to a Microsoft Page and reports a configuration problem.

As solved by this StackOverflow post, I've added a new DWORD registry key under

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config\MSBuild\EnableOutOfProcBuild

Can the problem be that this value can't be readed when the User is'nt logged in ?

EDIT 27/01/2017

I'm going crazy with this issue.

The command devenv /? work fine when i run it locally but wont work when i run it from Jenkins with the same error as before: Microsoft Visual Studio found a configuration problem. To fix it restart as administrator or visit http://go.microsoft.com/fwlink/?LinkId=659046 for further information.

So the devenv.com cannot be executed when i'm not logged in ??

UPDATED 31/01/2017#

Here's my .bat file called from a target by ant build.xml

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"

@set MSBUILD="C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe"

%MSBUILD%  "%cd%\src\AutomatedSetupBuild.proj"

pause

Where the AutomatedSetupBuild.proj is an MSBuild script

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

<Target Name="Build">
  <PropertyGroup>
        <DevEnv>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com</DevEnv>
        <SolutionFile>$(MSBuildProjectDirectory)\MySolution.sln</SolutionFile>
        <ProjectFile>MySetupProject\MySetupProject.vdproj</ProjectFile>
        <Configuration>Release</Configuration>
</PropertyGroup>
    
<Exec
      Command="&quot;$(DevEnv)&quot; &quot;$(SolutionFile)&quot; /Rebuild &quot;$(Configuration)&quot; /Project &quot;$(ProjectFile)&quot; /ProjectConfig &quot;$(Configuration)&quot; /Log vs.log /useenv"
      ContinueOnError="false"
     IgnoreExitCode="false"
     WorkingDirectory="$(MSBuildProjectDirectory)" />
 </Target>
</Project>

As you can see, I'm loading the environment variable before run devenv.com but i receive the same error.

Community
  • 1
  • 1
Gianpolo
  • 966
  • 8
  • 19
  • What is the error message? – stijn Jan 25 '17 at 19:15
  • This sounds like the environment variables are not set up correctly if devenv.com is started by Jenkins. If you open the Visual Studio console form the Windows start menu, a .bat Script is executed (e.g. `"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"`. So find out, which variables are set by such a script. Be sure to use `call` to execute it in the console. – jherb Jan 26 '17 at 10:37
  • In order to load the environment variable I'm running `VsDevCmd.bat` before run devenv.com in a batch file but it wont work – Gianpolo Jan 27 '17 at 15:26
  • I do successfully build with devenv.com with a Jenkins pipeline script (and before from a free style project). – jherb Jan 31 '17 at 15:06

3 Answers3

1

Do you use a free style job or do you use a Jenkinsfile for a pipeline project? In any case, for devenv.com to work, environment variables have to be set up.

Please go to the Windows start menu and look for something like Visual Studio XX -> Visual Studio Tools -> Developer Command Prompt for VS20XX. Press right mouse bottom and select properties. There look for target. In my case this field contains the following string:

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat""

If you use e.g. a Jenkinsfile, change the call to devnenv.com, which probably looks like

bat "devenv.com my_solution_file.sln /project my_project /build  \"Release|x64\""

to

bat "call \"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat\"; devenv.com my_solution_file.sln /project my_project /build  \"Release|x64\""

It is important, that the call to the VsDevCmd.bat is within the same bat command. Otherwise the environment variable settings get lost and are not seen by a second call to bat.

jherb
  • 392
  • 2
  • 11
0

Open the dev command prompt type "where devenv" then call the full path with the .com version... e.g.

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com" /Rebuild "RELEASE|Win32" "F:\project.sln"
kierzo
  • 113
  • 4
0

For my part, I had to convert the Visual Studio 2015 SSRS project to SSRS Visual Studio 2017. Then I installed the 2017 SSDT for VS 2017, and use MSBUILD. Everything works well without open remote session.

Hugues Gauthier
  • 639
  • 8
  • 18