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!

How to add ProGetAssemblyAttribute to an extension?



  • Hi,

    I'm trying to get an AfterPush Package Adapter running. I've created a MyExtension class, inherited from AfterPushPackageAdapterBase. The class has the ProGetComponentProperties attribute and I also added the following line to AssemblyInfo.cs:

    [assembly: ProGetAssembly]

    The class overrides the Adapt method since I guess, that's the entrypoint for the extension. I pack everything in a zip, rename it to MyExtension.progetx and push it into the configured extensions folder on the proget server. When I restart the service, I get the following error:

    One or more errors occurred while loading this extension.
    
    Assembly MyExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    is missing the required attribute ProGetAssemblyAttribute.
    

    Did I miss something? Is there a sample for an AfterPush Adapter. Since it's only a few lines of code (i guess), it would be really cool if you could provide these kind of samples to the world. Would be really really helpful since the ProGet SDK Documentation is more a listing of class- and method names but not really a documentation.

    Best Regards,

    Joachim

    Product: ProGet
    Version: 3.8.6



  • Ok, got the problem with the Attribute. I've used the ProGet SDK from nuget.org and that seems to be outdated. I removed it and used the appropriate DLLs from my actual ProGet installation and the Extensions is recognized without an error.

    But! i still get nothing working my Extension looks like that:

    public class MyExtension : AfterPushPackageAdapterBase
    {
        public override PackageContainer Adapt(PackageContainer item)
        {
            File.WriteAllText(@"C:\testout.txt", item.Metadata.Id + " - " + item.Metadata.Version.OriginalString);
            return item;
        }
        
    }
    

    I expect to see the testout.txt on c:\ as soon as I upload a nuget package to the server but nothing happens. The package is uploaded but no testout.txt is created :-(

    What's wrong?

    Best Regards,

    Joachim Roppert



  • Did you add the adapter configuration XML to the feed? You should be able to set that on the Manage Feed page.



  • Yes and it's listed under "Feed Adapters" as "MyExtension (Push)". I test it using the Upload- Button in the Web UI, not a push- Operation using nuget.exe. I assume the upload should also trigger my extension. Right?



  • Currently it only works via the /nuget endpoint and not via the web UI. I'll put in a note to add that functionality though - it should work in both cases.



  • Hm unfortunately, I tried pushing a package using nuget.exe push but still no sign of life from my extension. Is it correct to simply override the Adapt method or do I have to do something else? Isn't there a working sample available that I can use as a starting point?





  • Got it working. Thanks, that helps a lot!


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation