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

标签 c# .net .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>

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

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

最佳答案

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

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

关于c# - 使用 dotnet 发布时设置 exe 文件版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43516625/

相关文章:

c# - 如何将子类属性映射到每个层次结构的表中的列?

c# - 当应用程序进行全局化和本地化时,我必须做和不应该做的事情是什么?

visual-studio - GetEnvironmentVariable 应该在 xUnit 测试中工作吗?

c# - 从用于外部登录身份验证的 Twitter API 获取用户的电子邮件 ASP.NET MVC C#

c# - 我怎样才能让 Decimal.TryParse 解析 0.0?

c# - RazorGenerator 看不到自定义 cshtml 助手

c# - 使用继承自相同接口(interface) Console .Net Core 的类进行依赖注入(inject)

c# - 为什么我的线程在显示 Windows 窗体后立即终止?

.net - 为什么DataTable比DataReader快

c# - 如何在 xunit 中模拟 Db 连接?