This is really shocking (and very disappointing) to me.
I had the task of upgrading the code base at Walsh Construction from .net 1.1 to 2.0 and putting it all in a source control database.
I had been getting a lot of totally random build problems, and I started wondering: Where does it store my references?
ASP.Net Web Sites projects don’t have a vbproj or csproj file anymore, so where is it storing the fact that I want this website to have a references to a given DLL or a given project in my solution?
I found that the answer is that the project references are stored in the solution file!
If you open up the solution file you will find lots of stuff like this:
ProjectSection(WebsiteProperties) = preProject ProjectReferences = "{E050AEA3-6DCA-4DE8-936F-5A8B14A912B9}|MyReferencedAssembly.dll;
This is kinda stupid.
Non-website projects keep a list of their references in their project file.
Websites keep SOME reference info in their web.config, although I think that is only for DLLs that are in the GAC.
Anyway on to the list of things that truly suck about how this works:
1) When you add a reference from a web project to a DLL, the DLL is copied to the Bin directory right then, as opposed to when you do the build. I bet it does it at build-time as well, but what really sucks is that you can have a situation where WebSiteA references ComponentA which references DataAccessLayerA. WebSiteA will have DataAccessLayerA.dll in it’s bin directory, then if you go to add a references from WebSiteA to DataAccessLayerA, it will say “Oh you already have a reference” when you really don’t, and if you try to build it won’t work until you go delete that dll from your bin and add the reference.
2) I have been unable to open some projects without opening the entire solution that I joined them too at one point. Basically as I was converting all our projects over to 2003 I wanted to also change them from DLL references to project references. So I created a solution with ever project and website we have in .net. To illustrate my problem, I added a project to the solution called IAmABogusProject with 1 class and 1 static method. No one uses this class, no projects have a reference to this project, and this project has no references to any other projects. Yet, if I go click on the vbproj file for this project, it loads up my solution file with every single project. I tried creating another solution and adding it to that one to see if it would open the new solution when I tried to reopen the project but no luck, it opened original solution with every application again!! WTF!!
3) This is the worst of the list. If you have a project in a solution that is referenced by some other projects and you remove that project from the solution, guess what happens? In 2003 it would remove the project and all the referencing projects would show a missing reference icon. In 2005 it checks out all the referencing projects and removes the reference!!! Are you kidding me??? For the cherry on top, you have to then manually add all the references back after you add the project back into the solution, and of course you get all kinds of weird bugs, none telling you that you are missing an assembly reference. Totally stupid. This is a bug, see Update3 at the bottom.
I am really pissed about this. Why do MS product upgrades frequently come with a “What were they thinking?” tag?
Maybe the roll of the solution has changed or something, but this is going to really piss me off working like this day to day.
I have already had something happen where all my website projects that I had already added to source control lost their binding. Great….
Update1: I am continuing to have problems with my web project “losing” references that I have to keep setting. What a pain this is becoming!
Update2: Scott Gu from Microsoft (http://weblogs.asp.net/scottgu) suggested that I give the Web Application projects a try. I had tried them once before when in beta and remembered there was something that was a show stopper at the time. I don’t remember exactly what, maybe the designer didn’t work? Anyway, that could solve a few of my issues, but this whole thing of not being able to open a project without a solution getting opened, and the thing where VS removes references from projects (even if they are under source control) if you remove the project from a solution is crazy.
Update3: Well thank God, someone from Microsoft let me know that this thing with removing a project causing references to disappear is actually a bug: http://www.chrismay.org/2006/04/19/VS2005RemoveProjectLoseReference.aspx
VS 2005 now supports two project model options:
VS 2005 Web Site Projects
VS 2005 Web Application Projects
For upgrading V1.1 applications to VS 2005, you will probably find VS 2005 Web Application Projects much easier. They use a project file and have the same compile semantics as VS 2003.
You can learn more about it and download it here: http://weblogs.asp.net/scottgu/archive/2006/04/05/442032.aspx
Hope this helps,
Scott (scottgu@microsoft.com)
Thanks for the suggestion.
I think I tried the Web Application projects a while back, and I remembered that something about it was a deal breaker… maybe something like the designer didn’t work? I can’t remember for sure, but maybe this has been fixed in the release candidate.
I will have to give it a try though, see if it works a little better.
Still though, a lot of the issues I am having don’t seem to be related to the web project specifically. The notion that removing a project from a solution will remove the references from other projects (non web projects), and it will even check out the project file in order to do this, that is crazy. I still have some projects on my computer that are somehow "bound" to a master solution file. I can’t open these projects by themselves, even if they don’t reference anything. They somehow trigger VS to open up my giant solution of 40 projects. And of course, I can’t remove any projects from this solution, because it will remove refereces from all the projects in the solution.