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
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))" />
Related
I'd like to create a auto-completion definition file to my domain specific language so that the I get parameter hints for predefined class methods.
In the doc I have the following example:
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<AutoComplete language="C++">
<Environment ignoreCase="no" startFunc="(" stopFunc=")" paramSeparator="," terminal=";" additionalWordChar = "."/>
<KeyWord name="abs" func="yes">
<Overload retVal="int" descr="Returns absolute value of given integer">
<Param name="int number" />
</Overload>
</KeyWord>
That works like a charm for function calls such as:
abs(-12)
That is, I hit "a" and Notepad++ suggests the function abs and hints to its parameters.
However what if abs is a method of a class? For instance:
MyObject.abs(-12)
I would expect that once I hit the key "." and "a" Notepad++ would propose me the abs method and all the parameter hints. However, with the xml definition listed above it does not work.
Does anybody know how to deal with this issue? Is there a regular expression mode that we can use?
Thanks in advance.
I just found out solution. Posting here to leave a trace and help others out.
If I remove additionalWordChar = "." it wokrs!
I saw this code example in a recording and wanted to know what the colon syntax did. I searched the docs, but I wasn't able to find any info on it:
weather.subscribe(observer: application.observers.currentConditions);
I know we can use colon in CF9 for ternary operators:
result = (condition) ? true : false;
But in this case it looks like it's being used to provide named arguments; so what's it doing there?
<cfset result = obj.func(arg:value,thing:42) /> I looked at this and
went blink, blink... That can't be right! You can't use colons for
named arguments! Er, can you? Well, apparently you can.
http://corfield.org/blog/post.cfm/Learn_something_new_every_day_named_arguments
Yes, you are allowed to use both. I think it's a matter of preference. You can even mix.
Try this and see, mocked up some test function:
<cffunction name="testFunction" returntype="void" hint="I just spit out the arguments I get">
<cfdump var="#arguments#" label="arguments">
</cffunction>
<cfset testFunction(arg1:"hello",arg2:"world") />
<cfset testFunction(arg1="hello",arg2="world") />
<cfset testFunction(arg1:"I can mix",arg2="my named argument syntax") />
Personally, I prefer = for named arguments. You might also notice that if you use IntelliJ IDEA for your ColdFusion development that they do not recognize the colon syntax, so for better parsing you would want to use the = syntax. I can't speak for other IDEs
Looks like a typo to me. In ColdFusion you would use an equals sign (=) not a colon to used named arguments.
Your example would become:
weather.subscribe(observer = application.observers.currentConditions);
The following code:
<xsl:message>[threfUrl] <xsl:value-of select="$threfUrl" /></xsl:message>
<xsl:variable name="actualHeight" select="itext:getPlainHeight(itext:getInstance($threfUrl))" />
throws this error:
[xslt] [threfUrl] file:/data/dtemple/share/dita_share/png_debug/screenshot_example.png
[xslt] /tools/dita_ot/1.6/plugins/com.altera.pdf/cfg/fo/xsl/altera_commons.xsl:1124: Fatal Error! Cannot convert from xs:string to byte
The PNG file exists and is readable. Using Saxon 9. Namespace: itext="java:com.itextpdf.text.Image"
Any clues as to what is wrong (the error message is not helpful) or how to fix?
Is the "file:/" syntax correct?
Assuming you are using http://api.itextpdf.com/itext/com/itextpdf/text/Image.html#Image%28java.net.URL%29 try select="itext:getPlainHeight(itext:new($threfUrl))". If that does not work then construct the URL explicitly, as in
<xsl:variable name="actualHeight" xmlns:url="java:java.net.URL" select="itext:getPlainHeight(itext:new(url:new($threfUrl)))" />
The documentation I cited says
Constructor Detail
Image
public Image(URL url)
Constructs an Image -object, using an url .
Parameters:
url - the URL where the image can be found.
so that constructor is public.
Maybe there are different versions of that API, I am not sure why you get an error. Another try might be your original attempt, but passing in a URL, so
<xsl:variable name="actualHeight" xmlns:url="java:java.net.URL" select="itext:getPlainHeight(itext:getInstance(url:new($threfUrl)))" />
I have the following in a file
version: [0,1,0]
and I would like to set an Ant property to the string value 0.1.0.
The regular expression is
version:[[:space:]]\[([[:digit:]]),([[:digit:]]),([[:digit:]])\]
and I need to then set the property to
\1.\2.\3
to get
0.1.0
I can't workout how to use the Ant tasks together to do this.
I have Ant-contrib so can use those tasks.
Based on matt's second solution, this worked for me for any (text) file, one line or not. It has no apache-contrib dependencies.
<loadfile property="version" srcfile="version.txt">
<filterchain>
<linecontainsregexp>
<regexp pattern="version:[ \t]\[([0-9]),([0-9]),([0-9])\]"/>
</linecontainsregexp>
<replaceregex pattern="version:[ \t]\[([0-9]),([0-9]),([0-9])\]" replace="\1.\2.\3" />
</filterchain>
</loadfile>
Solved it with this:
<loadfile property="burning-boots-js-lib-build.lib-version" srcfile="burning-boots.js"/>
<propertyregex property="burning-boots-js-lib-build.lib-version"
override="true"
input="${burning-boots-js-lib-build.lib-version}"
regexp="version:[ \t]\[([0-9]),([0-9]),([0-9])\]"
select="\1.\2.\3" />
But it seems a little wasteful - it loads the whole file into a property!
If anyone has any better suggestions please post :)
Here's a way that doesn't use ant-contrib, using loadproperties and a filterchain (note that replaceregex is a "string filter" - see the tokenfilter docs - and not the replaceregexp task):
<loadproperties srcFile="version.txt">
<filterchain>
<replaceregex pattern="\[([0-9]),([0-9]),([0-9])\]" replace="\1.\2.\3" />
</filterchain>
</loadproperties>
Note the regex is a bit different, we're treating the file as a property file.
Alternatively you could use loadfile with a filterchain, for instance if the file you wanted to load from wasn't in properties format.
For example, if the file contents were just [0,1,0] and you wanted to set the version property to 0.1.0, you could do something like:
<loadfile srcFile="version.txt" property="version">
<filterchain>
<replaceregex pattern="\s+\[([0-9]),([0-9]),([0-9])\]" replace="\1.\2.\3" />
</filterchain>
</loadfile>
I'm trying to configure autoincrement of version number in an Android aplication.
I've configured Ant tasks which make a checkout of the file then autoincrement the string with version value and then automatically do check-in in TFS system. So this test.properties file has this contetnt:
versionCode="1"
Autoincrement did this task:
<propertyfile file="${basedir}/src/test.properties">
<entry key="versionCode" value="1" type="int" operation="+" />
</propertyfile>
How would I configure replacement of the value of this string: android:versionCode="1", located in the target file androidmanifest.xml?
I suppose you can use the ReplaceRegExp task in Ant:
Directory-based task for replacing the occurrence of a given regular expression with a substitution pattern in a file or set of files.
It might look something like this:
<replaceregexp file="${src}/androidmanifest.xml"
match="android:versionCode="[0-9]+""
replace="android:versionCode="${versionCode}""
/>
The build.number property could be obtained by reading in the property file before running this task.
A solution with vanilla ant, no Ant addon needed, you may use a propertyfiletemplate that has =
f.e. named props.txt
...
android:versionCode=#versionCode#
...
and later on use the property ${versionCode} set by your workflow
and create a propertyfile from your template with copy + nested filterset =
<!-- somewhere set in your workflow maybe via userproperty -DversionCode=42 -->
<property name="versionCode" value="42"/>
...
<copy file="props.txt" todir="/some/path" overwrite="true">
<filterset>
<filter token="versionCode" value="${versionCode}"/>
</filterset>
</copy>
/some/path/props.txt will have =
...
android:versionCode=42
...
see Ant Manual on filtersets