This is my first foyer into .Net Core and App Engines, so please forgive me if I sound uninformed.
这是我第一次进入。net Core和应用引擎,所以如果我听起来不知情,请原谅我。
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:
我们有一个。net核心应用程序,我们试图将它发布到GCP应用程序引擎中(显然)。当我运行dotnet发布-c版本时,它构建得很好,没有任何错误。当我在本地测试程序时,它运行良好,我能够访问它。但是,每当我尝试在GCP中获取它时,我就会得到以下错误:
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.
我们尝试从依赖项JSON中删除它,这最终破坏了所有东西,所以它确实是必需的。它通过nuget安装在项目中,因此应该包含在dotnet恢复中。我四处查看了一下,一些消息来源似乎认为这是dotnet核心sdk的安装,但我已经在三部电脑上试用过了,而且总是得到相同的结果。
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.
最后,我应该说,当我尝试通过命令行和GCP SDK直接通过Visual Studio时,会发生这种情况。
Has anyone experienced this error, or something similar? Any advice or guidance is very much appreciated.
有人经历过这种错误吗?非常感谢您的建议或指导。
Thanks!
谢谢!
-BT
英国电信
3 个解决方案
#1
1
OP REVISION
OP修订
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:
作为一个更新,我能够解决这个问题,除了当我试图加载应用程序时,会出现502个错误。以下是我为其他人所采取的步骤:
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.
预编译:安装和运行Windows和谷歌云SDK的Docker。对于Docker来说,运行起来是一件非常痛苦的事情。许多许多重新启动和重新安装。
- Open the solution and ensure that the startup project is set correctly.
- 打开解决方案并确保启动项目被正确设置。
- Right click the startup Project, and select Add > Docker Support.
- 右键单击启动项目,并选择添加> Docker支持。
- Select Linux in the popup window and allow the files to be created.
- 在弹出窗口中选择Linux,并允许创建文件。
- When complete, the Dockerfile should appear in the preview window. Do the following:
- 完成后,Dockerfile应该出现在预览窗口中。执行以下操作:
For me the first line read: FROM microsoft/aspnetcore:2.0 AS base
. Change this to FROM microsoft/aspnetcore-build:2.0 AS base
.
对于我来说,第一行是:从microsoft/aspnetcore:2.0作为基础。将其从microsoft/aspnetcore-build改为:2.0作为基础。
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.
此外,检查以确保最后一行有正确的.dll名称。Windows的Docker会将项目名而不是类名放在任何位置,因此对我来说,我最终的。dll名称与项目名不同。
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.
最后,如果您的项目有任何需要运行但不需要构建的依赖项,那么您需要手动添加它们。对于我来说,我们有几个XML文件需要放到app文件夹中,所以我必须添加COPY *。xml /app/并将这些文件放在解决方案文件所在的文件夹中。
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).
如果您还需要对Dockerfile做什么,我强烈推荐这个页面。这是一个如何操作所有用英语写的Dockerfile命令!(这是我遇到的最大问题——我对Linux没什么经验,更别提Docker了,所有的东西都是用希腊语写的)。
-
Create an app.yaml file. I just used the standard:
runtime: custom env: flex
创建一个app.yaml文件。我刚刚使用了标准:运行时:custom env: flex。
-
Copy the Dockerfile found in the startup project's folder into the folder with the solution.
将启动项目文件夹中找到的Dockerfile与解决方案一起复制到文件夹中。
- Initialize gcloud to the right project, then navigate to the solution folder. The type
gcloud app deploy app.yaml
, and follow the onscreen guide. - 将gcloud初始化到正确的项目,然后导航到解决方案文件夹。类型gcloud应用程序部署app.yaml,并遵循屏幕上的指南。
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.
对我来说,部署GCP大约需要15分钟,因此根据项目的复杂性,可能需要更长的时间,尽管这个比较复杂。
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.
现在我要算出502的误差。我尝试了所有的方法——更改应用程序中的监听端口,公开dockerfile上的监听端口,尝试让GCP打开该端口,并尝试了六种不同的端口。这是缓慢的,因为每次部署都是一件苦差事。
Hope this helps anyone that was like me a couple weeks ago and had never even heard of Docker!
希望这能帮助那些几个星期前和我一样从未听说过Docker的人!
#2
0
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.
这是。net核心的哪个版本?另外,你试过在云Shell中运行吗?也许这将提供更多关于什么是错误的线索。
#3
0
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:
看起来你没有Microsoft.AspNetCore.Mvc。在系统中安装的抽象库。使用.NET CLI,输入以下命令:
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.
尝试在本地运行它(应该可以工作),然后再次使用dotnet发布-c发布命令。
#1
1
OP REVISION
OP修订
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:
作为一个更新,我能够解决这个问题,除了当我试图加载应用程序时,会出现502个错误。以下是我为其他人所采取的步骤:
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.
预编译:安装和运行Windows和谷歌云SDK的Docker。对于Docker来说,运行起来是一件非常痛苦的事情。许多许多重新启动和重新安装。
- Open the solution and ensure that the startup project is set correctly.
- 打开解决方案并确保启动项目被正确设置。
- Right click the startup Project, and select Add > Docker Support.
- 右键单击启动项目,并选择添加> Docker支持。
- Select Linux in the popup window and allow the files to be created.
- 在弹出窗口中选择Linux,并允许创建文件。
- When complete, the Dockerfile should appear in the preview window. Do the following:
- 完成后,Dockerfile应该出现在预览窗口中。执行以下操作:
For me the first line read: FROM microsoft/aspnetcore:2.0 AS base
. Change this to FROM microsoft/aspnetcore-build:2.0 AS base
.
对于我来说,第一行是:从microsoft/aspnetcore:2.0作为基础。将其从microsoft/aspnetcore-build改为:2.0作为基础。
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.
此外,检查以确保最后一行有正确的.dll名称。Windows的Docker会将项目名而不是类名放在任何位置,因此对我来说,我最终的。dll名称与项目名不同。
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.
最后,如果您的项目有任何需要运行但不需要构建的依赖项,那么您需要手动添加它们。对于我来说,我们有几个XML文件需要放到app文件夹中,所以我必须添加COPY *。xml /app/并将这些文件放在解决方案文件所在的文件夹中。
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).
如果您还需要对Dockerfile做什么,我强烈推荐这个页面。这是一个如何操作所有用英语写的Dockerfile命令!(这是我遇到的最大问题——我对Linux没什么经验,更别提Docker了,所有的东西都是用希腊语写的)。
-
Create an app.yaml file. I just used the standard:
runtime: custom env: flex
创建一个app.yaml文件。我刚刚使用了标准:运行时:custom env: flex。
-
Copy the Dockerfile found in the startup project's folder into the folder with the solution.
将启动项目文件夹中找到的Dockerfile与解决方案一起复制到文件夹中。
- Initialize gcloud to the right project, then navigate to the solution folder. The type
gcloud app deploy app.yaml
, and follow the onscreen guide. - 将gcloud初始化到正确的项目,然后导航到解决方案文件夹。类型gcloud应用程序部署app.yaml,并遵循屏幕上的指南。
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.
对我来说,部署GCP大约需要15分钟,因此根据项目的复杂性,可能需要更长的时间,尽管这个比较复杂。
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.
现在我要算出502的误差。我尝试了所有的方法——更改应用程序中的监听端口,公开dockerfile上的监听端口,尝试让GCP打开该端口,并尝试了六种不同的端口。这是缓慢的,因为每次部署都是一件苦差事。
Hope this helps anyone that was like me a couple weeks ago and had never even heard of Docker!
希望这能帮助那些几个星期前和我一样从未听说过Docker的人!
#2
0
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.
这是。net核心的哪个版本?另外,你试过在云Shell中运行吗?也许这将提供更多关于什么是错误的线索。
#3
0
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:
看起来你没有Microsoft.AspNetCore.Mvc。在系统中安装的抽象库。使用.NET CLI,输入以下命令:
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.
尝试在本地运行它(应该可以工作),然后再次使用dotnet发布-c发布命令。