I have two projects in my Visual Studio solution; one is a .NET Framework console application and the other is a .NETCore API Server.
What I want is to be able to start and stop the server from the console.
- I know I can't just write the line for start up in my console application
CreateWebHostBuilder(args).Build().Run();
Because it would mean "add the server as a reference for the console app" and it wouldn't work because of incompatibility.
I wanted to start the server from it's
.exe
file but it turns out that it's started from an IIS service who feed in the generated Release folder. So it seems that's not possible either.I found this answer from another question but it says that we can just create a self-hosted server in our console application.
I'm not sure that, architecturally speaking, it would be a good practice to make the whole server side of my project in a "Server.cs class". I imagined it would be better as a separate project that would be started from the main one.
So far I have a pseudo-result by starting both projects and making the server wait for a Tcpsocket message (to start or to quit) from the console, but that definitely doesn't feel right and isn't as stable as I want.
Does anyone have an idea of how to proceed?