简体   繁体   中英

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 . 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 option 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM