Visual Studio: Converting a Webproject Into a Class Library

Introduction#

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 create the separate libraries for my projects as web-projects.

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

Step 1#

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

Step 1

Step 2#

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

Step 2

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 3

Step 4#

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

Step 4

Step 5#

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

Step 5

And thats all!