Dotnet-warp & NSSM deployment. net core project to Windows Services

Time:2019-8-5

If you want to deploy the. net core project as a service to Windows, I hope this article will help you avoid detours.

Installation and use of dotnet-warp

Dotnet-ware is a global. NET Core tool that allows. NET Core projects to be packaged into a single executable
Project address: https://github.com/Hubert-Ryb…
Installation:dotnet tool install --global dotnet-warp
Use: Execute in the project output directorydotnet-warpThe application can be packaged into an EXE file (support: win-x64, linux-x64, osx-x64)

Dotnet-warp & NSSM deployment. net core project to Windows Services

NSSM Installation and Use

NSSM is a service encapsulation program, which can easily encapsulate Exe program into Windows service operation.
Download: nssm-2.24
Use: Copy the corresponding version to the target machine after downloading, and then execute the command line:nssm installThe visual interface can be called up.
Select the application path, add parameters with parameters, specify the service name, specify the execution user, and then install it.
Don’t forget to start the installation successfully:NSSM start service name
Dotnet-warp & NSSM deployment. net core project to Windows Services
Dotnet-warp & NSSM deployment. net core project to Windows Services

Execute/run the NSSM interface to view all commands and execute the corresponding commands according to the need

Dotnet-warp & NSSM deployment. net core project to Windows Services

Simply pass in the listening port to the asp.net core project

public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
    List<string> urls = new List<string>();
    Urls.Add ("http:/*: 5454"); //default listening
    // --urls http://*:6060,https://*:2333
    var urlIndex = args.ToList().IndexOf("--urls");
    if (urlIndex > -1 && args.Length > urlIndex + 1 && !string.IsNullOrEmpty(args[urlIndex + 1]))
    {
        urls.AddRange(args[urlIndex + 1].Split(','));
    }
    return WebHost.CreateDefaultBuilder(args)
            .UseUrls(urls.ToArray())
            .UseStartup<Startup>();
}

Matters needing attention

  • The wwwroot folder needs to be manually copied
  • Errors encountered when publishing to Windows 7****/ hostfxr.dll could not be foundDownload the corresponding system version of Windows 6.1-KB2533623 patch and restart

Recommended Today

Array of algorithms — sum of three numbers

Sum of three numbers difficultysecondary Here is an array of N integersnums, judgmentnumsAre there three elements a, B, C in a such that a + B + C = 0? Please find all triples that satisfy the condition and do not repeat.be careful:The answer cannot contain duplicate triples. Example:Given array nums = [- 1, 0, […]