Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

devenv.com won't start without a desktop session

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.

like image 823
Gianpolo Avatar asked Mar 21 '26 20:03

Gianpolo


1 Answers

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.

like image 75
jherb Avatar answered Mar 23 '26 11:03

jherb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!