October 25, 2013

Converting a VS Class Library Project to Web Application Project

Without recreating the project!

Today we discovered that a recently created VS2010 project was not setup as Web Application. When we tried to run the debugger VS complained that libraries cannot be executed as application. I found out that under the project's properties the tab "Web" was missing. I opened another project to compare the settings within VS, but could not figure out obvious differences.

First, I asked Google, which told me to have a look at MSDN, where the Redmonders suggest in a conversion walk-through to create a new project and copy the content from the old project into the new one. Yeah, but we all know that this could mess up our references, even if we use NuGet. To be honest, I started to follow that hint, and find myself in such a painful situation. After a few minutes, I abandoned this idea. That way is only for masochistic lifeforms.

I diff'ed (using SVN Tortoise Diff) both project files and then changed the compromised project file manually. I played around a bit and discovered, that I need to add the ProjectTypeGuids-Tag only to get things work.

So instead of cumbersome project recreation it needs less than a minute to convert the pure library project into a web application project.

1 comment: