.net core 当配置参数设置为“调试”时,为什么生成的dotnet core程序集会得到优化

.net core 当配置参数设置为“调试”时,为什么生成的dotnet core程序集会得到优化,.net-core,azure-devops,msbuild,yaml,azure-pipelines,.net Core,Azure Devops,Msbuild,Yaml,Azure Pipelines,我有一个dotnet核心持久功能应用程序,由Azure DevOps构建管道构建。此文件的yaml文件将“Debug”指定为配置参数,如下面显示的构建日志摘录所示: [command]"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\Interfaces.Avaloq.Presentation.AzureFunctions\Interfaces.Avaloq.Presentation.AzureFunctions.csproj --confi

我有一个dotnet核心持久功能应用程序,由Azure DevOps构建管道构建。此文件的yaml文件将“Debug”指定为配置参数,如下面显示的构建日志摘录所示:

[command]"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\Interfaces.Avaloq.Presentation.AzureFunctions\Interfaces.Avaloq.Presentation.AzureFunctions.csproj --configuration Debug
但是,生成的程序集是“优化”的,这会阻止我附加调试器。我知道这一点,因为我下载了由构建创建的zip,然后添加了对程序集的引用,如下所示:

正在生成的csproj文件如下所示:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    <LangVersion>8.0</LangVersion>
    <NullableContextOptions>enable</NullableContextOptions>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Base.Core.SharedKernel" Version="1.0.0.23885" />
    <PackageReference Include="FluentValidation.AspNetCore" Version="8.5.0" />
    <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.3" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.1.1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.8" />
    <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.0.0" />
    <PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Interfaces.Avaloq.Application\Interfaces.Avaloq.Application.csproj" />
    <ProjectReference Include="..\Interfaces.Avaloq.Common\Interfaces.Avaloq.Common.csproj" />
    <ProjectReference Include="..\Interfaces.Avaloq.Infrastructure\Interfaces.Avaloq.Infrastructure.csproj" />
    <ProjectReference Include="..\Interfaces.Avaloq.Persistence\Interfaces.Avaloq.Persistence.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

你知道为什么程序集被构建为优化的吗?

你在yaml中为发布步骤使用了
--configuration Release
,我想我看到了BuildConfiguration变量的一个案例问题。正在检查。。。
trigger:
- develop
stages:
- stage: Build
  jobs:
  - job: Build

    pool:
      name: Hosted Windows 2019 with VS2019
      demands:
      - msbuild
      - visualstudio

    variables:
      solution: '**/*.sln'
      projects: '**/Interfaces.Avaloq.Presentation.AzureFunctions.csproj'
      testProjects: '**/*[Tt]esting*/*.csproj'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Debug'

    steps:
    - script: |
    - task: DotNetCoreCLI@2
      displayName: Restore
      inputs:
        command: restore
        projects: '$(projects)'
        feedsToUse: config
        nugetConfigPath: nuget.config

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

    - task: AzurePowerShell@4
      inputs:
        azureSubscription: 'Design Subscription (e73cbf58-ae70-454f-89dc-692d3882dbf4)'
        ScriptType: 'InlineScript'
        Inline: |
          Set-Location $env:AGENT_WORKFOLDER
          Get-ChildItem -Recurse
        azurePowerShellVersion: 'LatestVersion'

    - task: DotNetCoreCLI@2
      displayName: Publish
      inputs:
        command: publish
        arguments: '--configuration Release --output $(build.artifactstagingdirectory)'
        projects: '$(projects)'
        publishWebProjects: false
        zipAfterPublish: true

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
      condition: succeededOrFailed()

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: ArmTemplate'
      inputs:
        PathtoPublish: Interfaces.Avaloq.Deployment
        ArtifactName: RGDeploy