I cant seem to get Nant to copy my web solution to an output folder, such as a Test server. It simply will not copy the files, even though the build succeeds.
According to the docs /p:WebProjectOutputDir should do it.
Thanks in advance.
<echo message="Compiling ${msbuild.workingdir}\${package.name}.sln - Copy to ${development.path}"/>
<exec program="msbuild.exe" basedir="${msbuild.path}" workingdir="${msbuild.workingdir}">
<arg value="/p:Configuration=Test" />
<arg value="/p:UseWPP_CopyWebApplication=True" />
<arg value="/noconsolelogger" />
<arg value="/v:d" />
<arg value="/logger:${lib.nant.path}\loggers\Rodemeyer.MsBuildToCCnet.dll"/>
<arg value="/t:rebuild;ResolveReferences;_CopyWebApplication"/>
<arg value="/p:OutDir=\\latchford\Drop\Club.Registration.DailyBuild\current\bin" />
<arg value="/p:WebProjectOutputDir=\\latchford\Drop\Club.Registration.DailyBuild\current\" />
<arg value="${package.name}.sln"/>
</exec>
<property name="msbuild.output.file" value="${msbuild.workingdir}/msbuild-output.xml"/>
<move if="${file::exists(msbuild.output.file)}" file="${msbuild.output.file}" todir="${log.dir}" failonerror="false" overwrite="true" />
1.The OutDir property must end with a trailing slash: /p:OutDir=..\current\bin\
2.Parameter UseWPP_CopyWebApplication doesn't required just to copy to your output
3.It seems that enough only rebuild target to call
<exec program="msbuild.exe" basedir="${msbuild.path}" workingdir="${msbuild.workingdir}">
<arg value="/p:Configuration=Test" />
<arg value="/noconsolelogger" />
<arg value="/v:d" />
<arg value="/logger:${lib.nant.path}\loggers\Rodemeyer.MsBuildToCCnet.dll"/>
<arg value="/t:rebuild"/>
<arg value="/p:OutDir=\\latchford\Drop\Club.Registration.DailyBuild\current\bin\" />
<arg value="/p:WebProjectOutputDir=\\latchford\Drop\Club.Registration.DailyBuild\current\" />
<arg value="${package.name}.sln"/>
</exec>
Related
I can run just one camera alone
I am following this enter link description here
I need to run both cameras simultaneously
when running the second camera the output:
[ INFO] [1550737732.951379947]: Initializing nodelet with 4 worker threads.
[FATAL] [1550737734.651595532]: Failed to load nodelet '/camera/rgb_rectify_mono` of type `image_proc/rectify` to manager `camera_nodelet_manager'
[camera/rgb_rectify_mono-4] process has died [pid 12535, exit code 255, cmd /opt/ros/indigo/lib/nodelet/nodelet load image_proc/rectify camera_nodelet_manager --no-bond image_mono:=rgb/image_mono image_rect:=rgb/image_rect_mono __name:=rgb_rectify_mono __log:=/home/turtlebot/.ros/log/4c3c5ce6-35a0-11e9-97f4-6c71d9e07c7b/camera-rgb_rectify_mono-4.log].
log file: /home/turtlebot/.ros/log/4c3c5ce6-35a0-11e9-97f4-6c71d9e07c7b/camera-rgb_rectify_mono-4*.log
openni.launch, this file causes conflict between them
<!-- Entry point for using OpenNI devices -->
<launch>
<!-- "camera" should uniquely identify the device. All topics are pushed down
into the "camera" namespace, and it is prepended to tf frame ids. -->
<arg name="camera" default="camera" />
<arg name="rgb_frame_id" default="$(arg camera)_rgb_optical_frame" />
<arg name="depth_frame_id" default="$(arg camera)_depth_optical_frame" />
<!-- device_id can have the following formats:
"B00367707227042B": Use device with given serial number
"#1" : Use first device found
"2#3" : Use device on USB bus 2, address 3
"2#0" : Use first device found on USB bus 2
-->
<arg name="device_id" default="#1" />
<!-- By default, calibrations are stored to file://${ROS_HOME}/camera_info/${NAME}.yaml,
where ${NAME} is of the form "[rgb|depth]_[serial#]", e.g. "depth_B00367707227042B".
See camera_info_manager docs for calibration URL details. -->
<arg name="rgb_camera_info_url" default="" />
<arg name="depth_camera_info_url" default="" />
<!-- Use OpenNI's factory-calibrated depth->RGB registration? -->
<arg name="depth_registration" default="false" />
<!-- Arguments for remapping all device namespaces -->
<arg name="rgb" default="rgb" />
<arg name="ir" default="ir" />
<arg name="depth" default="depth" />
<arg name="depth_registered" default="depth_registered" />
<arg name="depth_registered_filtered" default="depth_registered" />
<arg name="projector" default="projector" />
<!-- Optionally suppress loading the driver nodelet and/or publishing the default tf
tree. Useful if you are playing back recorded raw data from a bag, or are
supplying a more accurate tf tree from calibration. -->
<arg name="load_driver" default="true" />
<arg name="publish_tf" default="true" />
<!-- Processing Modules -->
<arg name="rgb_processing" default="true"/>
<arg name="ir_processing" default="true"/>
<arg name="depth_processing" default="true"/>
<arg name="depth_registered_processing" default="true"/>
<arg name="disparity_processing" default="true"/>
<arg name="disparity_registered_processing" default="true"/>
<arg name="hw_registered_processing" default="true" />
<arg name="sw_registered_processing" default="true" />
<!-- Disable bond topics by default -->
<arg name="bond" default="false" /> <!-- DEPRECATED, use respawn arg instead -->
<arg name="respawn" default="$(arg bond)" />
<!-- Worker threads for the nodelet manager -->
<arg name="num_worker_threads" default="4" />
<!-- Push down all topics/nodelets into "camera" namespace -->
<group ns="$(arg camera)">
<!-- Start nodelet manager in top-level namespace -->
<arg name="manager" value="$(arg camera)_nodelet_manager" />
<arg name="debug" default="false" /> <!-- Run manager in GDB? -->
<include file="$(find rgbd_launch)/launch/includes/manager.launch.xml">
<arg name="name" value="$(arg manager)" />
<arg name="debug" value="$(arg debug)" />
<arg name="num_worker_threads" value="$(arg num_worker_threads)" />
</include>
<!-- Load driver -->
<include if="$(arg load_driver)"
file="$(find openni_launch)/launch/includes/device.launch.xml">
<!-- Could really use some syntactic sugar for this -->
<arg name="manager" value="$(arg manager)" />
<arg name="device_id" value="$(arg device_id)" />
<arg name="rgb_frame_id" value="$(arg rgb_frame_id ...
freenect.launch
<!-- Entry point for using OpenNI devices -->
<launch>
<!-- "camera" should uniquely identify the device. All topics are pushed down
into the "camera" namespace, and it is prepended to tf frame ids. -->
<arg name="camera" default="camera" />
<arg name="rgb_frame_id" default="$(arg camera)_rgb_optical_frame" />
<arg name="depth_frame_id" default="$(arg camera)_depth_optical_frame" />
<arg name="data_skip" default="0" />
<!-- device_id can have the following formats:
"B00367707227042B": Use device with given serial number
"#1" : Use first device found
-->
<arg name="device_id" default="#1" />
<!-- By default, calibrations are stored to file://${ROS_HOME}/camera_info/${NAME}.yaml,
where ${NAME} is of the form "[rgb|depth]_[serial#]", e.g. "depth_B00367707227042B".
See camera_info_manager docs for calibration URL details. -->
<arg name="rgb_camera_info_url" default="" />
<arg name="depth_camera_info_url" default="" />
<!-- Use OpenNI's factory-calibrated depth->RGB registration? -->
<arg name="depth_registration" default="false" />
<!-- Arguments for remapping all device namespaces -->
<arg name="rgb" default="rgb" />
<arg name="ir" default="ir" />
<arg name="depth" default="depth" />
<arg name="depth_registered" default="depth_registered" />
<arg name="projector" default="projector" />
<!-- Optionally suppress loading the driver nodelet and/or publishing the default tf
tree. Useful if you are playing back recorded raw data from a bag, or are
supplying a more accurate tf tree from calibration. -->
<arg name="load_driver" default="true" />
<arg name="publish_tf" default="true" />
<!-- Processing Modules -->
<arg name="rgb_processing" default="true"/>
<arg name="ir_processing" default="true"/>
<arg name="depth_processing" default="true"/>
<arg name="depth_registered_processing" default="true"/>
<arg name="disparity_processing" default="true"/>
<arg name="disparity_registered_processing" default="true"/>
<arg name="hw_registered_processing" default="true" />
<arg name="sw_registered_processing" default="true" />
<!-- Disable bond topics by default -->
<arg name="bond" default="false" /> <!-- DEPRECATED, use respawn arg instead -->
<arg name="respawn" default="$(arg bond)" />
<!-- Worker threads for the nodelet manager -->
<arg name="num_worker_threads" default="4" />
<!-- enable libfreenect debug logging -->
<arg name="libfreenect_debug" default="false" />
<!-- enable diagnostics support for freenect_camera -->
<arg name="enable_rgb_diagnostics" default="false" />
<arg name="enable_ir_diagnostics" default="false" />
<arg name="enable_depth_diagnostics" default="false" />
<arg name="diagnostics_max_frequency" default="30.0" />
<arg name="diagnostics_min_frequency" default="30.0" />
<arg name="diagnostics_tolerance" default="0.05" />
<arg name="diagnostics_window_time" default="5.0" />
<!-- Push down all topics/nodelets into "camera" namespace -->
<group ns="$(arg camera)">
<!-- Start nodelet manager in provided namespace -->
<arg name="manager" value="$(arg camera)_nodelet_manager" />
<arg name="debug" default="false" /> <!-- Run manager in GDB? -->
<include file="$(find rgbd_launch)/launch/includes/manager.launch.xml">
<arg name="name" value="$(arg manager)" />
<arg name="debug" value="$(arg debug)" />
<arg name="num_worker_threads" value="$(arg num_worker_threads)" />
</include>
<!-- Load driver -->
<include if="$(arg load_driver)"
file="$(find freenect_launch)/launch/includes/device.launch.xml">
<!-- Could really use some syntactic sugar for this -->
<arg name="manager" value="$(arg manager)" />
<arg name="device_id" value="$(arg device_id)" />
<arg name="rgb_frame_id" value="$(arg rgb_frame_id)" />
<arg name="depth_frame_id" value="$(arg depth_frame_id)" />
<arg name="rgb_camera_info_url" value="$(arg rgb_camera_info_url)" />
<arg name="depth_camera_info_url" value="$(arg depth_camera_info_url)" />
<arg name="depth_registration" value="$(arg depth_registration)" />
<arg name="data_skip" value="$(arg data_skip)" />
<arg name="rgb" value="$(arg rgb)" />
<arg name="ir" value="$(arg ir)" />
<arg name="depth" value="$(arg depth)" />
<arg name="depth_registered" value="$(arg depth_registered)" />
<arg name="projector" value="$(arg projector)" />
<arg name="respawn" value="$(arg respawn)" />
<arg name="libfreenect_debug" value="$(arg libfreenect_debug)" />
<arg name="enable_rgb_diagnostics" value="$(arg enable_rgb_diagnostics)" />
<arg name="enable_ir_diagnostics" value="$(arg enable_ir_diagnostics)" />
<arg name="enable_depth_diagnostics" value="$(arg enable_depth_diagnostics)" />
<arg name="diagnostics_max_frequency" value="$(arg diagnostics_max_frequency)" />
<arg name="diagnostics_min_frequency" value="$(arg diagnostics_min_frequency)" />
<arg name="diagnostics_tolerance" value="$(arg diagnostics_tolerance)" />
<arg name="diagnostics_window_time" value="$(arg diagnostics_window_time)" />
</include>
<!-- Load standard constellation of processing nodelets -->
<include file="$(find rgbd_launch)/launch/includes/processing.launch.xml">
<arg name="manager" value="$(arg manager)" />
<arg name="rgb" value="$(arg rgb)" />
<arg name="ir" value="$(arg ir)" />
<arg name="depth" value="$(arg depth)" />
<arg name="depth_registered" value="$(arg depth_registered)" />
<arg name="projector" value="$(arg projector)" />
<arg name="respawn" value="$(arg respawn)" />
<arg name="rgb_processing" value="$(arg rgb_processing)" />
<arg name="ir_processing" value="$(arg ir_processing)" />
<arg name="depth_processing" value="$(arg depth_processing)" />
<arg name="depth_registered_processing" value="$(arg depth_registered_processing)" />
<arg name="disparity_processing" value="$(arg disparity_processing)" />
<arg name="disparity_registered_processing" value="$(arg disparity_registered_processing)" />
<arg name="hw_registered_processing" value="$(arg hw_registered_processing)" />
<arg name="sw_registered_processing" value="$(arg sw_registered_processing)" />
</include>
</group> <!-- camera -->
<!-- Load reasonable defaults for the relative pose between cameras -->
<include if="$(arg publish_tf)"
file="$(find rgbd_launch)/launch/kinect_frames.launch">
<arg name="camera" value="$(arg camera)" />
</include>
</launch>
I am run a Kinect
roslaunch freenect_launch freenect.launch
I am run a ASUS and Kinect
roslaunch openni_launch openni.launch
once running the second camera in the terminal of ASUS as second camera, output:
[ERROR] [1550795336.052843598]: Failed to find nodelet with name '/camera/disparity_registered_hw' to unload
also, the output for Kinect became:
[FATAL] [1550795336.061536430]: Failed to unload nodelet '/camera/disparity_registered_hw` from manager `camera_nodelet_manager'
please help me
thank you in advance
I'd suggest trying to launch each node in their own namespace. Looking at the launch files, you should be able to run:
roslaunch freenect_launch freenect.launch camera:=cam_kinect
and
roslaunch openni_launch openni.launch camera:=cam_asus
This should avoid conflict with node names and topic names.
I am using this command to build dojo 1.9.3
"ant -file buildWAR.xml -DbuildWorkDir=G:\Codebase\folder\PSInviter -DzuoraJarFile=WebContent\WEB-INF\lib\zuora.jar"
but in reponse of this I am getting the following error:
[exec] G:\Codebase\folder\PSInviter\WebContent\js\dojo-release-1.9.3-src\util\ buildscripts>java -Xms256m -Xmx256m -cp " G:\Codebase\folder\PSInviter\WebContent\js\dojo-release-1.9.3-src\uti
l\buildscripts\../shrinksafe/js.jar";"G:\Codebase\folder\
PSInviter\WebContent\js\dojo-release-1.9.3-src\util\buildscripts\../closureCompi
ler/compiler.jar";"G:\Codebase\folder\PSInviter\WebConten
t\js\dojo-release-1.9.3-src\util\buildscripts\../shrinksafe/shrinksafe.jar" org.
mozilla.javascript.tools.shell.Main "G:\Codebase\folder\
PSInviter\WebContent\js\dojo-release-1.9.3-src\util\buildscripts\../../dojo/dojo
.js" baseUrl="G:\Codebase\folder\PSInviter\WebContent\js\
dojo-release-1.9.3-src\util\buildscripts\../../dojo" load=build releaseDir=G:\Codebase\folder\PSInviter\WebContent\js\builds/ profileFile
=G:\Codebase\folder\PSInviter/WebContent/js/somefolder
/timedriver.profile.js copyTests=false action=clean,release optimize=shrinksafe
localeList=ar,ca,cs,da,de,de-de,el,en,en-au,en-ca,en-gb,en-us,es,es-es,fi,fr,he,
hu,it,it-it,ja,ja-jp,ko,ko-kr,nb,nl,pl,pt,pt-br,ru,sk,sl,sv,th,tr,zh,zh-cn,zh-tw
releaseName=1405191028 internStrings=true cssOptimize=comments excludeFromBase=
true
[exec] org.mozilla.javascript.WrappedException: Wrapped java.net.MalformedURLException: unknown protocol: g
below is my buildWar.xml file's code
<?xml version="1.0"?>
<!-- Build the PSInviter WAR project -->
<project name="PSInviter.WAR" basedir="." default="default">
<!-- All properties are in build.properties -->
<property environment="env" />
<property file="buildWAR.properties" />
<property name="dojoSrcRelease" location="WebContent/js/dojo-release-1.9.3-src" />
<property name="outputDir" location="WebContent/js/builds" />
<path id="compile.classpath">
<pathelement path="${classes.dir}" />
<fileset dir="${was.api.dir}" includes="runtimes/websphere_apis.jar" />
<fileset dir="${was.api.dir}" includes="java/jre/lib/**/*.jar" />
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
<target name="init" description="Initialize the build process">
<delete dir="${build.dir}/js/builds"/>
<mkdir dir="${build.dir}/js/builds"/>
<delete dir="${outputDir}"/>
<mkdir dir="${outputDir}"/>
<mkdir dir="${temp.artifacts.dir}"/>
<tstamp>
<format property="buildDateTime" pattern="yyMMddHHmm"/>
</tstamp>
</target>
<target name="build-dojo" description="" depends="init">
<exec dir="${dojoSrcRelease}/util/buildscripts/" executable="${dojoSrcRelease}/util/buildscripts/build.bat">
<arg line="releaseDir="${outputDir}/""/>
<arg line="profileFile="${basedir}/WebContent/js/someFolder/timedriver.profile.js""/>
<arg line="copyTests=false"/>
<arg line="action=clean,release"/>
<arg line="optimize=shrinksafe"/>
<arg line="localeList=ar,ca,cs,da,de,de-de,el,en,en-au,en-ca,en-gb,en-us,es,es-es,fi,fr,he,hu,it,it-it,ja,ja-jp,ko,ko-kr,nb,nl,pl,pt,pt-br,ru,sk,sl,sv,th,tr,zh,zh-cn,zh-tw"/>
<arg line="releaseName=${buildDateTime}" />
<arg line="internStrings=true" />
<arg line="cssOptimize=comments" />
<arg line="excludeFromBase=true" />
</exec>
<replaceregexp file="${basedir}/WebContent/WEB-INF/startup.properties"
match="TDBuildNumber=(.*)"
replace="TDBuildNumber=${buildDateTime}"
byline="true"/>
<java dir="WebContent/js" classname="org.mozilla.javascript.tools.shell.Main" fork="true">
<arg value="nonDojo/nonDojoBuilder.js"/>
<arg value="nonDojo/base.js|nonDojo/login.js|nonDojo/securityPolicy.js|nonDojo/MD5.js|jsonrpc.js|nonDojo/loginpage.js"/>
<arg value="${outputDir}/${buildDateTime}/loginPage.js"/>
<classpath>
<pathelement location="${exec.dir}/../WebContent/WEB-INF/lib/js.jar"/>
<pathelement location="${exec.dir}/../WebContent/WEB-INF/lib/shrinksafe.jar"/>
</classpath>
</java>
<java dir="WebContent/js" classname="org.mozilla.javascript.tools.shell.Main" fork="true">
<arg value="nonDojo/nonDojoBuilder.js"/>
<arg value="nonDojo/base.js|nonDojo/login.js|nonDojo/sfdclanding.js|nonDojo/securityPolicy.js|nonDojo/MD5.js|jsonrpc.js|nonDojo/registration.js"/>
<arg value="${outputDir}/${buildDateTime}/sfdclandingPage.js"/>
<classpath>
<pathelement location="${exec.dir}/../WebContent/WEB-INF/lib/js.jar"/>
<pathelement location="${exec.dir}/../WebContent/WEB-INF/lib/shrinksafe.jar"/>
</classpath>
</java>
<copy file="${basedir}/WebContent/js/jsonrpc.js" todir="${outputDir}/${buildDateTime}" />
<copy file="${basedir}/WebContent/js/nonDojo/securityPolicy.js" todir="${outputDir}/${buildDateTime}" />
</target>
<target name="copy-files" depends="build-dojo" description="Copy the web content files">
<copy todir="${build.dir}">
<fileset dir="${web.dir}">
<exclude name="**/.svn"/>
<exclude name="**/js/dojo*/**"/>
<exclude name="**/js/someFolder/**"/>
</fileset>
</copy>
<copy todir="${build.dir}/AST" failonerror="true">
<fileset dir="AST">
<exclude name="**/.svn"/>
</fileset>
</copy>
<copy todir="${build.dir}/WEB-INF/lib" failonerror="true" file="${zuoraJarFile}" overwrite="true" />
</target>
<target name="compile" depends="copy-files" description="Compile the Java source code">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
includes="**/*.java"
classpathref="compile.classpath"
source="${javac.source}"
target="${javac.target}"
debug="${javac.debug}"
fork="true"
includeAntRuntime="no"
/>
</target>
<target name="war" depends="compile" description="Create the WAR file">
<manifest file="MANIFEST.MF">
<attribute name="Build-Version" value="${buildVersion} - ${buildDateTime}"/>
</manifest>
<delete dir="${build.dir}/AST"/>
<mkdir dir="target"/>
<war destfile="target/${war.file}"
webxml="${web-inf.dir}/web.xml"
basedir="${build.dir}"
manifest="MANIFEST.MF"
/>
<copy todir="${temp.artifacts.dir}" failonerror="true">
<fileset dir="target">
<exclude name="**/.svn"/>
<include name="${war.file}"/>
</fileset>
</copy>
</target>
<target name="jar" depends="compile" description="Create the timedriver jar file">
<jar destfile="target/${jar.file}"
basedir="${classes.dir}"
/>
<copy todir="${temp.artifacts.dir}" overwrite="true" failonerror="true">
<fileset dir="target">
<exclude name="**/.svn"/>
<include name="${jar.file}"/>
</fileset>
</copy>
</target>
<target name="default" depends="war, jar" />
</project>
Anyone know about this error, please help.
Regards
I was experiencing a similar problem and after some investigation I realize that the problem was that I have ignored a couple of directories required to create the dojo build.
In my particular case the issue was related to ignoring (deleted) the util/build directory of the sdk.
You can debug this by adding:
console.log(url);
At dojo/_base/configRhino.js on the isLocal function.
This function determines if a file is local or a URL and if the file does not exists then it assumes that is a URL and then the exception occur.
That extra line is going to print all the files that is trying to use and when it breaks the last file path that printed is the faulty one.
All of this of course is just a guess based on my experience.
I'm working with ant for the first time, read lots of tutorials and examples, and still cant make this works. Every target works, but with test im getting
"Test TestMaze failed (crashed)."
I've tried to change lot of things (using lot of examples), still nothing. Can anyone tell me where is the problem please? Thanks a lot.
<?xml version="1.0"?>
<project name="Maze" default="default" basedir=".">
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<property name="dist.dir" location="dest-server" />
<property name="test.dir" location="test" />
<property name="test.report.dir" location="testreport" />
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${test.report.dir}" />
</target>
<path id="junit.class.path">
<pathelement location="lib/junit-4.10.jar" />
<pathelement location="${build.dir}" />
</path>
<target name="compile" depends="clean">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" />
<javac srcdir="${test.dir}" destdir="${build.dir}">
<classpath refid="junit.class.path" />
</javac>
<jar destfile="${dist.dir}\Maze.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="maze.tape.Commands" />
</manifest>
</jar>
</target>
<target name="test" depends="compile">
<junit printsummary="on" fork="true" haltonfailure="yes">
<classpath refid="junit.class.path" />
<formatter type="xml" />
<batchtest todir="${test.report.dir}">
<fileset dir="${test.dir}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="run" depends="compile">
<java jar="dest-server/Maze.jar" fork="true"/>
</target>
</project>
Your test target is generating an xml file because you are using:
<formatter type="xml" />
when the attribute usefile is not used, the default value will be set and in this case, the value is "true".
You can set the attribute to false and the output will be displayed in the console.
I am only using apache-ant and not ant-contrib
I have an ant target
<target name="stop" depends="init" >
...
</target>
In which i want to invoke exec task.
If the value of a variable HOST_NAME is all
<exec executable="${executeSSH.shell}" >
<arg value="-h ${HOST_NAME}" />
<arg value="-i ${INSTANCE}" />
<arg value="-w 10" />
<arg value="-e ${myOperation.shell} " />
<arg value=" -- " />
<arg value="${INSTANCE} ${USERNAME} ${PASSWORD}" />
</exec>
If the value of a variable HOST_NAME is anything else
<exec executable="${executeSSH.shell}">
<arg value="-h ${HOST_NAME}" />
<arg value="-i ${INSTANCE}" />
<arg value="-e ${myOperation.shell} " />
<arg value=" -- " />
<arg value="${INSTANCE} ${USERNAME} ${PASSWORD}" />
</exec>
But i would like to write only one task and not to repeatexec. I have used HOST_NAME parameter but what to do about the second parameter -w 10 which is different in both calls.
I have tried a couple of ways by searching on SO by using condition and if else but nothing seems to be applicable for exec or arg.
You can use the condition task:
<condition property="my.optional.arg" value="-w 10" else="">
<equals arg1="${HOST_NAME}" arg2="all" />
</condition>
<exec executable="${executeSSH.shell}" >
<arg value="-h ${HOST_NAME}" />
<arg value="-i ${INSTANCE}" />
<arg line="${my.optional.arg}" />
<arg value="-e ${myOperation.shell} " />
<arg value=" -- " />
<arg value="${INSTANCE} ${USERNAME} ${PASSWORD}" />
</exec>
Try using macrodef. The following example is not tested.
<macrodef name="callSSH">
<element name="extArgs" optional="y"/>
<sequential>
<exec executable="${executeSSH.shell}" >
<arg value="-h ${HOST_NAME}" />
<arg value="-i ${INSTANCE}" />
<extArgs/>
<arg value="-e ${myOperation.shell} " />
<arg value=" -- " />
<arg value="${INSTANCE} ${USERNAME} ${PASSWORD}" />
</exec>
</sequential>
</macrodef>
<target name="stop" depends="init" >
<if>
<equals arg1="${HOST_NAME}" arg2="all"/>
<then>
<callSSH>
<extArgs>
<arg value="-w 10" />
</extArgs>
</callSSH>
</then>
<else>
<callSSH>
<extArgs/>
</callSSH>
</else>
</if>
</target>
Or if you don't use contribs:
<target name="sshExecWithHost" if="HOST_NAME">
<callSSH>
<extArgs>
<arg value="-w 10" />
</extArgs>
</callSSH>
</target>
<target name="sshExecNoHost" unless="HOST_NAME">
<callSSH/>
</target>
<target name="sshSwitch" depends="sshExecNoHost,sshExecWithHost">
</target>
<target name="stop" depends="init,sshSwitch" >
</target>
Given a list of directories:
<ItemGroup>
<Dirs Include="Foo\Dir1" />
<Dirs Include="Foo\Dir2" />
</ItemGroup>
How can I get a list of all subdirectories.
Transforming this list with "$(Identity)\**" does not match anything and transforming with "$(Identity)\**\*" and then with RelativeDir yields only directories that contain files.
Currently I have to resort to C#:
<UsingTask TaskName="GetSubdirectories" TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Directories ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<SubDirectories ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs"><![CDATA[
var result = new List<ITaskItem>();
foreach (var dirItem in Directories) {
foreach (var dir in Directory.GetDirectories(dirItem.ItemSpec, "*", SearchOption.AllDirectories)) {
if (dir.Contains(#"\.svn\") || dir.EndsWith(#"\.svn")) continue;
result.Add(new TaskItem(dir));
}
}
SubDirectories = result.ToArray();
]]></Code>
</Task>
</UsingTask>
<GetSubdirectories Directories="#(Dirs)">
<Output TaskParameter="SubDirectories" ItemName="SubDirs" />
</GetSubdirectories>
But I would like to know if there is an easier way.
Excerpted from the book "MSBuild Trickery":
<Import Project="EnableAllPropertyFunctions.tasks" />
<Target Name="GetSubdirectories">
<ItemGroup>
<Dirs Include="$([System.IO.Directory]::
EnumerateDirectories(
`.\Foo`,
`*`,
System.IO.SearchOption.AllDirectories))"
/>
</ItemGroup>
<Message Text="%(Dirs.Identity)" />
</Target>
You'll need to first enable the extended property function set by ensuring that the environment variable MSBuildEnableAllPropertyFunctions is set to the value 1 (that is what the imported .tasks file accomplishes, with an inline task).
Once #(Dirs) is set up, you can filter it with the Remove attribute to get rid of the Subversion folders.
<CreateItem Include="$(OutputFolder)\*\*.*">
<Output TaskParameter="Include" ItemName="FilesInSubFolders" />
</CreateItem>
<RemoveDuplicates Inputs="#(FilesInSubFolders->'%(RelativeDir)')">
<Output TaskParameter="Filtered" ItemName="SubDirs"/>
</RemoveDuplicates>
<Message Text="#(SubDirs)"/>
This will put all the immediate subfolder paths into #(SubDirs). If you change Include="$(OutputFolder)\*\*.*" to Include="$(OutputFolder)\**\*.*", it'll include all subfolders recursively.
To expand on Brian's answer with a fully self-contained example:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GetSubdirectories">
<UsingTask TaskName="SetEnvironmentVariable"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll">
<ParameterGroup>
<Name ParameterType="System.String" Required="true" />
<Value ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs"><![CDATA[
Environment.SetEnvironmentVariable(Name, Value);
]]></Code>
</Task>
</UsingTask>
<Target Name="GetSubdirectories">
<SetEnvironmentVariable Name="MSBuildEnableAllPropertyFunctions" Value="1" />
<ItemGroup>
<Dirs Include="$([System.IO.Directory]::EnumerateFiles('.\Stuff', '*', System.IO.SearchOption.AllDirectories))"/>
</ItemGroup>
<Message Text="%(Dirs.Identity)" />
</Target>
</Project>
I got the UsingTask example from this answer.