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:
uninstall-package Microsoft.AspNetCore.All
install-package Microsoft.AspNetCore
install-package Microsoft.AspNetCore.Mvc.Core
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.
Comments
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 }