Saturday, September 13, 2008

VS2005 web site publishing problems

When trying to do a Build > Publish Web Site from VS2005 of a file-based (!) Web Site project I'd get the following error: "You must choose a publish location that is different from the source Web application".

My web site project is called HRWeb. Its file-based which means that the source folder sits somewhere other then IIS' wwwroot/HRWeb. In fact, when opening the publish dialog box, VS2005 pre-fills a default location to a subfolder of where the solution file sits (something like /aspprecompile).

I wanted to publish the project to IIS on my machine, so tried http://localhost/HRWeb and got the above message. I did a similar thing elsewhere and managed to publish to a remote server with the same /HRWeb path portion, so its only on the local machine.

My work-around was to have the publishing directory something (anything) else, as long as its not under the /HRWeb (putting HRWeb2 for example does not work). So, I've put the publishing option as http://localhost/HR/ and that did the trick. Obviously I then had to manually copy the files from that directory into the one I wanted.

After doing this there was another problem. Accessing one of the sub-pages would show an error such as: "BC30456: 'Theme' is not a member of ...". Please note that the application works just fine while I develop things using VS2005 in-built web server.

To get around this I actually went back to the publishing to the local folder first on the file system and then manually moving the files over to IIS. I tried with the options on the publishing dialog ("Allow this precompiled site to be updateble" and "Use fixed naming and single page assemblies") but they made no difference - the error would persist.

All these deployment troubles came-in when my client wanted to do the publishing to the remote server from VS2005 (I was hoping he'll end-up doing an installation via the installer OR at least via the NAnt script that I had). Which now prompts me to go and figure out how can I get my NAnt to deploy things remotely instead of assuming a localhost deployment.

1 comment:

sjusic said...

As always, one must resist the urge to think there might be something wrong with Visual Studio (or another tool of your choice in a given task).

Turns out that "error BC30456" produced after publishing a website from VS2005 is due to code-behind partial class definitions.

In my case, only one file kept producing the error. Most of the other pages seemed to work fine.

Looking at this file, called edit.aspx" I noticed that the code-behind file vas called (as expected) "edit.aspx.vb" but the partial class definition inside it was not "views_edit" as I believe it should be (my file is in a folder /views), but was "views_new".

I have another file in the same folder called new.aspx with a new.aspx.vb which defines the views_new partial class.

I renamed the original edit.aspx.vb partial class views_new to views_edit and then changed the edit.aspx page directive to Inherits="views_edit" (it was Inherits="views_new"). After republishing from VS2005 it makes the error disappear.

Why did I get to this in the first place? I believe it was due to a copy-paste of files using VS2005. I did a few of these initially just copying around various aspx files and it obviously kept the partial class name in place. So I suppose that's one place to watch out for.

I still can't explain to myself what was the error in the end due to these duplicated partial class names.