Visual Studio: Converting a webproject into a class library

Tuesday, June 26, 2018


We've all been there. You checkout a solution you last looked at a few years ago. You're planning on migrating the site to a new server and decided that it was a perfect opportunity to do a quick upgrade to Umbraco and do a bit of refactoring whist you are there. For some reason, back then I used to created the separate libraries for my projects as web-projects.  

So here is how what do we need to do to change them to a bog standard class library.

Step 1

Right-click the project you want to change, select "Unload project" 

Step 2

One its unloaded, right-click again and click "Edit {project}.csproj"

Step 3

Delete the ProjectTypeGuids XML node (line 11)

Slightly modify the GUID in ProjectGuids (Just increase one of the digits by once). This trick VS into thinking its a new project and will prevent it from caching the old configuration.

Step 4

Once again, right click the project and this time select Reload Project.

Step 5

Delete the web.config, global.asax file and the App_Start folder, you won't be needing them anymore.

And that all!

Lead Photo by Luca Bravo on Unsplash