I want to change name of executable file. Like suppose my project name is "SampleDemo" It will create executable file Like 'SampleDemo.exe' but I want to rename it to 'Demo.exe'
-
1msdn.microsoft.com/EN-US/library/ms247046(v=VS.120,d=hv.2).aspx– SteveFeb 3, 2015 at 14:19
-
1@skrrgwasme - Not quite, Kiran's asking how to change the name of the output from a VS project.– 4444Feb 3, 2015 at 14:20
-
2If like me you wanted to change the output file name without changing the assembly name, see stackoverflow.com/a/44188341.– jnm2May 25, 2017 at 19:21
6 Answers
- Open the Project Properties in Visual Studio (right click on project in Solution Explorer and select "Properties" from popup menu)
- On the "Application" tab of the properties window, change the "Assembly name"
-
@KiranDesai I think you are editing the AssemblyInfo.cs file. You need to edit the project properties instead. I've clarified this in my answer. Feb 3, 2015 at 14:50
-
-
1Can I change Exe file name based on command line arguments during pre-build or post-build events? Mar 20, 2016 at 13:47
-
3If like me you wanted to change the output file name without changing the assembly name, see stackoverflow.com/a/44188341.– jnm2May 25, 2017 at 19:24
If like me you wanted to change the output file name without changing the assembly name, put this like in your .csproj's main <PropertyGroup>
:
<TargetName>Desired output name without extension</TargetName>
-
5this worked like a charm. Except now debug process cannot find the executable anymore .. Jul 4, 2017 at 12:01
-
1
-
2This did not work for me. I get a build error that the exe cannot be found. Jan 15, 2019 at 20:07
-
1For anyone reading this for .Net 5+ - this will only change the
*.dll
and*.pdb
file names, it won't change the*.exe
name AND the application will still look for itsoriginal name.dll
. I.e. if your project is named "Test" but you put<TargetName>Change</TargetName>
you will see the following files in the build output:Test.exe
,Change.dll
andChange.pdb
(depending on settings). So, building or running the application (Test.exe
) will fail withThe application to execute does not exist: (path to dir)\Test.dll
. Yes, there is an ancient open issue for this. Feb 24, 2022 at 12:23 -
1@Tessaract <AssemblyName> works on .NET 6. Not sure about earlier versions. May 9, 2022 at 19:35
By MsBuild:
<Target Name="Rename" AfterTargets="AfterBuild">
<Move SourceFiles="$(OUTDIR)\Application1.exe" DestinationFiles="$(OUTDIR)\ApplicationNew.exe" />
<Message Text="Renamed executable file." Importance="high" />
</Target>
Change ApplicationName is not best way. For example if you used wpf resources, full path contains ApplicationName and after renaming executable file you need to change all full pathes in out application
<ResourceDictionary Source="pack://application:,,,/Application1;component/Themes/CustomStyles.xaml"/>
In this situation I used msbuild.
-
1This is nice because if you replace Move with Copy, debugging will still work (the other answer's problem is not fixed for me as of VS2017) Mar 28, 2019 at 18:09
For me none of the answers worked in net6.
In my csproj
file:
<PropertyGroup>
<AssemblyName>MyCustomExecutableName</AssemblyName>
</PropertyGroup>
Tested in Net6, Windows. Using VS Code and buiding with dotnet run
.
This will change both the executable name and the dll file name.
-
1Without touching the csproj file, the output assembly name can also be specified by passing the MSBuild property via the command line: /p:AssemblyName=MyCustomExecutableName– oliJul 19, 2022 at 15:17
"Post-build event command line" in Build Events tab, would be an option. You can use:
copy $(TargetPath) $(TargetDir)demo.exe /Y
or
ren $(TargetPath) $(TargetDir)demo.exe /Y
Double Click 'My Project'
Click 'Package Manifest...'
Click 'Application'
Under 'Display Name' fill in the name you want your exe to be called.
In your case it would be: 'Demo' since you want the project name 'SampleDemo' to have an output exe named 'Demo'