2

Is there a way to look for a pattern in aspx/ascx files and replace it with a build number or some other token? I'm not interested in using reflection and setting the string at runtime. I'd like to go into the aspx/ascx files and replace the string using msbuild.

Is this possible?

1

1 Answer 1

3

There's a project called MSBuild Community Tasks that contains a FileUpdateTask. This should satisfy your requirement. It allows you to make arbitrary text replacements using regular expressions.

<FileUpdate Files="MyWebPage.aspx"
            Regex="\<div id\=\'version\'\>(.*)\<\/div\>"
            ReplacementText="$(BuildVersion)" />

Please note that I haven't tested this regular expression.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.