如何解决在TeamCity中创建FileSet的NAnt错误?

时间:2022-11-23 15:01:24

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.

我正在使用TeamCity构建并部署到我们的演示站点。我们有一个名为HTML Demo Site的配置,其中一个构建步骤是使用NAnt将HTML部署到站点。

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:

每次我在TeamCity上运行构建时,它都会失败并出现此错误:

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:

所以我尝试在PowerShell上运行以获取超过最大长度的文件列表:

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?

但是返回的唯一文件是node_modules目录下的文件。但是在构建文件中,它被排除在外。所以我不确定还能在哪儿看?有任何想法吗?

2 个解决方案

#1


3  

You could try a few things:

你可以尝试一些事情:

  • Delete the node_modules dir first
  • 首先删除node_modules目录
  • Use robocopy /mir in an <exec> task
  • 任务中使用robocopy / mir
  • 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
  • 尝试将路径表达式更改为name =“node_modules \ ** \ *”或name =“** \ node_modules \ **”或类似

#2


2  

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

删除首先为我工作 - 但内置的nant删除任务也有问题所以我不得不使用rmdir控制台命令

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

#1


3  

You could try a few things:

你可以尝试一些事情:

  • Delete the node_modules dir first
  • 首先删除node_modules目录
  • Use robocopy /mir in an <exec> task
  • 任务中使用robocopy / mir
  • 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
  • 尝试将路径表达式更改为name =“node_modules \ ** \ *”或name =“** \ node_modules \ **”或类似

#2


2  

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

删除首先为我工作 - 但内置的nant删除任务也有问题所以我不得不使用rmdir控制台命令

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