Ever since around Delphi 2007, it started to use temporary .VRC files to re-build the project .RES file.
It confuses people, and with reason as the only public information about it on the dockwiki seems to be in the Version Info page (though there is more on the other embarcadero sites).
The reason is that parts of the .RES file are no more leading in the process of getting them from your project options to the final binary (EXE/DLL/BPL/…) of your project.
Delphi XE3 for instance can have these resource structures in the .VRC file:
- VERSIONINFO (usually called “1″)
- ICON (called “MAINICON”)
- 24 (called “1″; 24 is in fact a numeric alias for MANIFEST)
- RCDATA (called “PLATFORMTARGETS“)
Except for type 24, Delphi XE2 seems to have the same kinds of resource types.
All in all, most if not all of the .RES files are being auto-generated for at least a couple of years now so there is less and less need to put it under version control.
The problem is that if for one reason or the other, your project .RES file becomes readonly, and you get errors like mentioned in Why does a projects res file need to ….
[BRCC32 Error] xxx.vrc(1): error creating xxx.res
.RES in VCS or not?
Most people bump into the readonly .RES issue.
There are various opinions on having your .RES in version control or not. I think ultimately you shouldn’t, but it takes quite some effort to store ALL options in text files and generate the complete .RES file on the fly. For more on that, see for instance:
- delphi – How to define application version in one place for multiple applications? – Stack Overflow.
- DDevExtensions 2.8 | Andy’s Blog and Tools.
- dzPrepBuild for Delphi (English).
- dzPrepBuild for Delphi | Free Development software downloads at SourceForge.net.
- A collection of buildtools » twm’s blog.
- .manifest support in dzPrepBuild » twm’s blog.
This takes a while to implement in projects, so for those having occasional read-only .RES issues, here is a trick:
Failing prebuild-event to make your .RES file writeable
I’ve tried to include this pre-build event in some projects that suffered from readonly .RES files most:
if exist $(PROJECTDIR)\$(PROJECTNAME).res attrib -r $(PROJECTDIR)\$(PROJECTNAME).res
But it doesn’t work: the BRCC command is executed *before* the pre-build starts:
Build started 11/27/2013 3:19:34 PM.
__________________________________________________
Project "C:\develop\md5sum\md5sum.dproj" (Make target(s)):
Target BuildVersionResource:
...\bin\cgrc.exe -c65001 md5sum.vrc -fomd5sum.res
CodeGear Resource Compiler/Binder
Version 1.2.2 Copyright (c) 2008-2012 Embarcadero Technologies Inc.
...
Deleting file "md5sum.vrc".
Target PreBuildEvent:
if exist C:\develop\md5sum\md5sum.res attrib -r C:\develop\md5sum\md5sum.res && echo ensured read-only C:\develop\md5sum\md5sum.res
ensured read-only C:\develop\md5sum\md5sum.res
...
0 Error(s)
Time Elapsed 00:00:01.37
So you must make sure the .RES files are read-write before you start compiling:
Working solutions to make your .RES file writeable
The most simple solution is to just make all .RES files read-write:
attrib -R /s *.res
attrib /s *.res
Or you could write/use an IDE expert that allows you to make certain files read-write again, like Making Source writable from the Delphi IDE – Stack Overflow.
Quotes from the interesting thread via Why does a projects res file need to …:
The version control issue:
I have recently migrated from Delphi 7 to Delphi XE 2 and use a version control system to store my work.
I book in the following project files:
- cfg
- dof
- dpr
- dproj (new for Delphi XE 2)
- res
In previous versions of Delphi this was fine, I could leave these files read only, compile and build the project without issue. When I compile my project now I get the error:
[BRCC32 Error] xxx.vrc(1): error creating xxx.res
This is resolved when I make the project res file writable, but this is a little bit annoying, especially when the file does not change.
The reply by Mark Edington:
This was a design change made to support multi-platform projects.
The fact that the file has to be re-written even when it hasn’t changed is something that I would consider a bug. I’d recommend you log a QC report outlining your issue.
There is an undocumented property you can add to your .dproj file which will prevent the build process from ever generating the .res file. If you add the following below the first section of your .dproj file it will turn off the .res file generation:
Be aware that this will effectively disable your ability to edit the project file settings stored in the project .res file from the IDE.
Hopefully you enjoy these bits of info as much as I did when researching them.
–jeroen
via:
- Embarcadero Discussion Forums: Why does a projects res file need to ….
- delphi – What Is a .vrc file, how is is generated and can you remove it using the IDE? – Stack Overflow.
- Delphi 7 to Delphi XE2 .res file issue – Stack Overflow.
Filed under: Delphi, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Software Development