开发者

Moving a file in MSBuild using relative path

开发者 https://www.devze.com 2023-01-14 09:17 出处:网络
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.

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

精彩评论

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

关注公众号