I'm new to coding and spend most of my time in mobile application development with Phonegap, I've been learning how to code ASP.NET Web APIs and I know how it generally all works while having the code open in front of me but ---
I was asked a question today and I made a decent fool of myself attempting to answer it. Say you've got an ASP.NET Web API comprised of multiple projects, one for the core API and it's controllers, one for it's repositories, and another for the data structures being used. The routes are setup so they'll look for myServer.com/api/myController/giveMeSomeData. When the MSBUILD does it's thing and builds the API it produces a long list of dlls that has myApi.dll, myRepositories.dll, myDataStructures.dll, and the referenced libraries. Once this is all pushed to an Azure Cloud Service or whatever IIS instance to host it, how does server find /api/myController and where does it actually reside in the built files?
Best How To :
The WebApi is a web project and on compiling it creates a dll. It is not a class library or a nuget package to consume and use it. I have practically implemented this in a real world application and below are my thoughts for your understanding.
Your question is
Once this is all pushed to an Azure Cloud Service or whatever IIS instance to host it, how does server find /api/myController and where does it actually reside in the built files?
We cannot predict the behavior of the dll as everything goes in the form of managed code. The person who asked you this question is trying to ask you about deployment automation but he/she him/herself is not aware of it completely. Build artifacts are a collection of dlls for the solution (
.sln). I think the person who asked this question to you would have just have seen these dlls in the server without knowing what is the actual concept of using
MSBUILD. The exact question should be How will you deploy the dlls of web api along with the dlls dependent (repository,controller and other projects) in server, azure and so on..?
To answer this question, we need to know about the web project deployments. It is a very interesting topic to discuss about deployment automation using
MSBUILD is an xml based scripting language that helps you compile and build your .net applications and a very interesting language for build automation.
ASP.NET Web API is also a type of ASP.NET application without the web pages or views (if MVC) and it should be deployed as the same way we deploy our mvc applications. Of course, we have so many projects like repositories,controllers under one solution file(
.sln). By compiling the solution using MSBUILD we create build artifacts.
All web projects need build artifacts that can be directly IMPORTED as a website or application under iis manager/ Azure and so on. We will create a .zip file in terms Web API and import them in the inetmgr. You can take this .zip file and import them wherever you want (say in a different machine too).
The build artifacts are created by compiling the application using
MSBUILD scripts to execute
aspnet_compiler exe. This link will help you with that. Whatever information, say routes,controllers and so on we set up are getting pre-compiled and creating a precompiled dll. It is not okay to ask you how it will behave as everything goes in the form of binary once it is pre-compiled.
The complete process is called as deployment automation. Check out the command line deployment using MSBUILD section in the link and reading about deployment automation will help you further on this.
If you need more answers please reply I will help you further or you can google about deployment automation. Hope this helps you choose this as an answer.