Nant failing with bad permissions on build server

前端 未结 5 1057
有刺的猬
有刺的猬 2021-02-07 07:58

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

相关标签:
5条回答
  • 2021-02-07 07:58

    @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.

    0 讨论(0)
  • 2021-02-07 08:00

    This problem is caused by Windows setting the files' "Zone.Identifier" metadata in NTFS to "Internet" (or to another zone which you have to explicitly unblock to gain access).

    To not cause file security metadata to be written when you copy files or, in my case, unzip from a zip file on a network drive, either copy the zip file to a local folder before unzipping it, as previously suggested, or run the "streams.exe" tool from Sysinternals to remove that metadata.

    For example, if I run streams.exe on exe's in my Downloads folder:

    streams.exe *.exe
    
    Streams v1.56 - Enumerate alternate NTFS data streams
    Copyright (C) 1999-2007 Mark Russinovich
    Sysinternals - www.sysinternals.com
    
    C:\Downloads\jre-6u27-windows-x64.exe:
       :Zone.Identifier:$DATA       26
    

    Normally, streams.exe wouldn't display any metadata information if the files all originated from a local folder. If you do see these ":Zone.Identifier:$DATA" metadata (stored in NTFS as an alternate data stream), then you should also see an Unblock button in the files' Properties dialog.

    To unblock the files in bulk, run "streams.exe -s -d *.*" from your problematic folder.

    0 讨论(0)
  • 2021-02-07 08:16

    Are you running the Nant script on a network share drive?

    If so then you might need to configure the .NET Caspol policy to allow .NET code to be executed on a network share.

    Using CasPol to Fully Trust a Share

    This link might be able to help you.

    0 讨论(0)
  • 2021-02-07 08:17

    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.

    0 讨论(0)
  • 2021-02-07 08:19

    When you download NAnt, you have to right click on the zip file (before extracting evertything), then properties, and click on unblock file. Then extract everything and it will work.

    0 讨论(0)
提交回复
热议问题