I am running the following command from my ant target:
<exec executable="${soa.mypath}\deploy.exe" failonerror="true" vmlauncher="false">
<arg value="-n" />
<arg value="${myfile}" />
</exec>
Where ${soa.mypath} is B:\bin.
This drive B is a network drive that I mapped on a other server.
when I connect remotly to the server where that ant script is running I can totally see and browse the B drive via the Windows explorer and the user I use is the same user that runs tha ant script.
However when I run my target, I got this error:
[exec] The system cannot find the drive specified.
Which is very weird.
Do you know if I am missing some option in the exec command?
Thank you,
Regards
Using ant 1.9.3 under Windows 8.1 I was able to get this to work with no problem with a network-mounted drive, including various combinations of forward and backslashes in the path.
My only suggestion is to replace your property with the hard-coded executable path (B:\bin\deploy.exe) in the exec task and see if that works. Also - use hard-coded path to ${myfile}.
If deploy.exe has a -version command or similar you might also try that, to rule out the problem actually being in the drive/path of ${my file}.
hth
Related
Here is my ant script that wants to convert the script to executable from a zip. Here is what I do:
unzip a .zip file,
store to temp directory
run the script 'pkg' with a argument validate
<chmod dir="tmp/temp/test/bin" perm="ugo+rx" includes="**/*" />
<echo message="Making scripts exec: tmp/temp/test/bin" />
<exec executable="/bin/bash">
<arg value="tmp/temp/test/bin/pkg"/>
<arg value="validate"/>
</exec>
This does not make the script executable and instead gives this error:
Execute failed: java.io.IOException: Cannot run program "D:\tmp\temp\test\bin": CreateProcess error=5, Access is denied.
Cannot run program "D:\tmp\temp\test\bin": CreateProcess error=5, Access is denied.
Are you running this under Windows or Linux/Unix/MacOS?
Windows doesn't have the concept of executability in a file. Instead, it associates file suffixes with executable programs. For example, I could associate the .py suffix to be associated with the python.exe program. Opening foo.py will run that Python script under the Python executable. Change the name to foo.pl, and either the script won't run, or if you've associated .pl with perl.exe, will run the script under Perl.
You can add the suffix of your script to the %PATHEXT% environment variable which will allow you to type the file name sans extension. For example, if I added .py to %PATHEXT%, and I type in foo into the command line terminal, Windows may look for foo.py and then execute that. (unless it finds foo.exe or foo.bat first. Then those would execute).
The <chmod> task does nothing under Windows. In the <chmod> man page, it states:
Changes the permissions of a file or all files inside specified directories. Right now it has effect only under Unix or NonStop Kernel (Tandem).
Also, not all Zip implementations can store file permission and ownership information -- especially Unix style permissions and ownership. Some can, and some can't. Even if you somehow want to express the file's executability for Unix systems, it may not work.
What I recommend is to include a <condition> test in your script to test for the OS. Then, you can separate what to do if you're on Linux/Windows/MacOS and what you want to do on a Windows system.
I used the Automator tool on my mac to generate a .app file (well a directory, to be more precise). I am trying to execute this .app in an ant build.xml, but it gives me a file/directory not found error. I tried running exec on both the .app folder and on the "Application Stub" file buried inside, but both produced the same error. This should be straightforward, but I'm new to both automator and ant so I don't know the right syntax here.
More specifically, how do I run the task open MyApp.app in a build.xml file?
Maybe the following:
open -a MyApp.app
or
open -a MyApp
both should work.
I have noticed though that my apps created with Automator seem to have "funny" names for awhile. You can see "good names" in the Finder, but when I try to open their AppleScript dictionaries from AppleScript editor, the names are some kind of hex codes or something. (I'd give you a screen-shot but I don't have enough reputation points here yet to post an image.)
You could try opening up some other app from Ant see if that works.
<exec executable="open">
<arg value="MyApp.app" />
</exec>
I am trying to deploy a console application to a folder on a DMZ server using autodeploy with MSBuild and Team Foundation Server.
I am already deploying multiple sites to that same server and it works great. I have tried multiple ways but the files are not deployed.
First, I tried to deploy the console app in the same way as i do for my web site, ie:
<MSBuild
Projects="$(SolutionRoot)\MySolution.sln"
Properties="AllowUntrustedCertificate=True;AuthType=Basic;
Configuration=DEBUG;CreatePackageOnPublish=True;
DeployIisAppPath=Default Website/dummy.dev.myapp;
DeployOnBuild=True;DeployTarget=MsDeployPublish;
MSDeployPublishMethod=WMSvc;
MsDeployServiceUrl=https://xxx.xxx.xxx.xxx:8172/MsDeploy.axd;
UserName=userid;Password=password;UseMsdeployExe=True"
/>
Without success.
EDIT: No error message is returned. It all seems to go well.
Then, I also tried to deploy the console app as follows:
<Exec Command=""C:\Program Files\IIS\Microsoft Web Deploy V2\MSDeploy.exe"
-verb:sync
-source:contentpath="$(OutDir)\MyApp.Precompiled"
-dest:contentpath="D:\dev.myapp",computername=xxx.xxx.xxx.xxx,username=userid,password=password"
ContinueOnError="false" />
I actually also tried with computername as https://xxx.xxx.xxx.xxx:8172/MsDeploy.axd.
EDIT: The following is what I got.
EXEC: FileOrFolderNotFound
EXEC: Object of type 'contentPath' and path 'E:\Builds\1...\dev.myapp' cannot be created.
EXEC: The path '\?\E:\Builds\1...\dev.myapp' is not valid.
EXEC: 1.
E:\Builds\1...\BuildType\Targets\Deploy.targets (142): The command ""C:\Program Files\IIS\Microsoft Web Deploy V2\MSDeploy.exe" -verb:sync -source:contentpath="E:\Builds\1...\dev.myapp" -dest:contentpath="D:\dev.myapp",computername=https://xxx.xxx.xxx.xxx:8172/MsDeploy.axd,username=userid,password=password" exited with code -1.
I realize I haven't read all of the error, Do I really need an UNC path?
Does anyone know how to do this?
I finally found out how to make it work.
<Exec Command=""C:\Program Files\IIS\Microsoft Web Deploy V2\MSDeploy.exe"
-verb:sync
-source:contentpath="$(OutDir)\MyApp.Precompiled"
-dest:contentpath="D:\dev.myapp",computername=https://xxx.xxx.xxx.xxx:8172/MsDeploy.axd,username=userid,password=password,authtype=Basic
-allowUntrusted=True"
ContinueOnError="false" />
I changed computername to computername=https://xxx.xxx.xxx.xxx:8172/MsDeploy.axd, added authtype=Basic and allowUntrusted=True and voila it worked.
It was quite frustrating not having any kind of feedback of what went wrong with the first option. But when I was using the second alternative I got feedback to work with.
If anyone know how to make this work using the MSBuild task, please feel free to enlighten me.
Try dirPath provider instead of contentPath, it'll behave more like a folder sync rather than IIS web site deployment.
Considering the sync worked using the EXEC task, did you make sure you have the Microsoft.WebApplication.targets in your csproj (or vbproj) file? I could see it just ignoring that msbuild task without the correct targets file included.
For example in my web service project files, I have this towards the bottom of my csproj file
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
I am trying to set up ANT build.
However when I invoke build command
helloworld_15/${NAME} does not exist.
BUILD FAILED (total time: 0 seconds)
Also the configure variables does not seems to be assigned.
However i have set them into /etc/envitonment
I tried echo $<varaiable_name> and value get displayed.
Tried to google but not solutions seems am the first one having this issue.
PS: OS Ubuntu 10.10
The environment variables of the calling shell are not, by default, converted into Ant properties. If you want to access them, you need to 'import' them using something like:
<property environment="e_pref" />
in your buildfile. Once you've done that, you can access them by means of the prefix you just set:
<echo message="NAME=${e_pref.NAME}" />
You can set environment="" - i.e. an empty prefix - but you would still need the dot to access:
<echo message="NAME=${.NAME}" />
Sorted out the issue.
Somehow netbeans ant does not access environment variables when run in sudo mode.
I didnt find out a solution for that but i settled down with non sudo UI fornetbeans.
Thanx for your valuable time and help.
Of course it can be done using the exec task, but my question is:
Is it possible to do it using the tar task?
I don't think there is a way to retain existing permissions, per this note from the copy task:
Unix Note: File permissions are not retained when files are copied; they end up with the default UMASK permissions instead. This is caused by the lack of any means to query or set file permissions in the current Java runtimes. If you need a permission-preserving copy function, use <exec executable="cp" ... > instead.
However the tar task can take one or more tarfileset elements. The tarfileset can be defined with a filemode and/or dirmode attribute to specify the unix permissions. If you specify multiple includes matching only those files to get each set of required permissions, the files in that set will be included with those permissions.
It is impossible. This lack of permission makes ant tar task almost useless for me. There's no way to do it without executing the operating system tar with the exec task:
<exec executable="tar" output="/dev/null" os="Linux">
<arg value="--exclude-from=files_to_exclude.txt"/>
<arg value="-cvz"/>
<arg value="--file=${file.tar}"/>
<arg value="."/>
</exec>
There are gnu tar binaries for almost all operating systems known to man. Put one of them in your version control system and use it depending in your operating system. Yes, Ant will need to fork a process every time it is run.
Using tarfileset worked for our project. Here's a working example in case someone needs it:
<tar destfile="${dist}/${module.name}-${version}.tar">
<tarfileset dir="${package.dir}" filemode="550" includesfile="${home.dir}/includelist.txt">
<include name="*.sh"/>
</tarfileset>
</tar>
In this example, includelist.txt is used to tell which files to include in the tar file. All the files with *.sh extension will have Read and Execute permission (550) for the user and the group.
Hope this helps someone.