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'
- 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"
To change the output file name without modifying the assembly name, you can include the following line in the primary <PropertyGroup>
of your .csproj file:
<TargetName>Desired output name without extension</TargetName>
*.dll
and *.pdb
file names, it won't change the *.exe
name AND the application will still look for its original 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
and Change.pdb
(depending on settings). So, building or running the application (Test.exe
) will fail with The application to execute does not exist: (path to dir)\Test.dll
. Yes, there is an ancient open issue for this. –
Anzus 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.
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.
"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'
For a UWP app, right-click on the solution in Solution Explorer and select Rename.
If this is a .NET Core app being publish
ed then this does the trick:
<Target Name="RenameOutputExecutable" AfterTargets="Publish">
<Move SourceFiles="$(PublishDir)$(AssemblyName)" DestinationFiles="$(PublishDir)new-name-here"/>
<Message Text="Renamed executable file from $(PublishDir)$(AssemblyName) to $(PublishDir)new-name-here" Importance="high"/>
</Target>
This will only take effect when publishing.
© 2022 - 2025 — McMap. All rights reserved.