Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup exe file version when publishing with dotnet

I have a net core consoleapp project, as follows (VS 2017 style):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <Version>2.0.0</Version>
    <AssemblyVersion>3.0.0.0</AssemblyVersion>
    <FileVersion>4.0.0.0</FileVersion>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
  </PropertyGroup>
</Project>

I can build the project without any issues, I can publish it using dotnet publish -r win10-x64 and it will generate an exe file together with the dll file. My problem is that the exe file has some strange FileVersion and ProductVersion fields (in my case FileVersion = 1.0.1.4500 and ProductVersion 1.0.1.cee57... (some guid)). Also the rest of the file details (name, copyrights) are related to dotnet instead of my own project.

Is there any way I can control the exe details when publishing?

like image 280
mslliviu Avatar asked Apr 20 '17 10:04

mslliviu


People also ask

How do I Publish an EXE file?

Under the file menu, you will find "Publish as EXE". A Wizard will walk you through the necessary steps. The compiler has two steps: The first step requires that you run your script so that all dependencies (across your project files, Vizard modules, Python, etc) can be identified.

How is .EXE file created in C#?

First, right-click on the project and then hit Publish, then select folder and click create. Click the edit button to edit the configuration. In the publish configuration you can check the single EXE option. Once ready, save and click Publish.


1 Answers

No, the main build output of your project still is a .dll file, the .exe (or linux, mac executables) file is a copied and renamed dotnet.exe (or in case of upcoming 2.0 versions, apphost.exe with the dll name to run embedded).

The exe file is only a helper that boots the runtime and then loads your dll. However, you can try to use binary editing tools like editbin.exe (VS C++ Tools) to modify the file after publishing.

like image 140
Martin Ullrich Avatar answered Oct 25 '22 06:10

Martin Ullrich