In the new Visual Studio 2015 and the Web Essentials plugin, they've removed the function to compile certain files like Less files. Instead they suggest to use Gulp tasks.
While I applaud this decision and understand how to configure Gulp to compile the Less files, but because this is not an ASP.NET 5 application, the new files are not automatically added to the project and as such do not get copied when using the Publish function of VS2015.
As I see it the only way to get these file to copy is to manually add them to the project. This seems a but counter intuitive, if you create a task to compile **/*.less you have to look in your entire project to find the generated css files and add them all manually.
Am I just doing something wrong or is this just the way it works now?
Don't add the files manually, it is pretty easy to add them with a target in your project file. This is how we do it and we also use the gulp-rev package which modifies our filename dynamically (so they will not be cached by a browser). Here is how our BeforeBuild target from our .csproj file looks like:
<Target Name="BeforeBuild">
<Exec Command="BeforeBuild.bat" WorkingDirectory="$(ProjectDir)" />
<ItemGroup>
<Content Include="Scripts\Output\**\*.js" />
<Content Include="Content\**\output\**\*.css" />
</ItemGroup>
</Target>
And in our case when we publish all the generated js files from Scripts\Output\all_folders\ will get published too even though they are not in the csproj (and the same for the generated css files)
For those who preferred the "Web Essentials" method of compiling Less, Sass and CoffeeScript files, Mads Kristensen has published a new VS 2015 extension named Web Compiler. Try it. Also see his Bundler & Minifier extension for additional functionality removed from Web Essentials.
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