Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[MSBuild]::Add invocation returns error MSB4186

MSBuild engine returns error MSB4186 for '$([MSBuild]::Add($(OldRevision), 1))' statement. I'm using an example from here, but it does not work for me:

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()),
e.g. $([System.IO.Path]::Combine(`a`, `b`))

Here is what I'm trying to perform:

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

I wonder what is tha proper syntax for it

p.s. yes, I'm using MSBuild 4.5

like image 382
Constantin Tokarev Avatar asked Dec 12 '12 20:12

Constantin Tokarev


1 Answers

I think you got this property syntax right, it is just not working in CreateProperty task. CreateProperty function is deprecated, there are very few reasons to use it.

This simpler property syntax works for me:

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

Also this works as well (inside any target):

<Message Text="OldVersion=$(OldVersion), NewVersion=$([MSBuild]::Add($(OldVersion), 1))" />
like image 136
seva titov Avatar answered Oct 01 '22 10:10

seva titov