Question : read-only output file

This is one of those questions which might not have an answer, but I'm still interested in any opinions, and I'll award points even if I don't get an answer I like...

I am using visual studio.NET 2002 to build my project.  My project is a windows application that loads a .bmp file at startup to use for toolbar images.  This file is called UserImages.bmp.  The application has to set the UserImages.bmp file to read-only to prevent a 3rd party library from modifying it (unfortunately there is no other way around this - trust me on that because I have tried lots of alternatives).  To ensure that the UserImages.bmp file is available to the app when I run the release executable, without having to take any extra manual steps, I copy it from the source code tree to the release directory as a custom build step in my project build configuration.  The custom build step for the file UserImages.bmp looks like this:

Command: xcopy "$(InputPath)" "$(TargetDir)" /C /R /Y /F
Description: Copying Support File to Release Directory: $(InputFileName)
Outputs: $(TargetDir)$(InputFileName)
Additional Dependencies: "$(InputPath)"

Since I use xcopy/R, the custom build step will overwrite the file if it is read-only, which is exactly what I want.  However, if I "clean" the project or do a rebuild-all, the operation fails because visual studio .NET won't delete the UserImages.bmp output file $(TargetDir)$(InputFileName) if it is read-only, which it usually is.  This causes my build to fail until I manually delete the output copy of UserImages.bmp or manually remove its read-only attribute.

Is there some way I can configure visual studio to go ahead and delete read-only files in cases like this?  Or configure it to not even try to delete the output copy of UserImages.bmp?  Or configure it to assume that failure to delete a file is not an error?  Or configure it so that it automatically removes the read-only flag from UserImages.bmp before trying to clean anything (ie. like a custom pre-clean step of "attrib -r UserImages.bmp")?  Any other suggestions?

One solution which works but which I reject is to blank-out the "Outputs" configuration of the custom build step.  That way it doesn't consider the output copy of UserImages.bmp to be a file that it should delete when it does its cleanup.  However, that also causes visual studio to always think that the project is out-of-date when I try to run it in the debugger, which is more annoying than the current problem.  The problem there is that visual studio is not able to determine when it needs to run this custom build step if the Outputs are blank, and in that case it assumes it must always run the custom build step.

Another solution which seems like it *should* work, but doesn't, is to remove *.bmp from the list of file types to delete on cleanup (in project configuration...general...extensions to delete on clean).  Unfortunately, Visual Studio apparently doesn't actually do anything with that list, because it still tries to delete the read-only file.  My guess is that any explicit outputs of the project are always deleted despite what file types are listed in that "extensions to delete on clean" option.

Answer : read-only output file

it appears that visual studio .Net 2003 fixes this problem over 2002 because I have not seen it happen for a long time and I even forgot all about this.  So yes, I would appreciate it if you would please delete the question and refund my points.
Random Solutions  
 
programming4us programming4us