8

I want to rename the project exe output in visual studio 2010. Following the post Rename project output before being included into Setup project I always get the error The command rename ... exited with code 1

My command is:

rename $(TargetDir)$(TargetFileName) newname.exe
Community
  • 1
  • 1
Maro
  • 2,579
  • 9
  • 42
  • 79

3 Answers3

13

Here is a correct command for the Post-build event

rename "$(TargetPath)" "newname.exe"
GenZiy
  • 1,427
  • 2
  • 15
  • 20
9

I want to rename the project exe output in visual studio 2010.

I suggest you go into the project settings and change the output assembly name then. That's going to be far simpler and more reliable than using a post-build event.

It's possible that the fact that your current post-build command has an unmatched double-quote is the problem, but I wouldn't try to fix it - I'd just avoid it.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • For me, this is still coming out as setup.exe despite my assembly name being something else – Ben Jul 17 '13 at 18:52
  • @Webnet: Are you should you're not building an installer binary? I've never seen anything automatically create a setup.exe file other than for installers... – Jon Skeet Jul 17 '13 at 19:00
  • I don't know... This is my first C# app, so maybe I am? How can I check and/or change it so it comes out as `MyApp.exe`? – Ben Jul 17 '13 at 19:05
  • 1
    @Webnet: Well what project type have you got? It feels like you should probably start a new question with all the relevant information, to be honest - it's not ideal for a comment thread here. – Jon Skeet Jul 17 '13 at 19:08
2

I use the Post-Build to execute a Batch file and/or PowerShell script to do whatever you want:

Post-Build cmd:

if "$(ConfigurationName)" == "Release" start "Version" /D "$(SolutionDir)" /WAIT Version.bat

Version.bat:

@powershell -ExecutionPolicy Unrestricted -File "%~dp0Version.ps1"

IF ERRORLEVEL 1 (
    echo ERROR
    pause
) ELSE (echo OK)

Version.ps1:

# A lot of possibilities here
$scriptDirectory =  [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Definition)
Brock Hensley
  • 3,617
  • 2
  • 29
  • 47