Tag Archives: nant

deploying asp.net mvc

the goal of every application is to get deployed on a server or another computer. sometime its really easy and logic to do so and sometimes its easy and logic, but you really mess up…

first of all asp.net mvc needs some dlls in the GAC… but normally installing stuff on servers is not really the good way… goal should be, to install as less as possible, or at least good controlable… and in my case, its a windows server… so controlable is not really a word to describe it… but on the other hand, im just a developer and not a server admin… so i might be wrong…

to avoid installing stuff in the GAC for asp.net mvc, just simply add the dlls to the bin folder and voila… every thing is good 🙂 you need to add following dlls:

  • Microsoft.Web.Infrastructure
  • System.Web.Helpers
  • System.Web.Mvc
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Deployment
  • System.Web.WebPages.Razor

or just read http://drew-prog.blogspot.com/2011/01/how-to-deploy-aspnet-mvc-3-app-to-web.html

and it works… or lets say here ends the easy and logic part 🙂

in my case, it didnt work… why? we use nant to deploy out application and we do not publish the .config files. makes sence, because the web.config contains server information and is unique for a server… but the views folder has an own, mvc-based web.config and a packages.config, which might be used as well… so i or lets say the deploy script messed up 😛

nant timestamp

i needed a datretime to backup my deployed applications. the goal was to store the backup in a datetime named folder, so its easy to find the last backup.

tryed it with datetime::now() and other datetime functions, but wasnt really satisfied and acutally the nant code was kinda unreadable… so googled it… and tstamp is the solution

 <tstamp property=”backup.datetime” pattern=”yyyyMMdd_HHmmss” />

creates the wished for property… well done 🙂

nant remote start and stop services

i though, stopping and starting services on a remote maschine is almost impossible… but i was mistaken…

<target name=”startService”>
    <exec program=”sc.exe”>
         <arg line=”\\${server} start ${service.name}”/>
    </exec>
</target>

thats it… just run the sc.exe… but i am not really unhappy of the simpleness of this solution 😛

compile projects with nant

compiling c# projects in visual studio is kinda easy… in nant it sould be to… after trying to build the whole solution, and reading the manual properly, <solution> can only be used with visual studio version 2002 and 2003… crap…

okt tryed it with <exec> and msbuild.exe… works 🙂 but then i figured outm that nant CAN compile projects… so back to the <solution>

<solution configuration=”debug”>
    <projects>
        <include name=”project.csproj” />
    </projects>
</solution> 

so this call opens the project.csprojfile and executes it… but normaly it throws an exception… this link provides the answer… just change the $(MSBuildToolsPath) to $(MSBuildBinPath)

so compiling projects with nant is easy 🙂

installing nant

first of all, i have no clue about visual studio and deployment… mainly i just compile it, then copy paste it. and yeah, that is really a bad way to do that… so i tought, why not simple use my old beloved ant? ok i know maven is the thing now to use, but i just need simple scripts to copy/deploy stuff… so nant will do, or have to…

  1. download: http://nant.sourceforge.net/ 
  2. install: Installation Manual

this is it 🙂 ok currently its only usable as a command line, but its working 🙂 if i am able to write scripts is something completly different…

on the other hand visual studio should be able to execute these kind of scripts… ok finding a tool was hard, but there is one: NAntAddIn

installing it on a Visual Studio 2010 is not really trivial, but with link its easy…

  1. copy the addin to the user addin folder: \My Document\Visual Studio 2010\Addins
  2. important: set the Visual Studio version to 10.0 in the NAntAddin.AddIn file
  3. now it can be added in the Visual Studio AddIn manager
  4. configure it to the nant.exe and its runable

i had to restart the visual studio, because the NAntAddIn did not print stuff in the output window. worked afterwards

so NAnt is now up and running… we will see, how it can be used by my mighty hands… 😛