For example after I build the Release version I want it name changed to (for example) MyApp-1.2.exe. After I build the next version I want the exe to be named MyApp-1.3.exe. I still want to be able to run the MyApp-1.2.exe.
I would rather not use any external tool(I know there are nAnt and nMaven) and do it in VS. IF its not possible than I bet nAnt is the better optio开发者_JAVA百科n for me.
You could do it also via MSBuild with the help of the GetAssemblyIdentity task:
<GetAssemblyIdentity
AssemblyFiles="$(MSBuildProjectDirectory)\src\MyApp\bin\MyApp.exe">
<Output
TaskParameter="Assemblies"
ItemName="AssemblyIdentities"/>
</GetAssemblyIdentity>
And then rename your .exe file:
<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
).
Running a script or batch file that will copy
the file and then rename it. 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.
精彩评论