开发者

Moving a file in MSBuild using relative path

I'm trying to move all files of a certain type to a directory relative to the file itself and I'm wondering if it's possible using MSBuild.

Basically, I'm using the Microsoft AJAX Minifier to minify all Javascript and CSS files on my site. This outputs .min.js and .min.css files into the same directory as the Javascript and CSS files. Because my site has numerous skins, there are JS and CSS files located in numerous directories. I want to be able to add a task that runs after the AJAX Minifier that moves all .min.js and .min.css files to /min/ relative to the file locati开发者_StackOverflow社区on. So /Skin1/somescript.min.js would move to /Skin1/min/somescript.min.js and /Skin2/somescript.min.js would move to /Skin2/somescript.min.js.

The only way I know to accomplish a copy/move requires knowledge of the absolute directory (or should I say directory relative to the Project file) but I can't seem to find a way to move based on a directory relative to the file I'm moving.

Can this be done?


<CreateItem Include="wwwroot\**\*.min.js;wwwroot\**\*.min.css">
    <Output TaskParameter="Include" ItemName="FilesToMove" />
</CreateItem>

<Move SourceFiles="@(FilesToMove)" DestinationFiles="@(FilesToMove->'wwwroot\%(RecursiveDir)\min\%(Filename)%(Extension)')"/>

Assuming you're using the Move task from MSBuild community tasks. If not, you could just copy and then delete the originals instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜