Using relative paths in a project is a good idea - they make a project more maintainable, readable and portable.
However, lately I've seen quite a few sample FinalBuilder projects where people are using this kind of relative path in their actions:
MySolutionFile.sln |
.\MyProject\Installer\Project.iss |
..\..\MyOtherProject\MyProject.dproj |
The idea is that if the file is located relative to the project file path, the relative path will resolve to the right directory.
Great idea, right? Unfortunately, no.
These relative paths rely on the current Windows working directory for the process. Unfortunately, FinalBuilder and Automise only have limited control over this property. Various API calls (made by actions, scripts or the IDE) might change this directory unexpectedly.
The safe way to use relative paths in a FinalBuilder or Automise project is to use the variable %FBPROJECTDIR% (called %PROJECTDIR% in Automise.) This variable evaluates to the directory which contains the current project file.
Unsafe |
Safe |
MySolution.sln |
%FBPROJECTDIR%\MySolution.sln |
.\MyProject\ |
%FBPROJECTDIR%\MyProject\Installer\Project.iss |
..\..\MyOtherProject\MyProject.dproj |
%FBPROJECTDIR%\..\..\MyOtherProject\MyProject.dproj |
We recommend defining new project variables to prevent these paths from becoming too long and unwieldy, and to make your project easier to read.
For instance, you could define a project variable called InstallerPath and set it to %FBPROJECTDIR%\MyProject\Installer. Turn on the "Macro" option for the InstallerPath variable to make sure variable references are expanded each time the variable is read.