All I want to do is assign a project property with a value parsed from an external file when building from Visual Studio 2010. Specifically, I want to populate the HelpFileVersion in a Sandcastle Help File Builder project (see my thread here for specifics).
When building from VS, properties are only evaluated when the project is loaded, thus I thought I could just re-evaluate this property at build time in an MSBuild task, like this (in my shfbproj):
<Target Name="BeforeBuildHelp">
<PropertyGroup>
<HelpFileVersion>{@Major}.{@Minor}.{@Build}.{@Revision}</HelpFileVersion>
<In>$([System.IO.File]::ReadAllText('$(MSBuildProjectDirectory)\..\SolutionInfo.cs'))</In>
<Pattern>^\s*\[assembly: AssemblyVersion\(\D*(\d+)\.(\d+)\.(\d+).(\d+)</Pattern>
<Major>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern), System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value)</Major>
<Minor>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern), System.Text.RegularExpressions.RegexOptions.Multiline).Groups[2].Value)</Minor>
<Build>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern), System.Text.RegularExpressions.RegexOptions.Multiline).Groups[3].Value)</Build>
<Revision>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern), System.Text.RegularExpressions.RegexOptions.Multiline).Groups[4].Value)</Revision>
</PropertyGroup>
<Message Importance="High" Text="HelpFileVersion: $(Major).$(Minor).$(Build).$(Revision)" />
</Target>
This works just fine when building from MSBuild or command line directly, but if I update the external file in VS, the updated version (as set in the MSBuild task above) does not make it back to the IDE's instance of the HelpFileVersion property until I reload the project (which has not been working out very well for me to remember to do). I know my Major, Minor, Build, and Revision properties are updating correctly (seen by the message task). In my other thread listed above, the author of the SHFB tool mentioned that:
"As far as I know Visual Studio only edits project properties found at the project's root level and won't see any within a separate build task such as BeforeBuildHelp."
So, my question is, do any of you know a way, building from Visual Studio 2010, for me to update an IDE's instance of a property at build time from an MSBuild task or otherwise? I have tried setting the property several ways (CreateProperty, PropertyGroup, using DependsOn attribute, using CallTarget, etc), and every time I can get the correct value within the task, but the value is always stale in the IDE's property (seen by echoing it from a PostBuildEvent).