0

I am deploying a Blazor WASM (with ASP.NET server backing) using AZURE pipelines. I started out with .NET Core 3.1 and moved recently to .NET 5. I needed a Quick fix to get a version up and running why I deployed from visual studio on my desktop instead of through azure pipeline. After that no changes in my blazor pages (razor/razor.cs files) do go through to the published version when I use azure pipelines. Changes in static files (i.e. index.html) do go through. The files are however updated (dll's have correct timestamp). I have tried just adding some simple text as well as larger changes in my razor files but it does not affect the published version. When I change things in index.html I do see the changes in debug panel (F12 -> Network -> https://MyWebbApp.azurewebsites.net/ -> preview). Everything builds and publishes without errors. Here is my build pipeline:

trigger:
- master

pool:
  name: 'Default_Win2019'

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

steps:
- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '5.x'

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 5.0.103'
  inputs:
    packageType: 'sdk'
    version: '5.0.103'
    includePreviewVersions: true

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '$(solution)'
    feedsToUse: 'select'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false
  continueOnError: true
  
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

And the release pipeline:

steps:
- task: AzureRmWebAppDeployment@4
  displayName: 'Deploy Azure App Service'
  inputs:
    azureSubscription: '$(Parameters.ConnectedServiceName)'
    appType: '$(Parameters.WebAppKind)'
    WebAppName: '$(Parameters.WebAppName)'
    enableCustomDeployment: true
    ExcludeFilesFromAppDataFlag: false

I have tried to remove everything under C:\home\site\wwwroot using kudu, but that only resulted in nonfunctional webapp after redeploy. Using visual studio on the desktop is the only thing that works now. My understanding of the pipeline is limited and any comments on this is gratefully received. (it is after some time stitched together with help of others and pieces picked up here at SO) When I follow the deployed (azure pipeline) artifact back to the commit I can see the changes are in the code. If anyone know how to deal with this...?

Erik Thysell
  • 1,160
  • 1
  • 14
  • 31
  • Do you use release pipeline after the build pipeline? If yes, could you please provide a sample of your release pipeline? Also, I was wondering whether there is the same question if you deploy a **new** Blazor WASM with Azure DevOps using the same code? – Jane Ma-MSFT Feb 22 '21 at 10:00

1 Answers1

0

I finally managed to solve it. There were a couple of issues (at least).

  1. The build agent was on a version prior to 2.181 (which according to this is the first that is compatible with .NET 5)
  2. I had to use DotnetCoreCLI to build and publish. My build pipeline now looks like this (with the help of this question):
    trigger:
    - master
    
    pool:
      name: 'Default_Win2019'
    
    variables:
      project: '**/MyWebbApp.Server.csproj'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'
    
    steps:
    
    - task: UseDotNet@2
      displayName: 'Use .NET Core sdk 5.0.x'
      inputs:
        packageType: 'sdk'
        version: '5.0.x'
        includePreviewVersions: true
    
    - task: DotNetCoreCLI@2
      displayName: 'dotnet restore'
      inputs:
        command: restore
        projects: '**/*.csproj'
    
    - task: DotNetCoreCLI@2
      inputs:
        command: 'build'
        projects: '$(project)'
        arguments: '--configuration $(BuildConfiguration)'
    
    - task: VSTest@2
      inputs:
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
    
    - task: PublishSymbols@2
      displayName: 'Publish symbols path'
      inputs:
        SearchPattern: '**\bin\**\*.pdb'
        PublishSymbols: false
      continueOnError: true
    
    - task: DotNetCoreCLI@2
      displayName: Publish
      inputs:
        command: 'publish'
        publishWebProjects: false
        projects: '$(project)'
        arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
    
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: drop'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'

Erik Thysell
  • 1,160
  • 1
  • 14
  • 31