在基于MSBuild /惯例中的文件名中删除尾随斜杠
-
26-09-2020 - |
题
我正在尝试根据目录中的以下惯例搜索一组装配集:
{SubDirName}\{SubDirName}.dll
.
我通过创建MSBuild ItemGroup [通过批处理.RecursiveIr部分上的另一个项目组]开始。
<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版本并不挑剔。
解决方案 2
您可以在.NET 4.0中使用MSBuild的.NET方法支持。在最终结果中替换“。”。
(这至少可以解决我的原始问题)
其他提示
你试过
<AssembliesByConvention Include="@(Dirs -> '%(Identity)%(Identity).dll')" Condition="HasTrailingSlash(%(Identity))" />
<AssembliesByConvention Include="@(Dirs -> '%(Identity)\%(Identity).dll')" Condition="!HasTrailingSlash(%(Identity))" />
. 不隶属于 StackOverflow