Dynamic Versioning

后端 未结 1 526

I have a situation where i want the versioning to be dynamic at build time.

Version Pattern: ...

But

1条回答
  •  庸人自扰
    2021-02-15 17:18

    You can use the MsbuildCommunityTasks to generate the build number and to customize the assembly file version on pre-build time.

    • Download the zip at MsbuildCommunityTasks

    • Unzip to the folder [SolutionFolder]\MsBuildExtensions\MSBuildCommunityTasks

    • Add the sample below on your project (csproj), just after the Microsoft.CSharp.Targets import.

      
      $(MSBuildThisFileDirectory)..\MsBuildExtensions\MSBuildCommunityTasks  
        Properties
      
      
      
        
        
        
        
          
          
        
        
        
      
      
        
      
    

    • Wipe the AssemblyFileVersion attribute from your AssemblyInfo.cs. It will be generated at build time.

    • You'll see the version number being printed on the console when you build. The generated file is deleted on the AfterBuild target, to keep your source control clean.

      BeforeBuild:

      Building 2013.01.14.1016 ... Created AssemblyInfo file "Properties\AssemblyVersionInfo.cs".

      (...)

      AfterBuild:

      Deleting file "Properties\AssemblyVersionInfo.cs".

    • If you want do this to many projects with less msbuild code, it will be necessary to create a customized build script to wrap up your solution.

    0 讨论(0)
提交回复
热议问题