Sunday, August 12, 2018

Minimal ASP.NET Core Dependencies for Google Cloud

After a long hiatus, I'm slowly starting back on blogging and some personal projects. To get me back in the swing of things, here's a short post on running ASP.NET core on Google Cloud, since this seems poorly documented online.

The default project created by the Google Cloud tools includes Microsoft.AspNetCore.All which is a huge dependency. If you want something more minimal:

  1. uninstall-package Microsoft.AspNetCore.All
  2. install-package Microsoft.AspNetCore
  3. install-package Microsoft.AspNetCore.Mvc.Core
  4. install-package Microsoft.AspNetCore.Mvc

This creates a runnable project using the standard Google Cloud Web API project template, although it still isn't ideal as it includes the Razor pages dependencies.


John Zabroski said...

Nice! Welcome back! I've also been rather absent.

David said...

Cool, welcome back. :)

John Zabroski said...

Hi Sandro,

After looking into this issue myself for AWS, I realized the problem is not with Google Cloud Web API, but with the dotnet CLI. Run this on your local:

dotnet new -all
# Above command describes "web" as "ASP.NET Core Empty", which is misleading because it includes a ton of framework components under the NuGet super-package Microsoft.AspNetCore.App 2.1.1

# Run the following to confirm what I am saying:
dotnet new web
Get-Content .\obj\project.assets.json | ConvertFrom-Json | ForEach-Object { $($_.libraries -split ';') | Measure-Object }