Mono XBuild publishes MVC website

I have Monoserve and Nginx working fine on Ubuntu, but I still have to publish the website on the local computer on Windows using MSBuild and then copy the files.

It is advisable that I have a CI Linux server that does this instead of using XBuild, but I can only get it to create a project in .dlls, how to publish and deploy it using js, css, views, etc.?

+6
source share
3 answers

As a rule, the build dlls part is the most difficult part. If you succeed, you are 80% there. The other half is content publishing. In it the most elementary aspect, you copy part of the files from the source directory to the website folder. MSDeploy is Microsoft's answer to it, and it is waaaaaay too complex. I created an NAnt task that does this, although this also does not apply to your specific scenario. However, a general methodology may:

  • Scan the sln file looking for web projects. What does a web project do? Technically, the guides are in the csproj file or the project type identifier in the sln file. I tricked and identified it as "the destination folder contains the web.config file." If your solution has only one website project, you can skip this step and simply copy the .csproj file.

  • Scan the csproj file for <Content Include="some\file.ext" /> nodes. XPath can do this, Linq to XML can do this. This gives you all .aspx, .cshtml, .js, .css, .png, .config, etc. Etc. Carefully leaving all .cs files. You will need to prefix the path to the .csproj file to get the true location of the source file, and you want you to keep the folder structure in the destination. But this is trivial compared to collecting a list of files.

  • Now that you have the list of files, skip copying it from the source folder to the destination folder. (You probably want to either clear the destination folder first, or then delete the extra files from previous deployments. I think the first is easier.) The only thing that scanning the csproj file did not give you is the contents of the bin folder, but this cake: copy all contents folders bin .: D (There is a healthy discussion about whether to copy .pdb files, but I say yes.)

Create a script to complete the above 3 steps, then call it either from the XBuild task, or call XBuild and this script from the CI process. Poof. You have a deployment goal. Happy coding!

+8
source

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

Microsoft MVC (any version) is not installed on the build server. However, this is very easy to get 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 earlier version at the bottom of the page and you will get instructions on installing this version of the framework.

Hope this makes it easier for you!

0
source

@DHarun's idea works great! I wrote a small script based on @Dharun's idea, hope this can help others. https://github.com/z-ji/MonoWebPublisher

0
source

All Articles