Compiling multiple win32 resources into an assembly

C

coad.munky

Hi,

I have a build process in which my .NET projects get compiled using a
common version resource which is compiled into a .RES file. My
project files import a shared MSBuild file which uses the
Win32Resource tag. eg:

(abbreviated for readability)

MyCommon.targets:
----------------
<PropertyGroup>
<Win32Resource>version.res</Win32Resource>
</PropertyGroup>

MyExe.csproj
------------
<PropertyGroup>
<ApplicationIcon>app.ico</ApplicationIcon>
</PropertyGroup>
<Import Project="MyCommon.targets" />


The problem is that when I try to build MyExe.csproj I get the
following error:

CSC : error CS1565: Conflicting options specified: Win32 resource
file; Win32 icon

because apparently Win32Resource and ApplicationIcon tags are mutually
exclusive. To get around this, I compiled the application icon into a
new .RES file and added it to the project using the Win32Resource
tag. eg:

MyExe.csproj
------------
<PropertyGroup>
<Win32Resource>app.res</Win32Resource>
</PropertyGroup>
<Import Project="MyCommon.targets" />


The build error goes away, the file is versioned correctly, but
there's no application icon -- the EXE has the generic icon. It looks
like the resource in MyCommon.targets overrides the one defined in my
executable project. If I remove the Win32Resource tag in
MyCommon.targets, then my EXE has the right icon, but then it doesn't
get versioned.

So my question is, how can I specify multiple Win32Resource tags? I'd
like to do something like

<PropertyGroup>
<Win32Resource>$(Win32Resource);version.res</Win32Resource>
</PropertyGroup>

....in MyCommon.targets to append to a list. BTW, I've tried that
syntax and it doesn't work. I get the following error:

CSC : fatal error CS2021: File name 'app.res;..\version.res' is
too long or invalid

Thanks,
CM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top