Brian Truman
Brian Truman

Reputation: 91

.Net Core application fails to publish to GCP App Engine becuase of MVC.Abstractions

This is my first foyer into .Net Core and App Engines, so please forgive me if I sound uninformed.

We have a .Net Core Application that we're trying to get published to a GCP App engine (obviously). when I run dotnet publish -c Release it builds just fine without any errors. When I test the program locally it runs just fine and I'm able to access it. However whenever I try to get it on GCP I get the following error:

Updating service [default] (this may take several minutes)...
.................................................................................................................................................failed.
ERROR: (gcloud.app.deploy) Error Response: [9] 
Application startup error:
Error:
  An assembly specified in the application dependencies manifest (ApplicationName.deps.json) was not found:
    package: 'Microsoft.AspNetCore.Mvc.Abstractions', version: '2.0.2'
    path: 'lib/netstandard2.0/Microsoft.AspNetCore.Mvc.Abstractions.dll'
  This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
    aspnetcore-store-2.0.5.xml

Failed to deploy project WebApiDotNetCore to App Engine Flex.

We tried removing it from the dependencies JSON, and that just ended up breaking everything, so it is indeed required. It is installed in the project via nuget, so it should be included with dotnet restore. I've looked around and some sources seem to think that it's the installation of the dotnet core sdk, but I've tried it on three computers and always get the same thing.

Lastly, I should say this happens when I try to deploy through command line as well as directly through Visual Studio with the GCP SDK.

Has anyone experienced this error, or something similar? Any advice or guidance is very much appreciated.

Thanks!

-BT

Upvotes: 3

Views: 1350

Answers (3)

Brian Truman
Brian Truman

Reputation: 91

OP REVISION

As an update I was able to get this resolved aside from the fact that I get a 502 error when I try to load the application. Here are the steps I took for anyone else that is looking what to do:

Pre-reqs: Docker for Windows and Google Cloud SDK installed and running. Running turned out to be a pain with Docker for Windows. Many many restarts and reinstallations.

  1. Open the solution and ensure that the startup project is set correctly.
  2. Right click the startup Project, and select Add > Docker Support.
  3. Select Linux in the popup window and allow the files to be created.
  4. When complete, the Dockerfile should appear in the preview window. Do the following:

For me the first line read: FROM microsoft/aspnetcore:2.0 AS base. Change this to FROM microsoft/aspnetcore-build:2.0 AS base.

Additionally, check to make sure that the last line has the correct .dll name. Docker for Windows will put whatever the project name is rather than the class name, so for me my final .dll names were different than the project name.

Lastly, if your project has any dependencies that are required to run but not to build, then you'll need to manually add them. For me we have a couple of XML files that needed to be put in the app folder, so I had to add COPY *.xml /app/ and put those files in the same folder as the solution file is in.

If there's anything else you need to do to the Dockerfile I highly recommend this page. It's a how-to on all Dockerfile commands written in ENGLISH! (that was my biggest problem with all of this - I have little experience with Linux and even less with Docker and everything was written in Greek for me).

  1. Create an app.yaml file. I just used the standard: runtime: custom env: flex

  2. Copy the Dockerfile found in the startup project's folder into the folder with the solution.

  3. Initialize gcloud to the right project, then navigate to the solution folder. The type gcloud app deploy app.yaml, and follow the onscreen guide.

for me it takes about 15 minutes to deploy the GCP, so depending on the complexity of your project it may take longer, though this one is rather complex.

Now I'm trying to figure out my 502 error... I've tried what seems like everything - changing the listening port in the application, exposing the listening port on the dockerfile, trying to get GCP to open that port, and trying half a dozen different ports. It's slow-going since it's such a chore to deploy each time.

Hope this helps anyone that was like me a couple weeks ago and had never even heard of Docker!

Upvotes: 3

Rodrigo C.
Rodrigo C.

Reputation: 1184

It looks that you don't have the Microsoft.AspNetCore.Mvc.Abstractions library installed in your system. Using the .NET CLI, type the following command:

dotnet add package Microsoft.AspNetCore.Mvc.Abstractions --version 2.0.2

After that, to ensure the library is included, run the following:

dotnet restore
dotnet build

Try running it locally (it should work), and then use the dotnet publish -c Release command again.

Upvotes: 0

Mete Atamel
Mete Atamel

Reputation: 831

Which version of .NET Core is this? Also, have you tried to run in Cloud Shell? Maybe that will provide more clues on what might be wrong.

Upvotes: 0

Related Questions