mslliviu
mslliviu

Reputation: 1138

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?

Upvotes: 8

Views: 3224

Answers (2)

user1169420
user1169420

Reputation: 830

Dotnet core 3.0 added the functionality of versioning the shim exe during publish, like OP was expecting. It should work out of the box now. However that feature does not function if running builds on a Nanoserver based docker environment.

warning NETSDK1074: The application host executable will not be customized because adding resources requires that the build be performed on Windows (excluding Nano Server)

Upvotes: 0

Martin Ullrich
Martin Ullrich

Reputation: 100751

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.

Upvotes: 8

Related Questions