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 location. 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With