Aligning assembly version numbers with TFS Buildnumber

前端 未结 2 2046
小鲜肉
小鲜肉 2020-12-28 19:41

I am wondering if there is a way to synchronize the build numbers (20080213.1) without using the BuildNumberOverrideTarget where I would have to generate my own build number

2条回答
  •  猫巷女王i
    2020-12-28 19:59

    Yes you can. At some point, possibly at AfterGet, you can use the BuildNumber and create a custom task to update the AssemblyInfo.cs files in your source code.

    We've hooked into AfterGet and caused our target to be dependant:

    
    

    Our VersionAssemblies Target pulls all of the AssemblyInfo.cs files from $(SolutionRoot):

    
        
     
    

    checks them out:

    
    

    edits them and replaces the file version with the $(BuildNumber):

    
    

    and then checks the files back in:

    
    

    For the replacement of the file versions I use the File.Replace task that comes with the Microsoft SDC tasks on CodePlex.

    Also note, that if you have a build that is triggered on a checkin, when checking in the AssemblyInfo.cs files, make sure the comment includes $(NoCICheckinComment) as this causes TFS not to trigger another build otherwise you'll end up in an infinite build loop.

提交回复
热议问题