5

我正在尝试根据目录中的以下约定搜索一组程序集:

{SubDirName}\{SubDirName}.dll

我首先创建了一个 MSBuild ItemGroup [通过在 .RecursiveDir 部分上批处理另一个 ItemGroup]。

<AllAssemblies Include="$(SourceDirectory)\**\Test.*.dll" />
<Dirs Include="@(AllAssemblies->'%(RecursiveDir)')"/>

每个项目都有一个尾部斜杠,即:

<Message Text="@(Dirs)"/>

说:

SubDir1\;SubDir2\;SubDir3\

现在,我想从此列表中生成一组文件名。

问题是:

<AssembliesByConvention Include="@(Dirs -> '%(Identity)\%(Identity).dll')" />

生成:

SubDir1\\SubDir1\.dll;SubDir2\\SubDir2\.dll;SubDir3\\SubDir3\.dll

我不希望在.dll.

实现这一目标的最干净的方法是什么?

我知道有一个 HasTrailingSlash 表达式运算符,但在 OOTB 任务中没有 RemoveTrailingSlash 任务的迹象?。我对所需的 MSBuild 版本并不挑剔。

4

2 回答 2

1

你有没有尝试过

<AssembliesByConvention Include="@(Dirs -> '%(Identity)%(Identity).dll')" Condition="HasTrailingSlash(%(Identity))" />
<AssembliesByConvention Include="@(Dirs -> '%(Identity)\%(Identity).dll')" Condition="!HasTrailingSlash(%(Identity))" />
于 2010-08-04T07:25:05.577 回答
0

您可以使用 .NET 4.0 中的 MSBuild 的 .NET 方法支持"\."将最终结果中的 s 替换为“.”。

(这至少可以解决我原来的问题)

于 2013-04-20T12:43:12.813 回答