April 13, 2004

building embedded resources using csc

Info on this is scarce so I thought I'd contribute some. It's often desirable to store, say, images in external files rather than throw them all into a resx xml resource file. So you add them to your vs.net csharp project--oftentimes a resource-only dll--as embedded resources. Works great until you want to compile it directly from the command line.

Using this KB article and the docs for vs.net's csharp compiler options I arrived at this:

csc.exe /out:Resources.dll /target:library /res:image.png,Resources.image.png Resources.cs

The tricky thing here is that the ms docs for the /res option only mention using it with .resources files, which are compiled resx files. But in fact you can embed any sort of file in there. The "Resources.image.png" part identifies the resource and puts it under the Resources namespace, which is what vs.net will do when specify a default namespace for the project.

Posted by Alan at April 13, 2004 11:40 PM
Comments
Post a comment












Remember personal info?