Copied to clipboard

Flag this post as spam?

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


  • Paul de Quant 403 posts 1518 karma points
    Jul 22, 2020 @ 11:26
    Paul de Quant
    0

    Azure DevOps pipeline to change Client Dependency number

    Hi All,

    Does any one know of a way to automatically adjust the client dependency number when you do a deploy to azure app service. We're having to do this manually at the moment and just wondering if there's an easier way to do this? We have a Azure Devops pipeline in place, where we amend the web.config, but as the clientdependency.config file is external, we're not sure how to change this as part of the deployment process.

    Thanks

  • Tom Madden 252 posts 454 karma points MVP 3x c-trib
    Jul 22, 2020 @ 11:53
    Tom Madden
    0

    I think you can transform any config file in azure devops, not just web.config, using a File Transform Task

    https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic

    I've not done this personally, but it looks like this would be the starting point

    hth

    t

  • Kevin Jump 2145 posts 13579 karma points MVP 6x c-trib
    Jul 22, 2020 @ 12:16
    Kevin Jump
    4

    I use the parameters.xml file method (mainly because i am often substituting other things too.)

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/web-deployment-in-the-enterprise/configuring-parameters-for-web-package-deployment

    In root of site solution i have a parameters.xml file.

    the following snippet for the clientDependency version :

    <parameter name="ClientDependency.Version"
             description="Change the ClientDependency Version"
             defaultValue="#{ClientDependency.Version}#"
             tags="">
    
        <parameterEntry kind="XmlFile"
                    scope="ClientDependency\.config$"
                    match="/clientDependency/@version" />
    </parameter>
    

    When your build Step builds the site it should include a SetParameters.xml file in the artifact zip file.

    On your release step, I use the 'replace tokens' task. ( https://github.com/qetza/vsts-replacetokens-task#readme ) to replace the token values in my parameters file.

    So the step looks like this :

    enter image description here

    This means when the azure deploy step runs those variables are replaced in the configured files.

    for this example - in the parameters.xml I have called my variable ClientDependency.Version so now on my release setup I can replace this with something with something like a deployment id - so i know its always different each release.

    enter image description here

    I use : $(Build.BuildID)$(Release.DeploymentID)0

    So for the build id and release id are smudged together and an extra 0 is added (so if you really have to you can manually increment the number of the server and know it won't clash with a later release)

    build 12 release 41 would set the value to 12410

    This might not be the simplest method for just client dependency but it opens up the ability to change things all over the place from one file and variables in your pipeline.

    And this is a release time not build time substitution meaning one build can go to different environments.

  • MaartenVissers 32 posts 148 karma points
    Dec 23, 2020 @ 10:30
    MaartenVissers
    0

    Thanks for sharing your solution.

    I'm stuck at this line:

    When your build Step builds the site it should include a SetParameters.xml file in the artifact zip file.

    What (and how) exactly am I supposed to do here?

    Thanks in advance!

  • M 39 posts 261 karma points
    Jul 12, 2021 @ 11:57
    M
    0

    Excellent description, thanks!

    One extra step I had to do is point the deploy to the SetParameters.xml file (Step 4 here http://andrew.lansdowne.me/2016/12/15/using-environment-variables-for-configuration-with-vsts-build-and-release/ although the screenshots are a little out of date)

    @MaartenVissers, the SetParameters.xml file is auto-generated during the build.

  • Paul de Quant 403 posts 1518 karma points
    Jul 22, 2020 @ 12:19
    Paul de Quant
    0

    Thanks for responding guys, I'll have a read through and see if this sorts our issue.

    Thanks again for the help.

    Cheers

    Paul

Please Sign in or register to post replies

Write your reply to:

Draft