开发者

MSBuild: transform paths to namespaces

I have list of items like this:

<ItemGroup>
    <ToCompile Include="clojure\core.clj;clojure\set.clj;clojure\zip.clj;clojure\test\junit.clj;"/>
</ItemGroup>

And I want to transform that to a list of items like this:

clojure.core clojure.set clojure.zip clojure开发者_如何学Python.test.junit

Is there a way to do this with MSBuild transforms? I tried but I can only get at the file name; the extension and the root path, and I can change the separator. But not the path separators.

If not, any other solution that avoids using custom tasks is appreciated.


We can do it easily with fewer cheese:

<Message Text="$([System.String]::Copy('%(ToCompile.Identity)').Replace('.clj','').Replace('\','.'))"/>


This is a bit cheesy, but it works in MSBuild 4.0+.

<Target Name="Namespaces">
  <PropertyGroup>
    <Cheesy>@(ToCompile -> '%(relativedir)%(filename)', ' ')</Cheesy>
  </PropertyGroup>
  <Message Text="$(Cheesy.Replace(`\`, `.`))" />
</Target>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜