Project Options - Output Directory

Project Options - Output Directory

For first time, I finally paid attention to the Project Options of the project I'm working on. I noticed that the Output directory is set to

.\$(Platform)\$(Config)

This must be the out-of-the-box default setting for D10S. I have found this to be a real pain in the ass when referencing files based on the relative location of the exe.

I just realized that setting this value to a . (period) puts the executable in the same directory as the source files.

How do you set the Output directory default value to a . (period) so all new projects will use this value?

What is your best practice for setting up the Output directory and any other directories?

Comments

  1. .\bin, .\bin64 and dcus go to .\dcu .\dcu64

    ReplyDelete
  2. Michael Riley This is something I'd like to know, too for different reason. The above setting makes compiler place the built apps in folders like ".\Win32\Debug" or ".\Win64\Release".

    Are you sure you want all those files in the same directory as the source files? It will be a mess and files will replace each other, which means that you will not be able to execute both Win32 and Win64 without re-building.

    ReplyDelete
  3. Agustin Ortu do you do this each time you create a new project? Is it possible to set these values as default values for every new project?

    ReplyDelete
  4. I workaround around it. I created an empty Vcl app with those settings, and when I create a new project I just copy that instead of using the IDE wizard

    ReplyDelete
  5. I believe they store the values somewhere in the registry.

    ReplyDelete
  6. You can't change the default. I actually like the settings, but I actually use a couple dots.
    ProjectFolder
    ProjectFolder\_project (dpr/manifest/icon/etc)
    ProjectFolder\_forms
    ProjectFolder\_pasonly
    Projectfolder\win32\release
    Etc

    ReplyDelete
  7. John Kouraklis No I'm not sure. I use ElevateDB and I have been referencing a CSIDL_COMMON_APPDATA path location for the database because I did not want to have 4 copies 32Debug, 32Release, 64Debug, 64Release. This would allow me to reference a database path relative to ExtractFilePath(ParamStr(0)).

    ReplyDelete
  8. Michael Riley that's what I do for my ElevateDB stuff if I'm referencing the same data from any release. I also have a flag that is set when my app launches and it's under debugging in the IDE. It allows me to change base paths to files to be in my project folder or in normal common directories.

    ReplyDelete
  9. Michael Riley I see what you mean. In this case, you can use the .Parent property twice starting from the ExtractFilePath(ParamStr(0)) and you will get the folder of the source files.

    ReplyDelete
  10. Michael Riley you can use ifdefs:

    {$IFDEF DEBUG}
    DBPath := insert-your-debug-db-path-here
    {$ELSEIF}
    DBPath := insert-your-production-db-path-here
    {$ENDIF}

    Then its just a matter of putting the right thing into that var ie, hard-coded absoulte path, relative path, looking up using enviroments vars, etc

    ReplyDelete
  11. I use PostBuild events to copy the files to the right location. The output folders can be purged at any time.

    ReplyDelete
  12. I always put the sources into a subdirectory "source" and set the output directory to "..\". So I have the executable in the main directory of the project where I also put the supporting files like DLLs, configuration files (if any) and data files. (Most of my projects are "portable apps" that live in their main directory). I also set the dcu output dir to "..\dcu" so they don't clutter the source directory. And yes, I do that manually for each new project.

    ReplyDelete
  13. I think it you leave it blank it is the same thing a period.  As for the default, I don't think you can change it.  As a rule of thumb, the first thing I do is setup my project options on each new project.  Compile options, some warnings as errors, output directories, conditionals, etc.  Your "copy a blank project" is probably the best option since nearly everyone has a different opinion of what a project's defaults should be :)

    ReplyDelete
  14. I was sure that if you didn't have a project open and you went to Project -> Options... you could set the default but that ability seems to have disappeared, or was I dreaming?

    ReplyDelete
  15. In XE at least, if you do not have a project open, there is an option under Project->Default Options->Delphi where you can indeed set defaults.

    ReplyDelete
  16. Thanks Ryan McGinty. Just checked Seattle and Berlin and it is not present in either :-(

    ReplyDelete
  17. Nicholas Ring I have MMX, DDevExtensions, and GExperts installed. I looked at the source for GExperts and I don't see it in there. I'm not sure if it is a core IDE feature or added by one of those add-ins. I do not have my Berlin setup going yet but will verify that it is indeed missing (after I get the add-ins installed).

    ReplyDelete
  18. Default Project Options was ever a core IDE feature, it existed in Delphi XE and before. Don't know when and why it was removed.

    ReplyDelete
  19. Ryan McGinty I have the same add-ons installed (and a few others) for XE, Seattle and Berlin, so it isn't an add-on that has but the core IDE system :(

    ReplyDelete
  20. Nicholas Ring Good to know.  Odd.  It's only a guess, but I wonder if adding all the different configs made the feature too hard to maintain.  XE was Win32 only.  You'd pretty much have to implement default options for each type of target, making it a much more complex feature at that point...

    ReplyDelete
  21. Default project options was a standard IDE feature up to Delphi XE. It no longer exists in XE2:
    http://download.dummzeuch.de/DelphiXE-default-Project-Options.png

    ReplyDelete
  22. Having the output executable into the current directory is a bad practice unless you don't care to ever ship release binaries, but debug the debug ones.

    ReplyDelete
  23. It suits me very well having that dcu path (default). I sometimes change the exe output path though and the annoying thing is that you have to select "All platforms" to get a consistent change over all platforms and debug/release combination. There's some havoc when i forget to select a higher level. Goes for the version numbers too.

    ReplyDelete
  24. I asked the same question once in StackOverflow. And had the exact same answer: the default project options used to exist until XE, but then it was removed. I'd be OK with it, as long as I could edit the registry and change the settings myself, but it is not there either. Is hard to believe that the default project options are hard coded, but seems that this is the case... Embarcadero: please, at least, store the default project options somewhere in the registry so we can change them!

    ReplyDelete

Post a Comment