2012-12-12 36 views
6

MSBuild引擎爲'$([MSBuild] :: Add($(OldRevision),1))'語句返回錯誤MSB4186。 我用一個例子來自here,但它不爲我工作:[MSBuild] ::添加調用返回錯誤MSB4186

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`)) 

這裏就是我試圖執行:

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

我不知道什麼是正確的塔語法它

ps是的,我正在使用MSBuild 4.5

+0

我有同樣的問題。我認爲這與'$(OldRevision)'被視爲字符串對待有關。下面的代碼適用於我:'',但不是當我用屬性替換2和3時。 – vegemite4me

回答

1

我認爲你有這個屬性語法的權利,它只是在CreateProperty任務中沒有工作。 CreateProperty函數已被棄用,使用它的原因很少。

這種簡單的屬性語法爲我工作:

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

而且這個工程,以及(內部的任何目標):

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

不幸的是,它也不適用於我。同樣的錯誤。所以,我只是回到'老好'版'任務 –