我正在发布一个.net core 3.1应用程序,该应用程序保存在Azure DevOps存储库中,内置在构建管道中并发布到Azure Linux Web App Service容器中。整个过程似乎进展顺利,根据App Service中的部署刀片,部署成功。
预期结果
当我访问公共URL时,我希望能够看到部署的网站。
实际结果
相反,我看到一个新的主机页面,上面写着“嘿,.NET Core开发人员!您的应用程序服务已启动并正在运行。请继续执行下一步并部署代码”。
其他信息
应用服务似乎正在启动默认应用,因为启动我发布的应用时遇到问题。
我在应用程序服务常规配置中指定的启动命令是:
dotnet "SmartSAR.dll"
登录以启动App Service
2020-04-18 07:39:27.802 INFO - Container smartsar_0_36ea601f for site smartsar initialized successfully and is ready to serve requests.
2020-04-18T07:39:25.664749049Z _____
2020-04-18T07:39:25.664775249Z / _ \ __________ _________ ____
2020-04-18T07:39:25.664780549Z / /_\ \___ / | \_ __ \_/ __ \
2020-04-18T07:39:25.664799849Z / | \/ /| | /| | \/\ ___/
2020-04-18T07:39:25.664803949Z \____|__ /_____ \____/ |__| \___ >
2020-04-18T07:39:25.664808049Z \/ \/ \/
2020-04-18T07:39:25.664811949Z A P P S E R V I C E O N L I N U X
2020-04-18T07:39:25.664815749Z
2020-04-18T07:39:25.664819349Z Documentation: http://aka.ms/webapp-linux
2020-04-18T07:39:25.664823149Z Dotnet quickstart: https://aka.ms/dotnet-qs
2020-04-18T07:39:25.664826849Z ASP .NETCore Version: 3.1.0
2020-04-18T07:39:25.664830549Z Note: Any data outside '/home' is not persisted
2020-04-18T07:39:25.727133075Z Running oryx -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand 'dotnet "SmartSAR.dll"'
2020-04-18T07:39:25.730817476Z Oryx Version: 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
2020-04-18T07:39:25.737275979Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-04-18T07:39:25.737697979Z Could not find operation ID in manifest. Generating an operation id...
2020-04-18T07:39:25.738149780Z Build Operation ID: 6b038e35-4bdc-4c95-ba56-af4ed38e0ce0
2020-04-18T07:39:26.610476848Z Writing output script to '/opt/startup/startup.sh'
2020-04-18T07:39:27.105207557Z Running user provided startup command...
2020-04-18T07:39:27.112012760Z It was not possible to find any installed .NET Core SDKs
2020-04-18T07:39:27.112467060Z Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
2020-04-18T07:39:27.112892061Z https://aka.ms/dotnet-download
2020-04-18T07:39:27.113473661Z WARNING: Startup command execution failed with exit code 145
2020-04-18T07:39:27.113786261Z Running the default application instead...
2020-04-18T07:39:27.447628502Z Hosting environment: Production
2020-04-18T07:39:27.448410002Z Content root path: /defaulthome/hostingstart/
2020-04-18T07:39:27.449102503Z Now listening on: http://[::]:8080
构建管道YAML
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: UseDotNet@2
displayName: ".NET Core 3.1.x"
inputs:
version: '3.1.x'
packageType: sdk
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
生成的工件是一个包含WebApp.zip部署文件(以及相关文件)的放置。
据我所知,我需要启动的正在生成的dll是SmartSAR.dll。从构建日志中:
Building target "_CopyOutOfDateSourceItemsToOutputDirectory" partially, because some output files are out of date with respect to their input files.
Copying file from "d:\a\1\s\SmartSAR\obj\Release\netcoreapp3.1\SmartSAR.exe" to "d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.exe".
CopyFilesToOutputDirectory:
Copying file from "d:\a\1\s\SmartSAR\obj\Release\netcoreapp3.1\SmartSAR.dll" to "d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.dll".
SmartSAR -> d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.dll
Copying file from "d:\a\1\s\SmartSAR\obj\Release\netcoreapp3.1\SmartSAR.pdb" to "d:\a\1\s\SmartSAR\bin\Release\netcoreapp3.1\SmartSAR.pdb".
答案 0 :(得分:0)
您是否已将Azure Web应用程序的general settings堆栈属性设置为.NET Core?
答案 1 :(得分:0)
问题是我使用了为构建管道生成的默认YAML,但我没有注意到它针对的是Windows构建映像! (我责怪睡眠不足。)
这是我用于最终工作管道的YAML:
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: UseDotNet@2
displayName: ".NET Core 3.1.x"
inputs:
version: '3.1.x'
packageType: sdk
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: "Test"
inputs:
command: test
projects: '**/*tests/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: "Publish"
inputs:
command: 'publish'
publishWebProjects: true
arguments: '-r linux-x64 --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
displayName: "Upload Artifacts"
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'WebApp'