Removing Sticky Packages from Delphi Projects

In the Delphi IDE, when working on a project, you open a package (.dpk), then close the package. However, when you open the project at a later date the package “sticks” to the project. In other words, the package is listed in the Project Manager window. Sometimes the package becomes the default active project, so when you compile your project, the package is compiled rather than your project. This forces you to go to the Project Manager window and activate your project before you can compile. It’s annoying.

The cause of this is that when you close a project, the IDE remembers which windows you had open, breakpoints, and other IDE state information for that project. It does this by storing the layout in the desktop (.dsk) file. For some reason, even when you completely close the package file, the Delphi IDE remembers the package in the same way that it remembers the files you have open in the IDE. This does make sense on one hand. Packages are more than a source file, but less than a full-fledged project. However, packages have side effects that normal source files don’t. This is why the package seems to be “sticky”, showing up every time you reopen the project, and possibly interfering with your work on the project.

To get rid of the pesky “sticky” package there are two options. For both of these, do not have the project open in the Delphi IDE. If you do, you’ll end up overwriting your fix when you close the project and the IDE rewrites the desktop file.

Method #1

If you don’t care about which windows you had open, breakpoints, etc. you can just delete the whole .dsk file. Bam!

Method #2

On the other hand, if you want to preserve the IDE state without the “sticky” package, deleting the entire desktop file is too draconian. You’ll have to edit it. This is pretty simple. The desktop file is in Windows INI format. Open it up in your favorite text editor. (As an old Un*x head, I like vim.) Search for the name of the package’s file name, and delete the offending INI sections. Save the desktop. When you reopen the project, the IDE will not see any references to the package. Thus the pesky package will not show up anymore.

Leave a Reply