Hi,
After it took me quite a while to install Sitefinity as a web application project in Visual Studio (which I generally prefer over the website projects), I thought I'd share my experience on how I accomplished that.
I will not go into detail about why I chose the web application, this is perfectly covered here :
http://reddnet.net/code/asp-net-web-site-vs-web-application-project-part-2/
The most important part for me is the more detailed compiler output and the possibility to create XML documentations.
Installing Sitefinity as a web application
Note: This guide has been created for and
tested with a blank project of Sitefinity 3.5SP1 (Community edition so far).
-
Download the web profile builder from http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=WebProfileBuilder&ReleaseId=980
– This is because Sitefinity uses user profiles, which are not available at
compile time in a web application. For more information look here: http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx
-
Install the web profile Builder on your machine.
-
Create a new web application in Visual Studio. Because
Sitefinity uses C# in its files, you can only create a C# project at this
point. Mixing languages is not supported in web applications.
-
Close Visual Studio and navigate to the directory with the
new application.
-
Delete the default.aspx file and all associated *.cs files.
-
Edit the *.csproj file and add the following line under the
other <Import…> statements:
<Import Project="$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets"
/>
This enables the web profile builder in the current project.
-
Extract all files in the Sitefinity blank project into the
web application directory.
-
Re-open Visual Studio, load the project and click on “Load
project normally”, as described in the web profile builder documentation. This
dialog will appear only once.
-
Click on the “Show All Files” button in the solution
explorer.
-
Select all files except for the “bin” and “obj” folders,
right-click and select “Include in Project”.
-
Right-click on the “References” folder, and add all files
from the “bin” directory to your solution.
-
Right-click on the root item in the solution explorer and
select “Convert to web application”.
-
Build the project. There will be a couple of errors, this is
expected. The reason is that Sitefinity builds their product as a website,
whereas we want to use a web application.
-
In the compile errors, go through all occurrences that are
like “Profile not found” or “ProfileCommon not found”. Replace these classes
with “WebProfile”. This should only affect the file “ManageRecepients.cs” (yes,
there is a typo in the file name).
-
There are also 2 errors that a method in the “_Default”
class cannot be re-defined in “ManageRecepients.cs” and “ChangeRecepients.cs”.
Just rename these 2 classes into “Admin_ManageRecepients” and
“Admin_CmsAdmin_ChangeRecepients” respectively.
-
A new file called “WebProfile.cs” should have appeared in
the solution. Right-click and import the file.
-
Now the compile process should work without errors, and only
leave lots of warnings about missing XML comments, a couple of unused variables
and deprecated functions, and a few occasions where the “new” keyword should be
used when overriding inherited functions. This only shows the more rigid
compiler that is used in web applications. The application should run fine
though.
Note: When the
project is run for the first time, an installer starts that leads through the
creation of a database and an admin user. Occasionally it happened to me that
the database creation (Oracle in my case) failed the first time with a server
error. I could not find a reason for that, but so far it always worked by going
back in the browser and just trying again. I never had 2 server errors in a
row, and once installed the software worked as expected.
Maybe this helps some of you.
Cheers, Chris
Update for Sitefinity version 3.6:
This version already comes with proper namespaces for the classes in
"ManageRecepients.cs" and "ChangeRecepients.cs", which takes care of
the error described previously (
a method in the “_Default”
class cannot be re-defined). There is no need to rename these classes anymore.