I got a text file with a version number which updates on each build i.e: 1.4.10.301.
I would like to insert this number on each build to my globalassemblyinfo.cs file on this line: [assembly: AssemblyVersion("1.4.10.300")] and only to the version number, meaning before the build the globalassembly.cs file would be updated with the new version number from the text file (1.4.10.301).
Tried this:
$a = cat "C:\pathtofile\GlobalAssemblyInfo.cs" | select-string AssemblyVersion
which gives me only this line:
[assembly: AssemblyVersion("1.4.10.331")]
but from it I need only the number how can I pull it out? Tried using a pattern but I didn't know what to put in the pattern exactly
The code below worked like a charm and I had managed to extract the version number, now i'm trying to replace this version with the one in globalassemblyinfo.cs, so I wrote this line:
$a -replace $version,$Newversion | Set-Content "C:\pathtofile\GlobalAssemblyInfo.cs"
But it deleted the whole file content and put this string instead:
[assembly: AssemblyVersion("1.4.10.400")]
How can I just update the line without deleting the whole file content?