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

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

Related

HTTP Error 502.5 - Process Failure asp .net core 5

I'm having problems visit my site on a browser and this is the error I'm getting (see pic). I'm able to open the project in cli with dotnet project.dll command, what I want is to open it in a browser (like: server.com\project). I published the project in a folder and I also chose self-contained deployment mode. I couldn't find a right solution to questions that were asked. I'm using .net core 5.
The most common reason for this is that you haven't installed the .NET Core runtime on the server.
Check the download page from here Download .NET 5.0 Runtime and SDK

How to create installer for ASP.NET Core windows service?

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

Run an ASP.NET Core project with Kestrel without Visual Studio

I've created an ASP.NET core 2.1 project in VS2017 and run it successfully from VS2017.
The question is, What is the easiest way to run the above configuration (not production/release/deploy configuration) out of Visual Studio, on the same machine.
I can't find any exe in the project, and dotnet run in the project folder/output folder doesn't work.
It's best to generate an exe and click it to run.
It requires a lot of preparations to run kestrel as standalone application. Checkout this sample implementation in GitHub
https://github.com/PeteX/StandaloneKestrel

ASP.NET Core self-contained exe

I want my ASP.NET Core Web API to run as a self-contained exe within the .NET framework and not .NET Core Framework. Is that possible? Thanks!
EDIT:
If I add "net451": {} to my frameworks section in project.json,
I get the following exception:
Failed to make the following project runnable: myProject (.NETCoreApp,Version=v1.0) reason: Expected coreclr library not found in package graph. Please try running dotnet restore again.
You can't create a self-contained app which targets .NET Framework >=4.5, because the full .NET Framework isn't modular and its not possible to have more than one version of it installed. Newer versions basically always replace the previous one.
Self-contained apps were one main motivation for .NET Core (together with portability)
You ALWAYS have to install .NET >=4.5 before your app can run. self-contained apps only work with .NET Core because .NET core libraries can be pulled through nuget package.
For .NET 4.6 you can only create portable apps, which is the default mode.

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.