views:

349

answers:

3

Hi

I have an exe that is built and placed into a Setup project for deployment. I want to rename the exe that is produced (to a .scr file - it is a screensaver) before inclusion in the setup project. How do I do this?

I know I could rename the file in a post install process but I don't want to do it this way, I want the file to be renamed before inclusion into the setup project

Any help would be great thanks I am using Visual Studio 2008 and the program is written in C#

Thanks

+1  A: 

You could add the rename command as a post build event on the project (the project that builds the exe, not the setup project).

Right click on the project and go to "properties". Then in the tabs on the left hand side choose "Build Events".

In the post build command line box you can enter your rename command. If you click on the edit button there are some helper macros that you'll find useful for including the build output/project directories in your command line.

Simon P Stevens
I have tried this but get an error: (i tried with and without the del)Error 1 The command "del "screensaver.scr"rename "D:\App Development\ScreenSaver\ScreenSaver\bin\Release\Screen Saver.exe" "screensaver.scr"" exited with code 1. ScreenSaver
Chris
@Chris: Try looking in the output window, you might find a more detailed error message.
Simon P Stevens
It says the following:A duplicate file name exists, or the file cannot be found.- How can I make this error silently or overwrite?
Chris
Change the command to "move /Y oldfile.exe newfile.svr". The /Y switch on the move command sets it to automatically overwrite if the newfile already exists. For some reason rename doesn't have this option.
Simon P Stevens
A: 

An item in setup projects in VS2005 has a TargetName property. Does 2008 have that and will it work for you?

JeffH
A: 

I found the answer on the MSDN

You need to setup some AfterBuild events in your csproj file (manually edit it), here is what mine looks like

<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetDir)\$(TargetName).exe" DestinationFiles="$(ProjectDir)\bin\$(ConfigurationName)\smileyscreensaver.scr" SkipUnchangedFiles="true" />
</Target>
Chris