Building Default ASP.NET Projects in TeamBuild
There are few things to note while evaluating ASP.NET projects under TeamBuild. We had several instances of our customers selecting ‘Any CPU’ configuration while building default ASP.NET web projects. By ‘default’ I mean, an ASP.NET project that is created choosing default options in VS. Note that, the default configuration enabled for a solution that contains only Web Projects is “.NET” . In case the solution contains non-web projects, for example a class library project, the default configuration will be “Mixed Platforms” . You will need to select configurations accordingly.
Next, you might see some build errors while building default ASP.NET projects in Teambuild. If you have seen errors something like below, you have hit a known issue that we won’t be able to fix in this version J
ASPNETCOMPILER(0,0): error 1003: The directory 'd:\builddir\MyTeamProject\SampleWS\WebSites\SampleWS\' doesn't exist.
This is because, when a web site is created using default options, VS saves solution files and website files in two different locations and unfortunately, it is not very explicit to the user. When I created a website project called SampleWS using default options, VS saved solution files at “D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\Projects\SampleWS” and website folder at “D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\Websites\SampleWS”. The solution file contains a relative pointer (PhysicalPath property in the solution file) to the web site folder to locate it for compilation. But, when this solution gets checked in, everything goes as one blob with .sln file at the root folder and all websites as immediate sub folders. Refer here for more details. This results in broken PhysicalPaths in the solution file. Since the build machine syncs as persisted on the source control, the solution won’t be able to locate these websites and results in compilation errors.
The best way to avoid this problem in the first place is to create a blank a solution, and create web sites at the same location where the solution is created.
Well, I didn’t know this and hit this issue now. Is there any way to fix it?
Yes. You will have to hand edit the solution file to modify the properties Debug.AspNetCompiler.PhysicalPathandRelease.AspNetCompiler.PhysicalPathto point to the website folder as in source control and check it in back. In my sample, these were pointing to "..\..\WebSites\SampleWS\". I changed them to “SampleWS\" to make them inline with what is there on source control. It will be similar for you also.
Now, it is obvious that, on the local machine, you won’t be able to load this solution in VS as well as do msbuild command line compilation. You can do the following simple tweaks to the local workspace and get it to work. Here is what I did:
- In my example, I’ve two mappings like below (you will have similar mappings)
a. $/MyTeamProject/SampleWS: D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\Projects\SampleWS
b. $/MyTeamProject/SampleWS/SampleWS: D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\WebSites\SampleWS
- I checked in all changes from my website folder D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\WebSites\SampleWS
- I ran ‘tf workspace’ command from D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\Projects\SampleWS and removed the mapping “D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\WebSites\SampleWS” so that everything under $/MyTeamProject/SampleWS include the SampleWS web project folder will be synced to D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\Projects\SampleWS
- Then, I ran ‘tf get /r *’ to sync the web site folder to the new location
- Now I have two copies of website folder, one under solution folder and one originally created at D:\Documents and Settings\NAGARAJP\My Documents\Visual Studio 2005\WebSites\SampleWS, so I removed the original one to avoid confusion
- I deleted .suo file (note that this is a hidden file) from the solution folder so that it does not use any cached information and opened SampleWS.sln in VS.
- Boom, everything is up and working!!