Search code examples
asp.netasp.net-mvcmodel-view-controllerweb-applicationssetup-deployment

Converting - asp.net mvc 5 web application (Visual studio 2017) to .exe setup file


I would like to know if there is any possibility to convert an asp.net mvc 5 web application into an .exe setup file. I tried various links. But i didn't get any output. I received a .msi file and when i tried installing, the installation stops right at the beginning displaying a message = "installation stopped. Please try again". or if i try to install the setup file i get a message = "Invalid.. Please check if package exists...bla bla bla"

Some of the links that i tried are listed below.

https://www.c-sharpcorner.com/article/step-by-step-guide-to-create-a-setup-for-a-web-application/

https://weblogs.asp.net/scottgu/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005

https://www.c-sharpcorner.com/article/creating-setup-and-deployment-projects-in-vs-net/

https://www.codeproject.com/Questions/297343/How-to-create-exe-or-msi-file-setup-file-of-web-ap

And Much More...


Solution

  • You first need to do some preparation:

    1. Set up IIS 6 Management Compatibility (To prevent those "Installation stopped" errors)
    2. Install Microsoft Visual Studio Installer Projects extension. (To add setup project template to VS)

    Then you can create and configure and setup project and run the setup.

    Details

    1 - Set up IIS 6 Management Compatibility

    Open Turn Windows features on or offInternet Information ServiceWeb Management Tool and check at least the following items:

    • IIS 6 WMI Compatibility
    • IIS 6 Metabase and IIS 6 configuration compatibility.

    This is to fix the following error:

    The installer was interrupted before application could be installed. You need to restart the installer to try again

    2 - Install Microsoft Visual Studio Installer Projects.

    This is to add setup project templates to Visual Studio. Here, we are interested in Web Setup Project.

    3 - Create and configure the setup project

    1. Create setup project
    2. Right click setup project → Add → Project output and choose what you need. You need at least primary output and Content Files from your web project.

    Then you can build the project and run setup.exe.

    Note

    • You can setup other properties like ASPNETVersion, Manufacturere, product Name, ...
    • If after deployment you faced with error complaining about \roslyn\csc.exe, you may want to include roslyn files or remove roslyn compilation at all. For more information take a look at this post.
    • You can add CustomAction to do some custom actions during install/uninstall. You can find a lot of examples around, like this post.
    • You can even customize UI and add some input and use them during installation. You can find a lot of examples around, like this post.
    • In general, if your deployment is a common site deployment having a few files and database, a better option is creating Web Deploy Packages and then install the package to IIS. You can automate that process easily.