开发者

Remove {$R *.res} in package.dpk file will remove the rccompile in .dproj file

I use my own .rc file to generate custom resource entries including version info.

My library.rc file is :

#include "app.rc.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION _FileVersion
PRODUCTVERSION _FileVersion
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x0409, 1252
  END
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904E4"
    BEGIN
      VALUE "InternalName",       App_InternalName "\0"
      VALUE "CompanyName",        App_CompanyName "\0"
      VALUE "FileDescription",    App_ProductName "\0"
      VALUE "FileVersion",        _FileVersionStr "\0"
      VALUE "ProductName",        App_ProductName "\0"
      VALUE "ProductEdition",     App_ProductEdition "\0"
      VALUE "LegalCopyright",     "Copyright \251 " App_CompanyName "\0"
      VALUE "CompanyURL",         App_CompanyURL "\0"
      VALUE "ProductURL",         App_ProductURL "\0"
      VALUE "SupportURL",         App_SupportURL "\0"
      VALUE "AppRegistryPath",    App_RegistryPath "\0"
    END
  END
END

I add the .rc file into the package project file via Project | Add to Project. My package.dpk file is something like this so far:

package SQL.Alpha.resource.core;

{$R *.res}
{$R 'library.res'}
{$ALIGN 8}

The package.dproj file has RcCompile entry:

<RcCompile Include="..\..\build\rc\library.rc">
    <Form>library.res</Form>
</RcCompile>

When I c开发者_运维问答ompile the package, everything looks good but it has a warning:

[DCC Warning] W1056 Warning: Duplicate resource:  Type 16 (VERSIONINFO), ID 1; File library.res resource kept; file package.res resource discarded.

This is due to the package itself generate it's own package.res file that include MainIcon and VersionInfo entries. And the VersionInfo has conflict with my own VersionInfo entry.

I then attempt to remove {$R *.res} in the dpk file:

package SQL.Alpha.resource.core;

{$R 'library.res'}
{$ALIGN 8}

Rebuild the project and everything works fine. The warning is gone.

However, there are some side effects removing {$R *.res} manually:

  1. Delphi IDE will add the {$R *.res} again if you attempt to add new unit in package or make and changes in Project | Options...
  2. All RcCompile entries in .dproj file will be removed

I can tolerate with first side effect by removing {$R *.res} again in package.dpk file.

However, the 2nd side effect is out of my control. The missing RcCompile in package.dproj will cause the rc file not to compiled by brcc32 again. Removing the .res files in file system will cause error in compilation due to this.

Does anyone has ideas how to overcome this problem? Thank you.


In Delphi XE2, you may now remove the built-in version information of Delphi package (*.bpl) via Project | Options. Navigate to "Version Info" package, and uncheck "Include version information in project".

By doing this, the built-in version information will not generated in *.res files and thus the compiler warning message will not show. You may use your customized *.rc files as wish.


I had trouble getting this to work and finally resorted to using build events. It would be nice to just include the rc file directly. But if you don't get a different answer that works you can add this to your Pre-Build event:

brcc32 "$(PROJECTDIR)\version.rc"

Then just include the compiled file resource file with {$R version.res}. You don't need to add the .rc file to the project.

For the VersionInfo conflict look at the project option for version information. There is a check box at the top for "Include Version" information. If you uncheck that you can leave the {$R *.res} in place with no conflict.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜