I have a Silverlight 3 project with something like this:
<ItemGroup>
<Content Include="Content\image1.png">
</Content>
</ItemGroup>
Basically I've added a PNG file to my project and set its build action to "Content". This works nicely.
Now what I'd like to do is be able to add images in a different format to my project, and have them converted to PNG at build time - so that the end result is as if I had added a PNG image to the project (as Content) in the first place.
In other words - I want the image to appear, in PNG format, in my XAP package.
Ideally I would like to do this in such a way that it will work with Visual Web Developer 2008 Express (so I can add image files to my project by dragging them into the IDE and maybe changing their build action), and without making any system-wide changes.
The specific format I want to convert is XCF - I already have the .NET code to do the conversion to PNG. I am assuming that I must create a MSBuild Task.
I don't really have much MSBuild experience, and I'd like to know how to put such a thing together.
Based on my rough understanding of how MSBuild works, I think that I need to know:
- How to create a collection of items by (re)moving them from the
@(Content)
(or some other) collection, based on their file extension?- OR: Create a custom Build Action I can use in Visual Web Developer 2008 Express
- How to recieve the path of input items in a
Task
? - Where (.NET or MSBuild?) and How to specify the location of output files generated by a
Task
? - How to ensure that a file is rebuilt if its input file changes?
- Where (probably
BeforeBuild
?) and How to reinject the converted items into@(Content)
? (Or should I use some other collection?)- OR: Some other way of getting them into the XAP?
And if this seems like a reasonable way to do things or if I've missed anything?