Search code examples
c#asp.netasp.net-corednxkestrel-http-server

DNX start multiple websites


I have a folder A, which including two websites project. Can I start them only one command?

Such as dnx <something here> kestrel. For now, I have to switch to each website root directory, and execute command dnx . kestrel separately.

Any suggestion is helpful.


Solution

  • That . in the command is saying "start the site in this folder". Alternatively, you should be able to provide a path to a folder. Example: dnx Project1 kestrel if you're in the directory above the project, and the project is in a folder called "Project1".

    Knowing that, you can then build a batch file to launch both from one command. Put these commands in a separate file, probably in the directory above the projects. You may need to replace Project1 and Project2 with the correct absolute or relative paths to the folders the projects are in.

    dnx Project1 kestrel
    dnx Project2 kestrel
    

    Windows

    If you're on Windows, then you would probably use .cmd for the file extension. Then you can launch the file from the command prompt by entering the name of the file, ex, LaunchBothSites.cmd. Or you can double click the file in Windows Explorer.


    Linux

    If you're on Linux, you typically give the file a .sh extension. You may also need to mark the file as executable. For example, chmod +x LaunchBothSites.sh. Then you can launch the site from the command line with ./LaunchBothSites.sh.