I am trying to build the salesforce project on Visual Studio Online - TFS (hosted) server. I use GIT as source control and have a simple build file

<project name="Sample usage of Salesforce Ant tasks"  basedir="." xmlns:sf="antlib:com.salesforce">

<property file="build.properties"/>
<property environment="env"/>

<condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
<condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
<condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

 <taskdef uri="antlib:com.salesforce"

<!-- Shows check only; never actually saves to the server -->
<target name="deployCodeCheckOnly">
  <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="codepkg" checkOnly="true"/>

But I am getting following error when I start the build

C:\a\1f6c95b1\FAD_SFDC_GIT\FAD_SIT\build\build.xml:89: Problem: failed to create task or type antlib:com.salesforce:deploy
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.

Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
This appears to be an antlib declaration.
Action: Check that the implementing library exists in one of:
-a directory added on the command line with the -lib argument
Total time: 2 seconds
Unexpected exit code received from Ant: 1

I have included ant-salesforce-jar in the build file. Any idea?

  • 2
    Your class path is probably incorrect. I set up a Jenkins build that had the same error, and I had to actually move the jar file to another folder.
    – sfdcfox
    Jul 29, 2015 at 4:32

1 Answer 1


classpath="${basedir}/lib/ant-salesforce.jar" was wrong . Thanks @sfdcfox.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .