4
votes

I'm using TeamCity to build and deploy into our demo site. We have one configuration called HTML Demo Site and one of the build step is using NAnt to deploy the HTML to the site.

The build file have defined a target:

<target name="deploy-html" description="Deploys the HTML to the demo server">
    <echo message="Deploying HTML to the demo server..."/>
    <copy todir="\\<server>\<dir>\<client>" includeemptydirs="true" overwrite="true">
        <fileset basedir="..\html\_master">
            <include name="**\*"/>
            <exclude name="node_modules\**"/>
        </fileset>
    </copy>
</target>

Each time I run the build on TeamCity, it's failing with this error:

C:\tc\w\9149e011dfa8657d\build_scripts\website.build(27,14):
[NAnt output] Error creating FileSet.
[NAnt output]     The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

So I tried running on PowerShell to get a list of files that exceed the max length:

Get-ChildItem -Recurse | Where-Object {$_.FullName.Length -gt 248}

But the only files returned are files under the node_modules directory. But in the build file, it's being excluded. So I'm not sure where else to look? Any ideas?

2
1. Did you run powershell on your build machine? 2. Is node_modules folder directly under the _master folder? If not change the exclude condition to "*/node_modules/". 3. Team city is adding a long id to the folder name on the build server "C:\tc\w\9149e011dfa8657d\build_scripts"Isaiah4110
1. I ran PowerShell both on my local machine and the build machine. 2. The node_modules directory is underneath the _master directory. Other: I also ran the NAnt script locally on both machine. In my local machine, the NAnt ignores the node_modules directory as expected. In the build machine, the NAnt script ignores the exclude condition and includes the node_modules directory causing the error.TimAlonso
Same version of NANT on both machines? and if yes which version? I will test this on my machine and let you know in a bit.Isaiah4110
Just tested it on my machine, it errors out when the path length is more than what windows allows. It is not happening for you locally since you are local path is not hitting the limit, if you rename some of the folders in there it will throw the error locally as well. I didnt get time to look through the NANT code and find why it is happening for excluded folders. Will spend some time later.Isaiah4110
Here are some limits in Windows APIs that you should know about: #define MAX_PATH 260 // Maximum length of full path #define MAX_DIR 256 // Maximum length of path component #define MAX_FNAME 256 // Maximum length of file name component #define MAX_EXT 256 // Maximum length of extension componentIsaiah4110

2 Answers

3
votes

You could try a few things:

  • Delete the node_modules dir first
  • Use robocopy /mir in an <exec> task
  • try putting exclude first before include (not likely, but worth a try)
  • try changing the path expression to name="node_modules\**\*" or name="**\node_modules\**" or similar
2
votes

Deleting first worked for me - but the built in nant delete task also has problems so I had to use the rmdir console command

<exec program="${environment::get-variable('WinDir')}\system32\cmd">
    <arg value="/c &quot;rmdir /q /s ${Build.BuildFolder}\WebApplication\node_modules&quot;" />
</exec>