Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Mark Allott 2 posts 72 karma points
    Apr 22, 2021 @ 11:26
    Mark Allott

    Deployment problems using an Azure pipeline

    Hi Umbracians!

    I'm using Umbraco for the first time and have a deployment / packaging problem on my Azure pipeline and was hoping someone out there might have a few ideas on how I might resolve the issue... Apologies in advance as this quite long!

    First, a little background: I have a solution, in which I have 3 projects; 2 are class libraries that are used by the main Umbraco project. All references for Umbraco (in this case v8.12) are brought in using NuGet packages. Everything builds and runs perfectly on my local development machine, but when I attempt to deploy the solution from an Azure pipeline, I find that I'm missing some rather large chunks of Umbraco which are very much critical to the deployment (like the entire "Umbraco" folder!)

    Within source control for the solution, I've deliberately excluded the contents of the "umbraco" folder from the Umbraco project, as I know that this folder and its contents are part of the NuGet package itself and the whole reason for me using the packages is to stop me including huge chunks of code that will be recreated as part of the NuGet restore step in the build process - and that bit works exactly as I expected within the Azure pipeline build.

    For those with me so far, the VS Build step I have in my pipeline uses the following parameters:

    /p:OutDir="$(Build.ArtifactStagingDirectory)\$(BuildConfiguration)" /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:DeployTarget=Package /p:PackageRoot="$(Build.ArtifactStagingDirectory)\package"

    After the build completes successfully, I find that the "umbraco" folder is correctly regenerated in the expected location for the source (i.e. the $(Build.SourcesDirectory)\UmbSolution\UmbProject\umbraco\**\* folders) - so far so good. However, when I check the package temporary staging area, I find that the umbraco folder is missing!! All output from the build process gets placed into the following location (as per the OutDir parameter for MSBuild): $(Build.ArtifactStagingDirectory)\$(BuildConfiguration)\_PublishedWebsites\UmbProject - under that base folder, I see the following folders:

    \bin \config \css \Media \scripts \vendor \Views

    Obviously, what's not listed is the "Umbraco" folder - and that's pretty important in getting everything to work!

    Digging a lot deeper, I started looking at the various "target" files being used for the build process and seem to have spotted where things have gone awry and it does explain why the "umbraco" folder doesn't get copied to the staging area. Skipping the many thousands of lines of log output related to the build, the process follows these process targets:


    The problem manifests itself due to the order in which the targets are being applied - in this case, the CopyUmbracoFilesToWebRoot step executes after the _CopyWebApplicationLegacy step has taken place, resulting in the "umbraco" folder being copied from the package area and into the build area after the built solution has already been copied out to the packaging staging area.

    My question is (and apologies for it taking this long!): how do I go about making the build process work as I want it to and include the "umbraco" folder from the NuGet package as part of the Azure pipeline build process?

    My own "idea" is to include a separate step in the build pipeline that goes into the staging area and copies that missing "umbraco" folder into the packaging staging area - but that feels a bit clunky. I firmly believe there's a more elegant solution to be had, but right now, I can't see it.

    Many thanks!

  • Ruby Con 7 posts 98 karma points
    Jun 02, 2021 @ 22:15
    Ruby Con

    We've run into this same issue - was wondering if you came up with a solution?


  • Anton Oosthuizen 206 posts 486 karma points
    Feb 04, 2022 @ 07:22
    Anton Oosthuizen

    I am experiencing the same problem. Have you found a solution ?

  • Anton Oosthuizen 206 posts 486 karma points
    Feb 04, 2022 @ 07:50
    Anton Oosthuizen

    To answer my own question

    I think the behavior is correct not copying files that aren't included in the solution.

    To fix add another step to copy

    - task: CopyFiles@2
      displayName: 'Copy Files to: $(build.artifactStagingDirectory)'
        Contents: |
        TargetFolder: '$(build.artifactStagingDirectory)'

    Then add TWO release steps

    - task: AzureRmWebAppDeployment@4
      displayName: 'Deploy Azure App Service'
        azureSubscription: '$(Parameters.ConnectedServiceName)'
        appType: '$(Parameters.WebAppKind)'
        WebAppName: '$(Parameters.WebAppName)'

    - task: AzureRmWebAppDeployment@4
      displayName: 'Azure App Service Deploy Usync and umbraco'
        azureSubscription: 'Subscription (******-********-******)'
        WebAppName: **********Staging
        packageForLinux: '$(System.DefaultWorkingDirectory)/********-Staging/drop/****.***.Web'
        ScriptType: 'Inline Script'
      continueOnError: true
  • Mark Allott 2 posts 72 karma points
    Feb 04, 2022 @ 11:30
    Mark Allott

    Hi Anton,

    I'm not sure the statement that the behaviour it is exhibiting is correct - my initial investigation shows that the build steps are executing in the wrong order which results in the umbraco folder not getting placed into the staging area until after the build process step called _CopyWebApplicationLegacy has already run, which then results in the problems we are seeing - i.e. no umbraco folder in the build output (I've verified this by adding a PowerShell script that scans the build folders and dumps the results to the log output after each step). The Umbraco NuGet package includes the UmbracoCms.props and UmbracoCms.targets files which are getting included in the build process. These describe and correctly include the step called AddUmbracoFilesToOutput, adding the App_Browsers, App_Code, App_Plugins, data and umbraco folders (plus a few other folders, etc.) However, due to the order of execution for the targets during build, they aren't being included correctly :(

    Like you, the solution I found that works is to create an extra step in the build process that physically takes the umbraco folder that's present in the build area after the build has completed and then copy it to the staging area for further processing (in my case, zipping the results prior to creating the release artifact).

    My build process uses some pipeline variables:

    SolutionName => name of the solution's root folder - e.g. UmbracoSite1

    PublishedPath => $(Build.ArtifactStagingDirectory)/$(BuildConfiguration)/_PublishedWebsites/$(UmbracoProject)

    UmbracoName => Umbraco

    UmbracoProject => $(SolutionName).$(UmbracoName)

    I've then used the "Copy Files v2" task, using the variables above:

    - task: CopyFiles@2
      displayName: 'Copy Umbraco Folder to staging'
        SourceFolder: 'src/$(SolutionName)/$(UmbracoProject)/$(UmbracoName)'
        TargetFolder: '$(PublishedPath)/$(UmbracoName)'
        OverWrite: true

    One other potential solution is to manually edit the csproj file and tell VisualStudio that the umbraco folder and its contents are included in the project:

        <Folder Include="umbraco\" />

    Or, use the Content method:

        <Content Include="umbraco\*" />

    However, I've not tried that myself. If you do, then I'd also suggest you add an entry for that folder into a .gitignore to ensure that VS doesn't keep insisting on trying to add all that content into the project's repo!

  • Anton Oosthuizen 206 posts 486 karma points
    Feb 07, 2022 @ 06:05
    Anton Oosthuizen

    Hi Mark,

    Yeah you are right , my mind was going towards maybe it was intentional to give control over if the folder gets packaged, I did not take a deep dive.

    Busy investigating, Keep you posted...

Please Sign in or register to post replies

Write your reply to: