Mono XBuild publish MVC site
Asked Answered
S

2

6

I've got Monoserve and Nginx running perfectly in Ubuntu however I still have to publish the website locally on a Windows box using MSBuild and then copy the files over.

Preferably I'd like to have a Linux CI server that does this instead using XBuild however I can only get it to build the project into .dlls, how do I publish and deploy it with js, css, views, etc?

Singularity answered 12/1, 2013 at 18:23 Comment(3)
Have you hand-edited the msbuild file?Ezekielezell
And have you marked your content files with the build action Content?Ezekielezell
I guess following link might help to resolve this issue - #32782483Estheresthesia
V
8

Typically the "build dlls" part is the hardest part. If you've got that solved, you're 80% there. The other half is publishing content. In it's most elementary aspect, you're copying a portion of the files from the source dir to the website folder. MSDeploy is Microsoft's answer to it, and it's waaaaaay too complex. I built an NAnt task that does this, though that also doesn't apply to your specific scenario. However, the general methodology can:

  1. Crawl the sln file looking for web projects. What makes a web project? Technically guids in the csproj file or project type ids in the sln file. I cheated and defined it as "the target folder includes a web.config file". If you've only got one website project in your solution, you can skip this step, and just hard-code the .csproj file.

  2. Crawl the csproj file looking for <Content Include="some\file.ext" /> nodes. XPath could do this, Linq to XML could do it too. This gives you all the .aspx, .cshtml, .js, .css, .png, .config, etc, etc, while carefully leaving behind all the .cs files. You'll need to prefix the path to the .csproj file to get the true origin file location, and you want to ensure you preserve the folder structure in the destination location. But this is trivial in comparison to harvesting the file list.

  3. Now that you've got the file list, loop through it copying from the source folder to the destination folder. (You probably want to either empty the destination folder first or afterwards prune extra files from previous deployments. I find the former easier.) The only thing the csproj file crawl didn't give you was the bin folder content, but that's cake: copy all the contents of the bin folder. :D (There's a healthy debate about whether to copy .pdb files, but I say yes.)

Form a script to do the above 3 steps, then call it either from an XBuild task or call both XBuild and this script from the CI process. Poof. You've got a deploy target. Happy coding!

Viki answered 20/1, 2013 at 2:30 Comment(1)
Thanks I made a shell script to do this. Works beautifully, I always assumed it was too complicated to replicate the deploy process.Singularity
C
0

Preferably I'd like to have a Linux CI server that does this instead using XBuild The good news is that you CAN do this with a workaround I found in this article. Here is an excerpt and the workaround link from the above article:

The build server does not have Microsoft MVC (any version) installed. However, this is very easy to work around-Microsoft MVC is available on NuGet at http://nuget.org/packages/Microsoft.AspNet.Mvc if you need to install an older version, click on the older version at the bottom of the page and you’ll reach instructions on how to install that version of the framework.

Hope this make it easy for you!

Christianna answered 27/1, 2013 at 1:14 Comment(1)
Thanks for the link but I don't think this will handle fully deploying a Website, only compiling dllsSingularity

© 2022 - 2024 — McMap. All rights reserved.