Updating assemblyinfo

Posted by / 06-Aug-2016 14:03

Once we find this tag we grab the version, split it apart and increment the last part.Finally once we have updated the line in the array we re-write the information back to the file and go about our merry way. Recently we just added a new task which will parse the Assembly file and increment the version number of the Assembly.grunt.register Task('update Assembly Version', function(){ writeln('About to parse the assembly files'); var assembly File = read('./Assembly Info.cs'); var lines = assembly File.split('\n'); var version = ''; var version Parts = ''; var search String = 'Assembly Version'; _.each(lines, function (line, index) { if (line.index Of(search String) !Tests\Properties\Assembly Updating file : c:\jenkins\workspace\My Project-Backend_compile_MSBuild\My Project Backend\Properties\Assembly Info.cs, Version : Updating file : c:\jenkins\workspace\My Project-Backend_compile_MSBuild\My Project Backend\Properties\Assembly Updating file : c:\jenkins\workspace\My Project-Backend_compile_MSBuild\My Project Integration.I am 99% sure my next step is to make this into an NPM package but that is for another day.

In order to get this to work you will need to reference the Underscore NPM inside your script.Now, I am sure there are other ways, better ways to do this but this works for our team.= -1) { version = line.match(/\d+\.\d+\.\d+\.\d+/g)String(); version Parts = version.split('.'); version Parts[3] = parse Int(version Parts[3], 10) + 1; lines[index] = line.replace(version, version Parts.join('.')); } }); var updated Assembly File = lines.join('\n'); write('./Assembly Info.cs', updated Assembly File); write('Updated to version: ' + version Parts); }); Basically all we are doing is opening up the Assembly class and reading it in and then splitting it into a string array.Once we have the string array we find the line which matches our tag of Assembly Version.Simply pass in an object containing the attibutes and their replacements. A function is passed the value specified in the original assembly info file and returns the replacement value.

updating assemblyinfo-66updating assemblyinfo-2updating assemblyinfo-34

is a slick task runner which can be used for stuff other than Java Script. Below is our code which we are using to accomplish this.