Author Topic: Custom build command help  (Read 4444 times)


  • Community Member
  • Posts: 11
  • Hero Points: 0
Custom build command help
« on: September 01, 2009, 08:55:04 pm »
I'm having trouble with v14, getting the custom build commands to work.  Essentially, I have it set up to run a batch file that sets environment variables and runs a prep script first.  In previous versions I had had this as a custom tool that was "Set Env" and would simply run my batch file in the build output window.  But with this version, the environment variables set don't persist in the output window environment and my build won't run without these.  I don't want to use "Set Environment" option on the build command because the environment variables are project dependent and it's my script that takes care of all this.

I have the Project Properties set for "Build with a user-maintained makefile..."

Currently the only way I can get it to work is to run the "Set Env" build tool, which opens the windows and then run my prep batch file manually.
Thoughts on what changed from v13 and how I can get this to work a little more seamlessly?

I'm using v14.0.2.2 on Windows 7 (but had the same problem on XP).

« Last Edit: September 01, 2009, 09:01:12 pm by JRen »


  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Custom build command help
« Reply #1 on: September 01, 2009, 11:33:59 pm »
When a build tool executes in SlickEdit, vsbuild is invoked in the Build window shell and vsbuild spawns a new process that will execute the command-line.  The environment variables that get set are only set in this spawned process and they are gone when the command and vsbuild terminate.    This is very much, by design, and it does differ from previous versions of SlickEdit. In earlier versions, some build tools would execute directly in the process shell and some would handled by vsbuild.  Now every build tool is handled by vsbuild by default.  In previous versions, Set Env script must have been executed directly in the process shell, and the vsbuild would then inherit the enviroment.

The simplest solution is to set your Build tool command to call a script that first invokes your prep script, then invokes your build script.  You could also use Project Properties > Tools> Advanced... > Set Environment Variable to manually set them.  These vars will be set in vsbuild when it executes the tool.  You could also set the enviroment vars in Workspace Properties > Environment....

If none of those work, there is an option to force the tool to not use vsbuild and to execute directly in the process buffer for legacy support.  It does require manually the project file (.vpj), as there is not a GUI option in Project Properties.  The project file is XML, so it's fairly logical to navigate.  You'll need to find the specific <Target> by name that you need to modify in each configuration (tree looks like this <Project><Config><Menu><Target>...</Target></Menu></Config>...</Project>).  Add this attribute to the Target tag, NoVSBUILD="0".  Should look like this:
    Name="Set Env"
    MenuCaption="&amp;Set Env"
    <Exec CmdLine="setenv.bat"/>
Try one the solutions, let us know if they work for you or if you have any other issues.