使用dotnet发布时设置exe文件版本

msl*_*viu 6 .net c# .net-core visual-studio-2017

我有一个net core consoleapp项目,如下(VS 2017风格):

<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>
Run Code Online (Sandbox Code Playgroud)

我可以毫无问题地构建项目,我可以使用dotnet publish -r win10-x64发布它,它将与dll文件一起生成exe文件.我的问题是exe文件有一些奇怪的FileVersion和ProductVersion字段(在我的例子中FileVersion = 1.0.1.4500和ProductVersion 1.0.1.cee57 ...(一些guid)).其余的文件详细信息(名称,版权)与dotnet而不是我自己的项目有关.

发布时有什么方法可以控制exe细节吗?

Mar*_*ich 7

不,您项目的主要构建输出仍然是一个.dll文件,.exe(或linux,mac可执行文件)文件已被复制并重命名dotnet.exe(或者在即将发布的2.0版本中,apphost.exe其dll名称可以嵌入运行)。

exe文件只是引导运行时然后加载dll的助手。但是,您可以尝试使用二进制编辑工具editbin.exe(如(VS C ++工具))在发布后修改文件。