How to create installer for ASP.NET Core windows service? - asp.net-core

I want to create installer that will install my ASP.Net Core 3.1 app as windows service (the app code already has .UseWindowsService();).
Right now when i publish the app, there are a lot of files and i just use sc create command in cmd to install it as service (specifying .exe path).
I want to create just one exe file that will include installer and files needed for installation. I would like to have some basic ui where you could choose path if you want different path than default. It should start service after installation and set it to start automatically. Before installation it should check if service is already installed and if it is, try to start it and inform user about it.

The located at https://github.com/iswix-llc/iswix-tutorials will handle this. Build your EXE to not require .net core. If you want to install .net core as a prereq instead you'll want to use the IsWiX bootstrapper project template and add .net core to your bundle.wxs.
This short video shows the whole process that's described in the tutorial.
https://www.youtube.com/watch?v=bxbcPnjfzIc

Related

.Net core - How to create multi-platform executable from a console app

I'm starting to work with .net core 1.1 on a Web API project. The way I'm currently starting my server for the API is by publishing with dotnet publish and then running with dotnet MyProject.dll. Now I have a requirement to start the server from an executable file on Windows and on Linux. I wrote a .net core console app that does just that but the question is how do I wrap in in an executable file for .exe for Windows and what ever it is for Linux...?
I'm just entering the link given in the comment, to mark it as the correct answer.
Self-contained deployment without third-party dependencies

WixManagedBootstrapperApplicationHost custom UI

I have created a msi which allows user to view license, select installation folder, and features to install. That all works well.
Now I need to create a bootstrapper that will check if framework 4.5 is installed, install it if not, and then install msi.
I can do this using WixStandardBootstrapperApplication.RtfLargeLicense, where I would install framework, and then execute msi with its own UI.
But what if I do not want to show two apps (msi over exe), but only one window?
Since my msi contains feature, standard bootstrapper does not provide interface where I can set features from msi, so I need to create a custom UI.
The problem is I do not quite understand how WixManagedBootstrapperApplicationHost works? I created a dll with new UI, and place it in Payload. When running the setup, when framework needs to be installed, WixManagedBootstrapperApplicationHost always invokes its own window which says:
Microsoft .NET Framework required for MyApp Setup. Click the "Accept and Install" button to accept the Microsoft .NET Framework license terms.
And after it completes installation of .NET Framework, then it invokes the UI that I Created in dll. Why would anyone want this kind of functionality, where my bootstrapper app contains totally different UI than the framework installation UI? Isn't the idea of bootstrapper with custom UI is to provide completely custom UI?
So, how can I provide my custom UI for that framework installation part?
I assume your own UI is C# and WPF? If your installing it on a machine without .Net then it's going to need to install .Net before it can show the WPF UI. I could be wrong but I'm sure that's unavoidable.
If you want to replace / modify the .Net install screen then this thread looks like it has the answer:
Wix Burn: Basic UI handling if No Net Framework is there
However if your saying the .Net install dialog is showing up over your UI at some point in installation then you need to set the Install command to "/q" which means quiet (no UI).

How to Create Websetup for Clickonce type windows forms application by publishing it to some folder

Trying to publish a click once type app to a local directory and create a websetup with the published contents- so that i can give tat setup to install in two different servers. but as the publishing wizard takes a URL - separate setup is required for each server. Is there any way that i can create a single setup which i can use it in two servers..?
The URL for setup.exe is only for the purpose of bootstrapping. What I found is that the bootstrapper that gets created with your deployment manifest ('setup.exe') is designed for a web-published application.
If your clickonce publish will be installed on intranet servers, you can't use out of the box bootstrapper. You may write your own or build a seperate setup project for bootstrapping and calling the .application from the installed server when the pre requisites where installed.
If you don't rely on pre requisites and you can ask users to make sure they have the right CLR version, you don't need the setup.exe at all.

Setup project: Adding .NET and Windows Installer prerequisites results in large installer

I've created my program successfully. Now, I want to publish it. I've created a Setup Project in order to make an installation file. I've added .NET 4.0 Client and Windows Installer as project prerequisites (via Setup Project Properties → Prerequisites). After that, I build my project.
This produces these files:
Setup files, .NET 4.0 Client, Windows Installer
But .NET 4.0 Client and Windows Installer make my project most biggest. So I would like to know if there is a way to make my setup file contain just the required libraries, i.e. the setup program won't install .NET on the target host?
No I don't think so - without the .net framework your are screwed here.
When you do this the .NET framework is not included in the MSI package and doesn't make the file any bigger. It is only a pre-requisite for the successful installation. So when you run the setup on the client computer if it already has the framework installed it won't do anything. If it doesn't it will ask the client to download it. You could of course remove this prerequisite but because your application is built with .NET if the client computer doesn't have the correct version installed your application won't run. So I would suggest you to leave this prerequisite in your setup project.

building a windows service using msbuild

Can someone point out any tutorials that help build windows services using msbuild.
Requirements :
- Should not use the csproj file
- Output should be the same as the publish option in Visual Studio
Updated question:
We have a project of type windows service in our solution. In this windows service, we are referencing a couple of libraries that reside on a different system (one of them is not strongly named). This solution also contains other class libraries and websites/web-apps.
I am trying to write a custom build that outputs a xcopy deployable version of the website, and a deployable version of the windows service. When I say windows service, it shows up on the Control Panel -> Services MMC.
The website build was easy via msbuild...however I am struggling with the windows service build. Until now, my fellow developers were using the right-click on the project file ,and click publish to publish the windows service. This generates a setup.exe file that helps the admins to deploy the service.
So, now here is my question:
I want to use msbuild to build my windows service.
I do not want to directly use the .csproj file in conjunction with msbuild to build the service.
The output my build file generates should match the output from the "publish" option (*the publish option generates a setup.exe file*)
In general, "the publish option" under the covers just runs a build with /t:Publish, i.e., it triggers a different target to the normal default 'Build' one.
Can you tell us more of what you are looking for, as opposed to not looking for?
Are you looking to generate an MSI? (If so, you definitely won't be using MSBuild if you're using the built-in .vdproj system - but be careful - this means having to put VS on a build server)