With the release of VS2010 SP1 Beta1, Web Matrix, and Razor QFE, we can build web projects containing SQL Compact Edition 4.0 sdf file and ASP.NET Web Pages with Razor syntax. However, this might be a problem when you are ready to deploy your project on a server that doesn’t have the assemblies required to run SQL CE 4.0 and Razor pages.
To solve this issue, we can make the project “Bin Deployable”, similar to the way we do bin deploy an MVC project. If the hosting machine has ASP.NET 3.5 or later installed, then we just need to include the required assemblies in the bin folder when deploying the project.
We can include required assemblies in a Web site or Web Application project with a few simple steps. You right click the project node in Solution Explorer and select “Add Deployable Dependencies…” context menu item.
If there isn’t SQL CE 4.0 nor Razor installed on the machine, the following dialog will pop up:
If there’s at least one of them installed, then the following dialog will pop up:
Visual Studio detects what components are present on the machine and the corresponding options will be enabled; you then can choose what to include in the bin folder. In the above picture, only the option for SQL Server Compact is enabled on a machine with SQL Server Compact 4.0 installed. If it’s a website, the required assemblies will be copied to “Bin” folder; if it’s a WAP, they will be copied to “_bin_deployableAssemblies” folder. Note that your selection will not be persisted after the dialog is closed.
Now you can deploy your web projects the same way you deploy any other web project. For a Web Application Project (WAP), you can use Deployment feature made available with VS2010. For both web site or WAP, you can use “Copy Web”, or “Web Deployment Project” to push all the files needed to deploy to a specific directory, test it, and then copy the the host.
Hope it helps!