It definitely can be done programmatically, (as that's how Umbraco itself does it). I haven't tried it myself, but took a quick look at the API - it looks like you'll need to use the "umbraco.cms.businesslogic.packager.CreatedPackage" class.
Create a new instance of the "CreatedPackage" object, the Data property is a "PackageInstance" - there you can set all the files, macros, etc. Then calling the "Publish()" method should create the zip file.
So far, so good - but I want / need to add an entry to createdPackages.config so that the created package appears in the Umbraco admin. However, I cannot (yet) see how to do it.
I'm assuming it's not a manual process!! Anyone have any ideas?
I believe that "umbraco.cms.businesslogic.packager.CreatedPackage.MakeNew(string name)" will create an entry in the "createdPackages.config" file.
Not sure how familiar you are with the Umbraco core - might be worth spending a little time looking over the APIs in Reflector (or getting the source from CodePlex)? Its definitely possible to do what you want programmatically - as that's what Umbraco itself is doing when creating/installing packages.
Create a package using C#
Is it possible to create an Umbraco Package using C# rather than using the package builder within Umbraco?
This would be for Umbraco 4.5.2 using SQL Server.
Hi Gordon,
You can do it as part of your build process, here's a blog post on Automating Umbraco Package Creation using MS Build.
HTH,
Hendy
Hi Hendy, what I am trying to do is automate the package creation from within Umbraco itself rather than a VS project.
I will take a look at the above link but I was kind of hoping that I could tap into the inbuilt Umbraco package creator...
Hi Gordon,
It definitely can be done programmatically, (as that's how Umbraco itself does it). I haven't tried it myself, but took a quick look at the API - it looks like you'll need to use the "umbraco.cms.businesslogic.packager.CreatedPackage" class.
Create a new instance of the "CreatedPackage" object, the Data property is a "PackageInstance" - there you can set all the files, macros, etc. Then calling the "Publish()" method should create the zip file.
Let us know how you get on.
Cheers, Lee.
So far, so good - but I want / need to add an entry to createdPackages.config so that the created package appears in the Umbraco admin. However, I cannot (yet) see how to do it.
I'm assuming it's not a manual process!! Anyone have any ideas?
Hi Gordon,
I believe that "umbraco.cms.businesslogic.packager.CreatedPackage.MakeNew(string name)" will create an entry in the "createdPackages.config" file.
Not sure how familiar you are with the Umbraco core - might be worth spending a little time looking over the APIs in Reflector (or getting the source from CodePlex)? Its definitely possible to do what you want programmatically - as that's what Umbraco itself is doing when creating/installing packages.
Best of luck, Lee.
Yes, I had seen "MakeNew" in the Umbraco source but it didn't appear with Intellisense!
Just tried it and it added it to the Umbraco UI but didn't fill in the other fields - more investigation needed then :-)
OK, I have a basic creation working - for the selected node and its children, including the node template and document type.
What I need to include now is any related stylesheets, macros, dictionary items and data types - oh yes and images!!?
Any ideas?
Hi gordon, can you explain me in outline how did you do to have a basic creation working ?
Thanks
How I can Add my course in to Umbraco?
is working on a reply...