0

I got an asp.net core WebApp project. Now I want to start that web app from another console app.

How do I do that?

I want to reuse all the configuration and DI setup from webapp. Thanks

terle
  • 86
  • 10
  • Asp.net core web projects by default hosted and run via console app. Is there anything you want to do specifically? – Chetan Sep 16 '19 at 12:01
  • @chetan Yes. I'm trying to run contract based API testing (Pact Foundation). I need to spin up the API and tweak the DI a bit to mock dependencies to run the test. – terle Sep 16 '19 at 12:04
  • Can you not simply use a test project and the test server? https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-2.2 – Chris Pratt Sep 16 '19 at 12:18
  • @ChrisPratt. I did not know that existed. It looks very promising. I will have a look right now. Thanks – terle Sep 16 '19 at 12:26
  • @ChrisPratt So I read it, and it's awesome!!! It is exactly what I needed. Thank you! If you want; write an answer to my ealier questions and I'll give you the points (Y) https://stackoverflow.com/questions/57850859/how-to-configureservices-in-asp-net-core-webapi-from-another-assembly – terle Sep 17 '19 at 11:17

1 Answers1

0

You can use the DOTNET run command from your console app to run the Web App.

dotnet run --project ./projects/proj1/proj1.csproj

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run?tabs=netcore21

Draken
  • 3,134
  • 13
  • 34
  • 54