publish two projects in same solution

user3842764 picture user3842764 · Aug 31, 2017 · Viewed 8.9k times · Source

I am currently running into an issue where I have an mvc project and an API project in the same solution,Visual Studio 2017. when I build the solution the structure is as follows solution solution/area1 solution/area2 solution/api I am able to reach the api with no issues when just building on my local machine, but when I go to publish the solution the api project builds the dlls but does not build out the solution/api so I cannot navigate to my api calls. I have tried setting up multiple start up solutions which did not resolve the issue.

Answer

Johan Donne picture Johan Donne · Aug 31, 2017

When you build on your local machine, you probably use '(Re)Build solution', which builds all projects in the solution. However, there is no such thing as 'Publish solution'. You can only publish a Project. When you do that, only the project and all its dependencies are built & published. if your API is in a seperate project and not referenced from the MVC site, it will not be built nor published together with that MVC application.

There are two viable approaches:

  1. You integrate the API in the MVC site (same domain, same routing mechanism, probably seperate area). In that case I would suggest keeping it in the same project for simplicity.

  2. You develop the API as a seperate application in its own (sub)domain. Here you put it in its own project. And you build and publish it on its own, seperate from the MVC application.