I have a regex I'm using (in test only) to update the AssemblyVersion
from the AssemblyInfo.cs
file. I'm wondering, however, what the best way to pull and replace this value from the .cs
file itself would be?
Here is my best guess which, obviously, isn't working but the general idea is in place. Was hoping for something a little more elegant.
Get-Content $file | Foreach-Object{
$var = $_
if($var -contains "AssemblyVersion"){
$temp = [regex]::match($s, '"([^"]+)"').Groups[1].Value.Substring(0, $prog.LastIndexOf(".")+1) + 1234
$var = $var.SubString(0, $var.FirstIndexOf('"') + $temp + $var.SubString($var.LastIndexOf('"'), $var.Length-1))
}
}
EDIT
Per request here is the line I'm looking to update in the AssemblyInfo:
[assembly: AssemblyVersion("1.0.0.0")]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…