Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nant failing with bad permissions on build server

Total newbie question. I am trying to run a Nant script on a build server (very basic script, not doing anything), and it's failing with the error

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

What should I do to get it running?

like image 229
Aidan Avatar asked Sep 15 '10 14:09

Aidan


2 Answers

My error message mentioned the "Internet Zone". This is probably because I downloaded zipped binaries from SourceForge. I zipped and then unzipped to strip the zone and that worked great for me.

On Windows 7 (or similar):

  1. Select all files in the NAnt folder
  2. Right click, Send to > Compressed (zipped) folder
  3. Right click on new zip file and choose "Extract All..."
  4. Extract to a new folder

The extracted files will no longer be from the "Internet Zone". You can copy back into the original directory if you wish.

like image 102
DanielLarsenNZ Avatar answered Sep 18 '22 11:09

DanielLarsenNZ


@TK has the answer here, I believe, though it may not be as simple as whether or not nant is running from a network drive.

I have had a similar issue as @Aidan. It turns out that I had copied the nantcontrib (v .86) assemblies to my build system in such a way that Windows 7 restricted access to the nantcontrib assemblies. To fix this, I first copied the nantcontrib zip file to my build VM, then overwrote the blocked assemblies with the contents of the .zip. Windows 7 saw that the files were coming from the local system (rather than from whatever untrusted source I had copied from originally) and it unblocked the assemblies.

There is probably a more direct means of trusting the assemblies (such as @TK's link), but this worked for me.

If you see this error again, look for two things:

First, Nant (v .91 alpha 2) does a decent job reporting exactly what the error is. I saw the same error as @Adian, along with a complete error stack, and finally this information (emphasis mine):

The assembly or AppDomain that failed was: NAnt.Contrib.Tasks, Version=0.86.3319.0, Culture=neutral, PublicKeyToken=null The method that caused the failure was: NAnt.Core.Task CreateChildTask(System.Xml.XmlNode)
The Zone of the assembly that failed was: Internet
The Url of the assembly that failed was: file:///C:/Program Files (x86)/NAntBuilder 2/nantcontrib/bin/NAnt.Contrib.Tasks.dll

Second, look at the property page of the offending assembly (in my case, Nant.Contrib.Tasks.dll). If the file has been copied from an untrusted source, you will see an "Unblock" button in the properties section (beneath Advanced...) along with a note which stated that the files had come from an untrusted source.

like image 32
Zeinrich Avatar answered Sep 18 '22 11:09

Zeinrich