I am trying to write a NAnt extension task that can update various parameters in the Setup.vdproj file created in Visual Studio 2003, and would appreciate help in the following.
In particular, I would like to use the RegEx expression to search and, if found, replace any string value value assigned to the ProductName value with the new string value in its entirty.
I am looking for a RegEx expression to change "ProductName" to any other value, without relying on anything else, except that the search string starts with "ProductName" = "8": and then has 1 or more characters and ends with an icon. I tried the following to no avail:
Before executing the following code snippet, the .vdproj ProductName file reads:
"ProductName" = "8:My Simple .NET Application"
... and a code snippet in C #:
string _theProductName = "My Other Native Application";
Regex productNameExpression = new Regex( @"(?:\""ProductName\"" = \""8:*)" );
_theProjectFileContents =
productNameExpression.Replace(_theProjectFileContents,
"\"ProductName\" = \"8:" + _theProductName + "\"" );
bool updatedProductName =
(_theProjectFileContents.IndexOf(_theProductName) >= 0);
After executing the above code snippet, the .vdproj ProductName file now reads:
"ProductName" = "8:My Simple .NET Application"My Other Native Application"
Close, but I was expecting the “My Other Native Application” to replace “My Simple.NET Application” and not add to it.
Any ideas and help would be greatly appreciated.
source
share