Azure / Azure/azure-functions-openapi-extension

OpenAPI UI dll load failure from release pipeline only

Open
#196 6 comments 0 reactions 0 assignees View on GitHub
Needs: Triage (Functions)
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Got a function app which is being deployed to an Azure serverless deployment. I have a Function App "Functions" project and corresponding "Functions.Tests" unit test project. When doing a zip deploy from Visual Studio, everything is working correctly. When trying to go thru Azure Devops build and release pipelines, I am getting a `Could not load file or assembly 'D:\home\site\wwwroot\bin\Functions.Tests.dll'. The system cannot find the file specified.` error. There is nothing special as far as the pipeline script that is standing out, and a little surprised the OpenAPI UI would be looking for the unit test project at all. Below are the yamls
build.yaml
```
trigger:
branches:
include:
- main

pool:
vmImage: "windows-latest"

variables:
solution: "**.*.sln"
buildPlatform: "x64"
buildConfiguration: "Release"

name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

stages:
- stage: Function_Service
displayName: 'Function App Build'
jobs:
- job:
steps:
- template: templates/functions-template.yml
```
templates/functions-template.yml
```
steps:
- task: VersionDotNetCoreAssemblies@2
inputs:
Path: "$(Build.SourcesDirectory)"
VersionNumber: "$(Build.BuildNumber)"
Injectversion: False
VersionRegex: '\d+\.\d+\.\d+\.\d+'
FilenamePattern: ".csproj"
OutputVersion: "OutputedVersion"

- task: DotNetCoreCLI@2
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests VS Test Coverage'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) --collect "Code Coverage"'

- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests Cobertura Report Support'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) --collect "XPlat Code Coverage"'

- task: DotNetCoreCLI@2
displayName: 'Install ReportGenerator Tool'
inputs:
command: custom
custom: tool
arguments: 'install --global dotnet-reportgenerator-globaltool --version 4.8.11'

- script: 'reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"'
displayName: 'Generate Code Coverage Report'

- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml'
failIfCoverageEmpty: false

- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: False
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'Functions-Artifact'
```
The release pipeline is a single task taking the zip files from `$(System.DefaultWorkingDirectory)/_Functions-Artifact/Functions-solution/*.zip` to deploy the service.

Contributor guide

Open the contributing guide

Research direction

Start with build.yaml and templates/functions-template.yml, then inspect the ZIP produced by the dotnet publish step and compare it with the working Visual Studio deployment. Check why Functions.Tests.dll is included or expected in the deployed artifact and identify the pipeline change needed for the OpenAPI UI to load without that test assembly. Verify the result using the Azure DevOps release path described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, openapi
Domain
api, ci-cd, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.