[MSBuild] :: Add call returns error MSB4186

The MSBuild mechanism returns error MSB4186 for the $$ [[MSBuild] :: Add ($ (OldRevision), 1)) 'operator. I use the example here , but for me this does not work:

error MSB4186: Invalid static method invocation syntax: "[MSBuild]::Add($(OldRevision), 1)". Input string was not in a correct format. Static method invocation should be of the form: $([FullTypeName]::Method()), eg $([System.IO.Path]::Combine(`a`, `b`)) 

Here is what I am trying to accomplish:

 <CreateProperty Value="$([MSBuild]::Add($(OldRevision), 1))"> <Output TaskParameter="Value" PropertyName="NewRevision" /> </CreateProperty> 

I wonder what is the correct syntax for?

ps yes, I'm using MSBuild 4.5

+6
source share
1 answer

I think you have the syntax of this right, it just doesn't work in the CreateProperty task. The CreateProperty function is deprecated, it is very small.

This simple property syntax works for me:

 <PropertyGroup> <NewVersion>$([MSBuild]::Add($(OldVersion), 1))</NewVersion> </PropertyGroup> 

It also works (inside any purpose):

 <Message Text="OldVersion=$(OldVersion), NewVersion=$([MSBuild]::Add($(OldVersion), 1))" /> 
+1
source

All Articles