25 May 2009

Here is the follow up of my post on building Subtext project with Visual Studio 2008 under Windows 7, with SQL Server 2008 Express installed.

In this post, I’ll explain how to deploy Subtext from Visual Studio on the local IIS server.

So, using the “Publish…” option in Visual Studio, let’s deploy the Subtext.Web project on the local IIS.

VS9SubtextPublish

VS9SubtextPublishToLocalIIS

The project will then build and be published, but the process will fail. There is a file missing in the SVN repository:

Publishing folder Skins/Colors...
Unable to add 'Skins/Colors/skins.config' to the Web site.  Unable to add file 'Skins/Colors/skins.config'.  The system cannot find the file specified.

In the Subtext.Web project, you can see the missing file:

VS9SubtextPublishMissingFile

Solution to this is very easy:

  1. Delete the reference to the file in the solution (simply select the file, as in the picture above, and press delete).
  2. In the same panel, click on “Show All Files” button.
  3. Select the “skin.config” file that is now displayed, right click on it and select “Include In Project”.

What’s happening here is that there is a sync issue between the Visual Studio project file and the files on the file system. The project file references a “skins.config” file that doesn’t exist on the file system.

It is time to publish the project, again. Fails, again :)

Publishing folder Skins/Lightz/Scripts...
Unable to add 'Skins/Lightz/Scripts/cityNight.js' to the Web site.  Unable to add file 'Skins/Lightz/Scripts/cityNight.js'.  The system cannot find the file specified.

Unable to add 'Skins/Lightz/Scripts/tableEffects.js' to the Web site.  Unable to add file 'Skins/Lightz/Scripts/tableEffects.js'.  The system cannot find the file specified.

Same kind of issue as before, but this time the files don’t exist on the file system.

VS9SubtextPublishMissingScripts

This time, simply delete the two files from the project.

Publish again, this time it works! (Note that it worked the two previous times, but there was an error from Visual Studio as the files were not found. As the missing files were only scripts or configuration for skins, this did not prevent Visual Studio from deploying the rest of the project).

Browsing the local Subtext

Publishing was the easy part. Now, if you browse to http://localhost/Subtext, you will get an error:

Server Error in '/Subtext' Application.
Object reference not set to an instance of an object.

I took me a while to spot what was wrong this time. The project file explicitly says to not copy the “Web.config” file to the output folder. So, when you publish from Visual Studio, there is no “Web.config” file copied along…

In the “Web.config” properties window, change the “Build Action” from “None” to “Content”.

VS9SubtextPublishWebConfigContent

There we go. Let’s publish again and browse to see if it works…

Nope, some SQL access error this time:

Cannot open database "Subtext2.1" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.

This is quite straightforward. The IIS running user doesn’t have access to the database file. But there is a catch. The “Web.config” file that is in the solution references a “.mdf” file. For some reason, I was unable to make it run with an instance database. I was also unable to find any answer about that yet. You’ll have to head to SQL Management Studio and create a database for Subtext to use.

Now, that’s not the only thing. Subtext will not work well with the new IIS 7 integrated pipeline. You’ll have to run Subtext in “classic” mode. Do this by simply changing the AppPool that runs Subtext.

VS9SubtextConfiguration

One this is done, you should be able to access the install page of Subtext (just hit the root folder in IE and the wizard will take you trough.

That’s it!

PS: there is a question on StackOverflow about IIS security model, DefaultAppPool user, etc. I just posed some questions, but no one seems to be able to answer.



blog comments powered by Disqus