Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

ProGet: include a Universal Package feed in a nuget config file?



  • We are in the process of adopting ProGet as our one-stop-shop for internal package management. We are using it as a build artifact store, and we pull from it to do deploys. Now, i am onboarding an app that consumes another app's build as part of its build. The consumee is already published as a Universal Package to ProGet.

    I'm wondering if there's a way to add this package as-is to the consumer's packages.config file, so that it gets pulled down by a nuget restore? This would avoid having to build a separate step that pulls the package to consume.


  • inedo-engineer

    Hi @mcascone, I'm afraid it's not possible.

    nuget or dotnet nuget tools only understand the NuGet Package Format, and the NuGet API, so there's no way for the tools to use different formats or different APIs...



  • Thanks for the reply, that's pretty much what i figured, but it's always worth asking.

    What i built at least as a first effort is: add an optional consumes parameter to the pipeline/Jenkinsfile, specifying the packages(s) to pull from ProGet as feedname:groupname:packagename:

    • Jenkinsfile:
    library 'my-shared-library'
    
    sharedPipeline {
    // ...
      consumes = 'myFeed:myGroup:myPackage'
    // ...
    }
    
    
    • In the file that manages restoring prior to jenkins builds:
    // if this repo consumes another package(s) from ProGet, get it here.
    // The required syntax of 'consumes' is: 'proget_feedName:groupName:packageName'
    // comma separate multiple packages
      if(env.consumes) {
        // create a [list] to support multiple packages
        env.consumes.split(/\s*,\s*/).each {
          downloadFromProget(it)
        }
      }
    
    • downloadFromProget.groovy:
    // common defaults
    // Note that downloadProgetPackage seems to require a literal path - hence the {WORKSPACE}
      dlFolder  = "${WORKSPACE}/${env.packageDownloadDir}"
      ver = 'Latest'
    
    //... a bunch of other custom patterns to download specific stuff ...
    
    // packages to consume from ProGet need to come in as feedName:groupName:packageName
    // check that it matches that syntax with regex (.+ means 1 or more of any char)
        else if (app ==~ /.+:.+:.+/)
          pkgMap  = app.split(':')
          fdName  = pkgMap[0]
          gpName  = pkgMap[1]
          pkgName = pkgMap[2]
          expFolder = "${WORKSPACE}/${pkgName}"
        }
    
    // then download
    
    downloadProgetPackage downloadFolder: dlFolder, 
        downloadFormat: 'zip',
        feedName:       fdName,
        groupName:      gpName,
        packageName:    pkgName,
        version:        ver
    

    The last thing i've yet to do is change all my package pulling to use the unpack mode of downloading from proget, so i can remove the unzipping steps on my side.


  • inedo-engineer

    That's great thanks for sharing!! We want to build a content backlog, and will add this to it -- at least a way to download from jenkins in this manner. nice find :)



  • I just noticed this in the ProGet Jenkins plugin docs:

    dependencies (optional)

    An array of strings, each consisting of a package identification string; this string is formatted as follows:

    �group�:�package-name�

    �group�:�package-name�:�version�

    When the version is not specified, the latest is used.

    Type: String

    This is for the upload parameters. I don't remember seeing this before, is this new, and/or related to my consumes pattern?


  • inedo-engineer

    @mcascone I don't think it's new, but it's just used to specify the dependencies field in the manifest file; I'm thinking, perhaps, it might be similar/identical to the consumes field you added?

    https://docs.inedo.com/docs/upack-universal-packages-manifest

    The only thing Inedo tools use it for today is just displaying information in ProGet, on the dependencies tab. That may / may not be helpful.


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation