.NET Core 3.1 自包含应用程序没有为可执行文件设置版本
我正在将应用程序部署为独立的 win-x64 应用程序。执行此操作会生成一个 .exe,用于在客户端计算机上启动应用程序,但是我需要在 .exe 上设置“产品版本”和“文件版本”。我的问题是,这个 .exe 没有设置这些属性中的任何一个,尽管部署的所有其他二进制文件都设置了这些属性。
以下是运行以生成自包含应用程序二进制文件的发布命令:
dotnet publish MyApp.csproj -c MyCustomRelease -r win-x64 --self-contained=true -v normal
此外,我为 MyApp.csproj 设置了以下属性。以下是这些:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Configurations>Debug;Release;MyCustomRelease</Configurations>
<Platforms>AnyCPU</Platforms>
<AssemblyVersion>3.2.0</AssemblyVersion>
<Version>3.2.0</Version>
<FileVersion>3.2.0</FileVersion>
</PropertyGroup>
但是当我检查 .exe 的版本时,我没有看到文件或产品版本设置为 3.2.0。然而,生成的 .dll确实已正确设置这些设置。我缺少什么?
I am deploying an application as a self contained win-x64 application. Doing this generates an .exe that will be used to start the application on the client machine, however I need to have the "Product Version" and the "File Version" set on the .exe. My issue is that this .exe does not have either of those properties set, despite every other binary that is deployed having those properties set.
Here is the publish command that is ran to generate the self contained application binaries:
dotnet publish MyApp.csproj -c MyCustomRelease -r win-x64 --self-contained=true -v normal
Additionally, I have the following properties set for MyApp.csproj set. Here are those:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Configurations>Debug;Release;MyCustomRelease</Configurations>
<Platforms>AnyCPU</Platforms>
<AssemblyVersion>3.2.0</AssemblyVersion>
<Version>3.2.0</Version>
<FileVersion>3.2.0</FileVersion>
</PropertyGroup>
But when I check the version of my .exe, I do not see 3.2.0 set for the file or the product versions. However the .dlls generated do have those set correctly. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题已在另一个 StackOverflow 问题中得到解答:https://stackoverflow.com/a/43280282/3424781
我希望这些信息有帮助!如果上面的链接回答了您的问题,请务必将此帖子标记为已回答,以便其他发现它的人被发送到正确的位置。
Your question has already been answered in another StackOverflow question here: https://stackoverflow.com/a/43280282/3424781
I hope this information helps! If the link above answers your question be sure to mark this post as answered so that others who discover it are sent to the correct location.
我想我找到了答案。我没有提到我是在 MacOS 上构建这个(并且最终将在我们的 CICD 管道中的 Linux 容器中构建),因为我认为我的操作系统对于这种功能并不重要,但是经过一番认真的挖掘后我做到了查找此 GitHub 问题,详细说明为自包含应用程序自定义 exe 依赖于 Windows API。
I think I found my answer. I didn't mention that I was building this on MacOS (and will eventually be built in a linux container in our CICD pipeline) because I wouldn't think my OS would matter for this kind of functionality, however after some serious digging I did find this GitHub issue detailing that customizing the exe for self contained applications relies on Windows APIs.