msbuild - How edit or add properties in inline task -
i need invoke msbuild task properties, whats name can calculated in runtime. try scripts
main.xml
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" toolsversion="14.0" defaulttargets="build"> <usingtask taskname="getvars" taskfactory="codetaskfactory" assemblyfile="$(msbuildtoolspath)\microsoft.build.tasks.v4.0.dll"> <parametergroup> <result parametertype="system.string" output="true"/> </parametergroup> <task> <code type="fragment" language="cs"> <![cdata[ this.result = "aaa=123;bbb=456;"; ]]> </code> </task> </usingtask> <propertygroup> <vars></vars> </propertygroup> <target name="make"> <getvars> <output taskparameter="result" propertyname="vars"/> </getvars> <msbuild projects="proj.xml" targets="make" properties="$(vars)"/> </target> </project>
proj.xml
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" defaulttargets="build"> <target name="make"> <message text="aaa = $(aaa)"/> <message text="bbb = $(bbb)"/> </target> </project>
this script give output:
aaa = 123;bbb=456; bbb =
i expected output:
aaa = 123; bbb = 456;
if want inline task produce several items (the msbuild equivalent of array or list in other languages), should state instead of using property (which single key/value pair). covered in of inline task documentation - uses full-blown itaskitems whereas using string array do. so:
- output
system.string[]
inline task - assign item instead of property using
itemname =
- pass item msbuild task (which expects anyway), using
@()
notation
in code:
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" toolsversion="14.0" defaulttargets="make"> <usingtask taskname="getvars" taskfactory="codetaskfactory" assemblyfile="$(msbuildtoolspath)\microsoft.build.tasks.v4.0.dll"> <parametergroup> <result parametertype="system.string[]" output="true"/> </parametergroup> <task> <code type="fragment" language="cs"> <![cdata[ this.result = new system.string[]{"aaa=123", "bbb=456"}; ]]> </code> </task> </usingtask> <target name="make"> <getvars> <output taskparameter="result" itemname="vars"/> </getvars> <msbuild projects="$(msbuildthisfile)" targets="show" properties="@(vars)"/> </target> <target name="show"> <message text="aaa = $(aaa)"/> <message text="bbb = $(bbb)"/> </target> </project>
output:
show: aaa = 123 bbb = 456
Comments
Post a Comment