【发布时间】:2022-02-02 21:19:50
【问题描述】:
我有一个 Azure Function 项目。它包括带有一些秘密的 local.settings.json 配置文件。这些值由 xUnit 测试项目检索和使用。在 Visual Studio 上运行时一切正常,但在 Azure 构建管道中,不会注入值,并且文件包含原始占位符值。 local.settings.json 文件的 Build Action 为“Content”,Copy to Output Directory 为“Copy if newer”。 在管道中,我使用文件转换任务来注入值。 这是我的管道的一部分:
- task: FileTransform@1
inputs:
folderPath: '$(System.DefaultWorkingDirectory)/ProjectName'
fileType: 'json'
targetFiles: 'local.settings.json'
- task: DotNetCoreCLI@2
displayName: 'DotNet Build Projects'
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: --configuration $(buildConfiguration)
- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests'
inputs:
command: 'test'
projects: '**/ProjectName.Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/'
publishTestResults: true
我做错了什么?
【问题讨论】:
标签: azure-devops azure-pipelines azure-pipelines-yaml azure-pipelines-tasks