[英]How to manage versions in VS2010?
For example after I build the Release version I want it name changed to (for example) MyApp-1.2.exe . 例如,在我构建Release版本之后,我希望将其名称更改为(例如) MyApp-1.2.exe 。 After I build the next version I want the exe to be named MyApp-1.3.exe . 在我构建下一个版本后,我希望将exe命名为MyApp-1.3.exe 。 I still want to be able to run the MyApp-1.2.exe . 我仍然希望能够运行MyApp-1.2.exe 。
I would rather not use any external tool(I know there are nAnt and nMaven) and do it in VS. 我宁愿不使用任何外部工具(我知道有nAnt和nMaven)并在VS中执行。 IF its not possible than I bet nAnt is the better option for me. 如果它不可能比我打赌nAnt对我来说是更好的选择。
You could do it also via MSBuild with the help of the GetAssemblyIdentity task: 您也可以借助GetAssemblyIdentity任务通过MSBuild执行此操作:
<GetAssemblyIdentity
AssemblyFiles="$(MSBuildProjectDirectory)\src\MyApp\bin\MyApp.exe">
<Output
TaskParameter="Assemblies"
ItemName="AssemblyIdentities"/>
</GetAssemblyIdentity>
And then rename your .exe file: 然后重命名您的.exe文件:
<Copy
SourceFiles="$(MSBuildProjectDirectory)\src\MyApp\bin\MyApp.exe"
DestinationFiles="$(MSBuildProjectDirectory)\src\MyApp\bin\MyApp-(AssemblyIdentities.Version).exe"></Copy>
<Delete
Files="$(MSBuildProjectDirectory)\src\MyApp\bin\MyApp.exe"></Delete>
If you really want to do it in VS, you can (again) do it using the Post-build Command function (from Project properties
-> Build Events
). 如果你真的想在VS中这样做,你可以(再次)使用Post-build Command函数(来自Project properties
- > Build Events
)来完成它。
Running a script or batch file that will copy
the file and then rename it. 运行将copy
文件然后重命名的脚本或批处理文件。 I used to do it based on current date (not version) a few years back (not even sure why). 我曾经在几年前根据当前日期(不是版本)做到这一点(甚至不确定为什么)。
You can do virtually anything in the build events if you can create batch files or scripts. 如果可以创建批处理文件或脚本,则可以在构建事件中执行几乎任何操作。
Using a build system is IMHO preferable to this approach. 使用构建系统是IMHO优于这种方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.