简体   繁体   English

在C#Visual Studio桌面应用程序的exe文件名中包含版本号

[英]Include version number in exe file name in C# Visual Studio desktop application

I looked everywhere for a solution, and I think that it's impossible to do that ! 我到处都在寻找解决方案,我认为这是不可能的!

Can I include the version number (that is in AssemblyInfo.cs) into the .exe filename ? 我可以在.exe文件名中包含版本号(在AssemblyInfo.cs中)吗? So I don't have anymore to rename the output exe file every release build. 因此,我不再需要在每个发行版中重命名输出exe文件。

I just posted this question to be sure that in fact, it is impossible to do that. 我刚刚发布了这个问题,以确保实际上是不可能的。 Otherwise, if someone has a working solution I'll be happy to know it. 否则,如果有人有可行的解决方案,我将很高兴知道。 Thank you 谢谢

EDIT 编辑

I'm not searching how to get the assembly version, which I can find, but I'm looking for how to include that version automatically into my .exe output file name 我不是在搜索如何获取可以找到的程序集版本,而是在寻找如何将该版本自动包含到我的.exe输出文件名中。

I made it ! 我做到了 !

Thanks to Stinky Towel for that helpful comment. 感谢“ 臭毛巾 ”的有用评论。 I had to modify the script to make it run under my configuration, and as you can see I worked with wmic instead of filever which I couldn't find on Windows 10. Here is my script that worked fine: 我不得不修改脚本以使其在我的配置下运行,并且您可以看到我使用wmic而不是在Windows 10上找不到的filever。这是我的脚本,可以正常工作:

`@echo off
set filepath=%1
set filename=%2
set dblslash=%filepath:\=\\%

FOR /F "tokens=2 delims==" %%I IN (
  'wmic datafile where "name='%dblslash%'" get version /format:list'
) DO SET "AssemblyVersion=%%I"
ECHO %AssemblyVersion%
move /Y %filepath% %filename%_%AssemblyVersion%.exe` 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Visual Studio 中构建 C# 应用程序时,如何在可执行文件名中嵌入版本信息? - How to embed the version information in the executable file name when building C# application in Visual Studio? Visual Studio C#EXE而不是.application - Visual Studio C# EXE instead of .application Visual Studio C#锁定.exe文件 - visual studio C# locking .exe file C#应用程序在已部署(.exe)版本中因缓冲区溢出而崩溃,但在Visual Studio中却没有 - C# Application crashes with Buffer Overrun in deployed (.exe) version, but not in Visual Studio C#Visual Studio 2008,包括DLL到exe吗? - C# Visual Studio 2008, include DLL to exe? Visual C#Express和Visual C#Professional之间的已编译EXE Windows桌面应用程序中的差异 - Difference in compiled EXE Windows desktop application between Visual C# Express and Visual C# Professional Visual Studio 2015 C#将应用程序部署到桌面 - Visual Studio 2015 C# Deploy Application to Desktop 如何在 C# Compact Framework 中获取 exe 应用程序名称和版本 - How to get exe application name and version in C# Compact Framework 如何共享在Visual Studio 2013(C#)中创建的.exe文件? - How to share .exe file created in Visual Studio 2013 (C#)? Visual Studio Windows 服务 c# exe 文件丢失 - Visual Studio Windows Service c# exe file missing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM