0

我有一个针对 ASP.NET Core 3.0 的应用程序。

我使用 Azure DevOps 构建了它,并从那里直接发布到 Azure Web App for Container。此 YAML 用于生成图像:

# Docker
# Build a Docker image 
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

resources:
- repo: self

variables:
  tag: '$(Build.BuildId)'
  BuildConfiguration: Release

stages:
- stage: Build
  displayName: Build image
  jobs:  
  - job: Build
    displayName: Build
    pool:
      name: 'Azure Pool inside Network Linux'
      vmImage: 'ubuntu-latest'
    steps:
    - task: UseDotNet@2
      displayName: Install .Net Core 3.0
      inputs:
        packageType: 'sdk'
        version: '3.0.x'
        includePreviewVersions: false
    - task: DotNetCoreCLI@2
      displayName: Restore packages
      inputs:
        command: 'restore'
        projects: '**/*.csproj'
        feedsToUse: 'select'
        vstsFeed: '8187f5c9-e9c1-419f-8a5c-98285cf7633c'
    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
        command: 'build'
        arguments: '--configuration $(BuildConfiguration)'
        projects: '**/*.csproj'
    - task: DotNetCoreCLI@2
      displayName: Publish
      inputs:
        command: 'publish'
        publishWebProjects: false
        projects: '**/NetCoreBoilerplate.WebApi.csproj'
        arguments: '--configuration $(BuildConfiguration)'
        zipAfterPublish: false
        modifyOutputPath: false
    - task: Docker@2
      displayName: Build an image
      inputs:
        command: buildAndPush
        containerRegistry: 'ContainerRegistry'
        repository: 'NetBoilerPlate'
        buildContext: '$(Build.SourcesDirectory)/src/NetCoreBoilerplate.WebApi/bin/$(BuildConfiguration)/netcoreapp3.0/'
        dockerfile: '$(Build.SourcesDirectory)/tools/docker/Dockerfile'
        tags: |
          $(tag)

而这个 Dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
RUN useradd --create-home -s /bin/bash user
WORKDIR /home/user
USER user
ENV APP_HOME /home/user/app
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ENV ASPNETCORE_URLS http://+:5000
EXPOSE 5000
COPY publish .
ENTRYPOINT ["dotnet", "NetCoreBoilerplate.WebApi.dll"]

该应用程序在本地工作,但是当我将它部署到 Azure 时,我在日志中发现了这个错误。

2019-10-02T14:20:43.177686408Z It was not possible to find any compatible framework version
2019-10-02T14:20:43.178398914Z The specified framework 'Microsoft.AspNetCore.App', version '3.0.0' was not found.
2019-10-02T14:20:43.178667416Z   - The following frameworks were found:
2019-10-02T14:20:43.178867518Z        3.0.0-preview8.19405.7 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2019-10-02T14:20:43.178936019Z
2019-10-02T14:20:43.179157321Z You can resolve the problem by installing the specified framework and/or SDK.
2019-10-02T14:20:43.179240321Z
2019-10-02T14:20:43.179425023Z The .NET Core frameworks can be found at:
2019-10-02T14:20:43.179548024Z        - https://aka.ms/dotnet-download

知道有什么问题吗?

4

1 回答 1

0

是的,我终于通过更改 dockerfile 中的原始图像来解决它

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS base
于 2019-11-15T14:58:35.007 回答