4

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.

user3842764
  • 43
  • 1
  • 4

2 Answers2

5

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.

Johan Donne
  • 2,136
  • 10
  • 18
0
msbuild MyProject.csproj /p:DeployOnBuild=true;PublishProfile=<profile-name>;Password=<insert-password>

https://stackoverflow.com/a/14232754/2183503 has the answer.

Note: It has some spurious information (regarding passing vs version) though. For example, I tested the command out out just now and it worked fine without the /p:VisualStudioVersion=11.0 in Visual Studio 2019 Developer Command Prompt.

kotpal
  • 347
  • 4
  • 11