You must understand that your .NET application and the Mongo database are different parts of the system. They can even be placed on different machines. Therefore, the publication of your application should not affect the availability of the database. However, you can combine these two actions into one simple batch file:
msbuild.exe [your app with necessary options] C:/mongodb/bin/mongod.exe [options]
About how to create and deploy web applications using msbuild , you can see here:
source share