System.OutOfMemoryException when packaging/publishing Azure project System.OutOfMemoryException when packaging/publishing Azure project azure azure

System.OutOfMemoryException when packaging/publishing Azure project


This error can occur not just because of the package size. We occasionally receive this error, but a simple restart of Visual Studio resolves the issue.


This is typically caused by trying to place too much content into your package, not by how many projects you reference. There is a maximum size that can be placed into the .cspkg zip stream, and there is a maximum size of .cspkg that can be uploaded to Azure (600 MB).

You should remove all static content such as images, audio, or video from your package and instead place those assets into blob storage. You can change hrefs so that customers directly download the contents from blob storage, or you can use something like the Azure Boostrapper to download content to the VM on startup.

Also, btw, the amount of RAM you have on your machine is in no way related to getting OutOfMemoryException in any application (unless you have too small of a swap file, but that is a different issue).


Figured it out after turning debug logging to diagnostic and running it twice. The exception started popping up when trying to copy/paste the log.

The problem is that the output log is so excessive that it starves the msbuild process running in the same thread for ram. turn the output logging level down, and it should fix it.