我需要帮助来设置Azure DevOps管道。这是我目前的状态:
制造零件
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
# https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=azure-devops
trigger:
- master
name: Build-$(Rev:r)
pool:
vmImage: 'Ubuntu-16.04'
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreInstaller@0
inputs:
version: '2.2.202'
- task: DotNetCoreCLI@2
displayName: Build $(BuildConfiguration)
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
# Tests here
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
- task: DotNetCoreCLI@2
displayName: Publish $(BuildConfiguration)
inputs:
command: publish
projects: '**/*.csproj'
publishWebProjects: false
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
inputs:
ArtifactName: 'drop'
请注意zipAfterPublish:如Microsoft官方文档中所述为true。在构建过程中我没有问题。它为我提供了一个带有多个zip文件的漂亮工件。
发布零件 在这里,我不使用YAML,但是我将复制并粘贴设置的YAML视图。让我们关注链接到我的主zip文件的第1阶段代理程序作业1。 API。 WepAPI.zip。
steps:
- task: FileTransform@1
displayName: 'File Transform: appsettings.json'
inputs:
folderPath: '$(System.DefaultWorkingDirectory)/Xxxx Project-CI/drop/Xxx.WebApi.zip'
fileType: json
targetFiles: '**/appsettings.json'
然后
#Your build pipeline references an undefined variable named ‘Parameters.ConnectedServiceName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppKind’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Azure Wev App Deploy: xxx-api'
inputs:
azureSubscription: '$(Parameters.ConnectedServiceName)'
appType: '$(Parameters.WebAppKind)'
WebAppName: '$(Parameters.WebAppName)'
packageForLinux: '$(System.DefaultWorkingDirectory)/Xxxx Project-CI/drop/Api.zip'
变量
我还定义了1个变量组和2个变量
问题
当我使用Kudu调试控制台并在编辑模式下打开appsettings.json时,我看不到任何东西被替换。
这是我的appsettings.json
{
"IdentityServer4": {
"Authority": "https://localhost:44367",
"ApiName": "xxxxxx"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"OygConnection": "Server=(localdb)\\mssqllocaldb;Database=XxxXxxx;Trusted_Connection=True;"
},
"AllowedHosts": "*"
}
没有任何变化。这些都是我的本地计算机设置。不适用于我的Azure登台环境。看来我的FileTransform @ 1任务被忽略了。也许任务无法在zip中找到* .json文件。或替换它,但不将其保存回zip。使用此转换任务的正确方法是什么?
我已经尝试使用除zip包以外的其他方式进行部署,但这种方法不起作用。我还有其他问题。看来Azure部署任务需要一个zip包进行部署。
我将尽快复制粘贴我的日志。