ClubberLang
ClubberLang

Reputation: 1898

Azure Dev Ops : build .NET as Release

I have the following azure pipeline, but it seems that it is built as a debug version. I know this because there are some "#if DEBUG" in the code and it is active also on the app built with the pipeline.

I'm searching for a way to debug this and also some documentation too.

If someone has an idea to debug or better fix it, you're welcome.

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  solution: '**/MyProd.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: Npm@1
  inputs:
    command: 'install'
    workingDir: 'src/MyCorp.Core.Blazor'

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '$(solution)'
    arguments: ''

- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    projects: '$(solution)'

- task: Docker@2
  inputs:
    containerRegistry: 'myprod'
    repository: 'myuser/myprod/myprod.httpapi'
    command: 'buildAndPush'
    Dockerfile: 'src/MyProd.HttpApi.Host/Dockerfile'
    buildContext: '$(Build.SourcesDirectory)'
    tags: '1.1.$(Build.BuildId)'

- task: Docker@2
  inputs:
    containerRegistry: 'myprod'
    repository: 'myuser/myprod/myprod.identityserver'
    command: 'buildAndPush'
    Dockerfile: 'src/MyProd.IdentityServer.Host/Dockerfile'
    buildContext: '$(Build.SourcesDirectory)'
    tags: '1.1.$(Build.BuildId)'

- task: Docker@2
  inputs:
    containerRegistry: 'myprod'
    repository: 'myuser/myprod/myprod.Web'
    command: 'buildAndPush'
    Dockerfile: 'src/MyProd.Web/Dockerfile'
    buildContext: '$(Build.SourcesDirectory)'
    tags: '1.1.$(Build.BuildId)'

- task: Docker@2
  inputs:
    containerRegistry: 'myprod'
    repository: 'myuser/myprod/myprod.jobs'
    command: 'buildAndPush'
    Dockerfile: 'src/MyProd.Jobs.Host/Dockerfile'
    buildContext: '$(Build.SourcesDirectory)'
    tags: '1.1.$(Build.BuildId)'
    
- task: Docker@2
  inputs:
    containerRegistry: 'myprod'
    repository: 'myuser/myprod/myprod.imageai.jobs'
    command: 'buildAndPush'
    Dockerfile: 'src/MyProd.Jobs.ImageAI.Host/Dockerfile'
    buildContext: '$(Build.SourcesDirectory)'
    tags: '1.1.$(Build.BuildId)'

- task: Docker@2
  inputs:
    containerRegistry: 'myprod'
    repository: 'myuser/myprod/myprod.dbmigrator'
    command: 'buildAndPush'
    Dockerfile: 'src/MyProd.DbMigrator/Dockerfile'
    buildContext: '$(Build.SourcesDirectory)'
    tags: '1.1.$(Build.BuildId)'

Upvotes: 1

Views: 236

Answers (1)

Vito Liu
Vito Liu

Reputation: 8298

Do you mean that you configure the buildConfiguration is release but it run the build via debug, right?

Check the Task .NET Core build, we need to add argument --configuration $(buildConfiguration), then it will build .NET as Release instead of debug

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '$(solution)'
    arguments: '--configuration $(buildConfiguration)'

Upvotes: 2

Related Questions