
Having a wonderful Synology drive on the farm, I was sad for quite a long time about the lack of hosting .NET applications. And so, armed with mat. part of the article in
habrahabr.ru/post/121159, I was puzzled by the creation of a home server for ASP.NET MVC projects. The mono package is quite old there, and the classic sequence of commands for building it did not lead to success. Information was collected from various sources, including habr, bit by bit, giving an understanding of what needs to be done and in what sequence. I just want to describe the passage of this quest in this article. I hope someone will come in handy.
Total, given:
1. Iron: Synology NAS 110j with Marvell mv5281 processor on board.
2. OS DSM 4.0 (based on an uncommon Linux distribution)
Prerequisite: Install the latest version of mono + xsp.
Training
Synology did not bother to provide opportunities for installing additional packages in the traditional way for * nix systems, i.e. through the console. Therefore, first you need to get acquainted with the topic at
www.synology-forum.ru/index.php?showtopic=38 , and perform the necessary movements. The end result will be installing and running the ipkg console package manager. I cannot give a brief summary in this article, since Synology drives are available on different processors and the recipe for each architecture will be different.
Building and installing MONO
After the ipkg package manager has earned, we get and unpack the latest mono sources (at that time it was 2.10.9). In the course of the story, if necessary, reinstall the necessary packages using ipkg on my own, because due to the specifics of the hardware I can’t completely virtualize the environment for a pure experiment, and many packages I had in the course of the tambourine and I forgot what needs to be installed additionally.
wget http://download.mono-project.com/sources/mono/mono-2.10.9.tar.bz2 tar -xvf mono-2.10.9.tar.bz2
')
Mono build process:
cd mono-2.10.9 ./configure --prefix=/usr --sysconfdir=/etc/mono
It should be normal, if something is not so look in config.log. Some packages will most likely need to be delivered.
I remind you that just the make command did not cope with my compilation. You need to add the flags '-Wl, -lpthread, -lrt'. But this was not enough. When linking to the pthread library, some functions were missing in the latter. It is possible that this is due to the architecture and on Intel `s everything will be OK. However, on my ARM just before compiling, I additionally had to perform the following spells:
mkdir /opt/arm-none-linux-gnueabi/lib_disabled mv /opt/arm-none-linux-gnueabi/lib/libpthread* /opt/arm-none-linux-gnueabi/lib_disabled cp /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/ cd /opt/arm-none-linux-gnueabi/lib/ ln -s libpthread.so.0 libpthread.so ln -s libpthread.so.0 libpthread-2.5.so
In /opt/etc/ipkg/cross-feed.conf change to
src / gz cross
ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable ipkg remove perl ipkg install perl
The magic of libpthread was clarified by googling, and as is clear from the commands, we replace the library. I do not know why this happened, but it is a fact. But reinstalling perl is generally something. I initially had packages from an unstable branch (unstable). It is possible that in your case everything will be fine.
So, we stock up on popcorn and compile ... the process is not fast and sometimes even interesting.
make CFLAGS+='-Wl,-lpthread,-lrt'
So, if the mono compilation is successful, install it with the command
make install
and check
mono --version
should produce something like
Mono JIT compiler version 2.10.9 (tarball Sun Apr 15 18:40:39 MSK 2012) Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: normal Notifications: epoll Architecture: armel,soft-float Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: Included Boehm (with typed GC and Parallel Mark)
Build and validate XSP
The environment is installed, now you need to install an ASP.NET application XSP server for mono. I understand that the "ASP.NET server" for XSP - it sounds too much, but do not forget where it will be used.
Everything is trite here ...
wget http://download.mono-project.com/sources/xsp/xsp-2.10.tar.bz2 tar -xvf xsp-2.10.tar.bz2 cd xsp-2.10 ./configure make install
after installation we will check:
cd /src/Mono.WebServer.XSP mono xsp4.exe --applications /:./../../test
must issue
xsp4 Listening on address: 0.0.0.0 Root directory: /xsp-2.10/src/Mono.WebServer.XSP Listening on port: 8080 (non-secure) Hit Return to stop the server.
We start the browser, type the NAS address and port 8080. Our server should issue a test page

Preparing the experimental ASP.NET MVC application
1. Create an ASP.NET MVC 3 Web Application Project

2. I chose the Internet application

3. The source code will make a small correction.

4. I set up publishing through the file system (choose to taste what is configured on your NAS, for example FTP)

5. We launch XSP on a folder in which we will deploy our application
mono xsp4.exe --applications /:./volume1/web/TestMvcOnSynology
6. Next, you need to include in the MVC assembly project so that they are deployed along with our application, since they are missing from MONO. To do this, in the properties of the connected assemblies, set the “Copy Local” property to True. The list of assemblies: System.Web.Helpers, System.Web.Mvc, System.Web.WebPages, add the assemblies System.Web.Razor, System.Web.WebPages.Razor, System.Web.WebPages.Deployment and also set the property “copy locally "to true.
7. Also, in order to familiarize, I “cut out” authorization from the application and all references to EntityFramework (this is the topic of a separate article).
1. Remove the link to EntityFramework, System.Data.Entity
2. Exclude from the project AccountController.cs;
3. Exclude AccountModels.cs from the Models;
4. we completely exclude the Account folder from the submissions
5. In _Layout.cshtml delete the section with id = logindisplay
6. Exclude from the project file _LogOnPartial.cshtml
Everything. You can deploy the application and enjoy the result:

At last
1. Considering that Microsoft recently opened the source code of the entire ASP.NET stack, it is likely that it will be more correct to connect the MVC package from the codeplex to the application and switch all links to it and deploy the application in this form.
2. Instead of cutting authorization, you need to implement your own mechanism without using EntityFramework, but, as I indicated, this is a separate topic.