给出这个xml:
<root>
<list>
<!-- foo's comment -->
<item name="foo" />
<item name="bar" />
<!-- another foo's comment -->
<item name="another foo" />
</list>
</root>
Run Code Online (Sandbox Code Playgroud)
我想使用XPath来选择有评论紧接所有这些项目节点,这是我喜欢选择"foo"和"另一个foo"的项目,但不是"栏"项.
我已经摆弄了前兄弟轴和comment()函数,但无济于事.
我想知道如何使用MSBuild同步两个文件夹,包括子文件夹.
我喜欢做的是
a)将源文件夹中的所有文件复制到dest文件夹中较新或不存在的dest文件夹
和
b)从源文件夹中删除dest文件夹中不再存在的所有文件
a)使用<Copy>任务很容易,但我怎样才能完成b)?
到目前为止,这是我的构建文件:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0"
DefaultTargets="Backup">
<PropertyGroup>
<SourceFolder>C:\source</SourceFolder>
<DestFolder>C:\dest</DestFolder>
</PropertyGroup>
<ItemGroup>
<FilesToCopy Include="$(SourceFolder)\**" />
</ItemGroup>
<Target Name="Backup">
<!-- copy all files from the source folder to the dest folder
that are newer or don't exist in the dest folder -->
<Copy
SourceFiles="@(FilesToCopy)"
DestinationFiles="@(FilesToCopy->'$(DestFolder)\%(RecursiveDir)%(Filename)%(Extension)')"
SkipUnchangedFiles="True" />
<!-- TODO: remove all files from the dest folder
that don't exist in the source folder -->
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud) 有人可以向我解释为什么以下语句的结果只有一个而不是一个?
MatchCollection matches = new Regex( ".*" ).Matches( "foo" ) ;
Assert.AreEqual( 1, matches.Count ) ; // will fail!
new Regex( ".+" ).Matches( "foo" ) ; // returns one match (as expected)
new Regex( ".*" ).Matches( "" ) ; // also returns one match
Run Code Online (Sandbox Code Playgroud)
(我正在使用.NET 3.5的C#)