Visual Studio: Set the Build Action for an Entire Folder

I'm sure you already encountered this problem, right? In my specific case I have a folder called "frontend" with a bunch of JavaScript, CSS and view template (EJS) files; my rich JavaScript client basically. I just need them when starting my app in my local Visual Studio development server but they should not be copied when publishing. Why? Because they walk through a Minifier and Linter before. The solution: set the Build Action to None. That won't work on an entire folders however, sigh...

Since Visual Studio doesn't provide us such option, the solution is basically to open your .csproj file with your preferred editor and to replace all occurrences of
<Content Include="frontend\snip\snip\somefile.js" />
<None Include="frontend\snip\snip\somefile.js" />
I'll leave the regex for you ;).

I just did it with Sublime Text and that's just amazing. Basically you do a Ctrl+F and enter your regex. Then you click the "Find All" button and it will place a cursor automatically on all of the found occurrences such that you can just edit those lines. Awesome!!



Your ad here?