我在 ASP.NET Core 3.1应用程序上有以下内容:
<Target Name="OnBuild" BeforeTargets="Build">
<Exec WorkingDirectory="approot" Command="npm run build --prod" />
<Copy SourceFiles="approotdist" DestinationFolder="wwwroot" />
</Target>
当我构建时,我收到一个错误:
The source file "approot/dist" is actually a directory.
The "Copy" task does not support copying directories.
如何使用 MSBuild 将目录approotdist
复制到wwwroot
?
试试这个:
<Target Name="OnBuild" BeforeTargets="Build">
<ItemGroup>
<Folder Include="**approot***.*" />
</ItemGroup>
<Copy SourceFiles="@(Folder)" DestinationFolder="wwwroot%(RecursiveDir)"></Copy>
</Target>
我能够使用以下xCopy语法解决此问题:
<Exec Command="xcopy "approotdist" "wwwroot" /S /Y /I" />
哪里:
- Approot\dist - 源路径
- wwwroot - 目标路径
- /Y - 禁止显示覆盖目标文件(如果存在(的确认。
- /I - 如果目标不存在,则此选项假定目标是目录并创建它。如果省略此选项,该命令将提示您确认目标是目录还是文件。
- /S - 以递归方式复制文件夹和子文件夹,不包括空文件夹和子文件夹。