我正在为MS PowerShell编写脚本.该脚本使用该Copy-Item命令.此命令的可选参数之一是" -container".该参数的文档声明指定此参数"在复制操作期间保留容器对象".
这一切都很好,因为在复制操作期间,我将是最后一个想要未预留容器对象的人.但严肃地说,这个论点有什么作用?特别是在我将磁盘目录树从一个地方复制到另一个地方的情况下,这对Copy-Item命令的行为有何不同?
我正在将一些 msbuild 脚本翻译为 powershell。
在 msbuild 中,我可以生成要(递归)复制到目标文件夹的文件的黑名单和/或白名单。
如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">
<PropertyGroup>
<!-- Always declare some kind of "base directory" and then work off of that in the majority of cases -->
<WorkingCheckout>.</WorkingCheckout>
<WindowsSystem32Directory>c:\windows\System32</WindowsSystem32Directory>
<ArtifactDestinationFolder>$(WorkingCheckout)\ZZZArtifacts</ArtifactDestinationFolder>
</PropertyGroup>
<Target Name="AllTargetsWrapped">
<CallTarget Targets="CleanArtifactFolder" />
<CallTarget Targets="CopyFilesToArtifactFolder" />
</Target>
<Target Name="CleanArtifactFolder">
<RemoveDir Directories="$(ArtifactDestinationFolder)" Condition="Exists($(ArtifactDestinationFolder))"/>
<MakeDir Directories="$(ArtifactDestinationFolder)" Condition="!Exists($(ArtifactDestinationFolder))"/>
<Message Text="Cleaning done" />
</Target>
<Target Name="CopyFilesToArtifactFolder">
<ItemGroup>
<MyExcludeFiles Include="$(WindowsSystem32Directory)\**\EventViewer_EventDetails.xsl" />
</ItemGroup>
<ItemGroup>
<MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.xsl" Exclude="@(MyExcludeFiles)"/>
<MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.xslt" Exclude="@(MyExcludeFiles)"/>
<MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.png" Exclude="@(MyExcludeFiles)"/>
<MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.jpg" …Run Code Online (Sandbox Code Playgroud)