Nant: extending properties in a string

Summary:

How can I deploy a property with the value "download \ $ {bulidmode} \ project \ setup.msi" to load \ Debug \ project \ setup.msi "if the buildmode property contained debug, so I can use it as the file =" "part <copy>

More details:

I have a little requirement to be able to extend properties inside a string in nant.

For example, I have a target that copies file A to B. A and B both come from a simple two CSV file field, which I repeat with

<foreach item="Line" in="filelist.csv" delim="," property="source.file,target.file">

    <property name="sourcefile" value="${path::combine(source.dir,source)}" /> 
    <property name="targetfile" value="${path::combine(download.dir,destination)}" />
    <echo message="Copy ${sourcefile} to ${targetfile}" />

    <copy file="${sourcefile" tofile="${destination}" />

</foreach>

and the list.csv file will be

build\manifest.xml 
solutiondirectory\setup-proj-directory\Release\setupproj.msi,ProductA\ProductA.msi
solutiondirectory\another-proj-dir\Release\setupproj.msi,ProductB\ProductB.msi

(The reason we share this is because we write multilevel applications and deploy MSI to each level - so a single product has several msi built with the same version numbers)

- , "Release" filelist.csv, - ${build.mode}.

<foreach item="String" in="Release,Debug" delim="," property="build.mode">
....as above
</foreach>

, , .

, .

+3
1

:

<?xml version="1.0"?>
<project>
    <script language="C#" prefix="vbfox" >
        <code>
            <![CDATA[
            [Function("expand")]
            public string ExpandString(string str)
            {
                return Project.Properties.ExpandProperties(str, Location.UnknownLocation);
            }
            ]]>
        </code>
    </script>
    <property name="hello" value="{path::combine('_hello_', '_world_')}" />
    <property name="hello" value="${'$' + hello}" />
    <echo message="${hello}" />
    <echo message="${vbfox::expand(hello)}" />
</project>
+4

Source: https://habr.com/ru/post/1703951/


All Articles