To deploy and Publish a WebAPI or MVC application, these 2 steps should work most of the time:
- Visual Studio Build
- Publish Build Artifacts
If you right-click on your WebAPI Project, go to “Package/Publish Web” tab and check the Items to deploy drop-down, the default value selected is:
Only files needed to run this application
The below solution produces the same output as when you build the WebAPI in Visual Studio.
This is the cue, that let me find the solution to build my WebAPI Project. The WebAPI Project consists of multiple Class Libraries with Business and DAL layers as well.
Follow the steps as below:
- Add /p:DeployOnBuild=true /p:OutDir=”$(build.artifactstagingdirectory)\” arguments in Visual Studio Build step:
- Change “Path to Publish” of Publish Build Artifacts task to $(build.artifactstagingdirectory)\_PublishedWebsites\ProjectName:
I’ve written another post on Creating Build Definition here.