使用 dotnet 发布时设置 exe 文件版本 [英] Setup exe file version when publishing with dotnet

查看:60
本文介绍了使用 dotnet 发布时设置 exe 文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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>

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

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.

有什么办法可以控制发布时的exe详细信息吗?

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

推荐答案

不,项目的主要构建输出仍然是 .dll 文件,.exe(或 linux、mac 可执行文件)文件是复制并重命名的 dotnet.exe(或者在即将推出的 2.0 版本的情况下,apphost.exe 带有要运行的 dll 名称).

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).

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

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.

这篇关于使用 dotnet 发布时设置 exe 文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆