How to set assembly version to Jenkins build number?

后端 未结 3 1707
遇见更好的自我
遇见更好的自我 2020-12-30 14:44

I am using \"Change Assembly Version\" plug-in in Jenkins to update all AssemblyInfo.cs files of my ASP.NET MVC project to apply version number during build process. If I se

3条回答
  •  無奈伤痛
    2020-12-30 14:59

    The previous answer about how to use "Change Assembly Version" plugin for Jenkins doesn't work. In my AssemblyInfo.cs files I usually set them up with auto incrementing version to help local dev work.

    Example

    AssemblyInfo.cs contains:

    [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyFileVersion("1.0.*")]
    

    After the Jenkins build if the version is 10 then AssemblyInfo.cs will contain:

    [assembly: AssemblyVersion("1.0.10")]
    [assembly: AssemblyFileVersion("1.0.10")]
    

    The plugin is used like so to achieve the above:

    Assembly Version: $BUILD_NUMBER
    FileName: 
    RegexPattern: Assembly(\w*)Version\("(\d+).(\d+).(\*)"\)
    ReplacementPattern: Assembly$1Version("$2.$3.%s")
    

    One other error I got whilst using the plugin was the file permission didn't allow write access. In order to fix this find the AssemblyInfo.cs and disable "Read Only".

    Hope to helps anyone.

提交回复
热议问题