Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops. Juri is also a recognized Google Developer Expert in Web Technologies

Visual Studio: Set the Build Action for an Entire Folder

1 min read

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!!
Questions? Thoughts? Hit me up on Twitter
comments powered by Disqus