SitecorePowerShell / Console

Sitecore PowerShell Extensions
https://doc.sitecorepowershell.com/
Other
114 stars 70 forks source link

Question: Create Sitecore Package from XML files located inside a folder #506

Closed kondapallysrknth closed 8 years ago

kondapallysrknth commented 9 years ago

Hello there,

I am trying to figure out a requirement on my end where we have a list of Sitecore XML files created using package designer located inside a folder(Assume this is Developer environment). During deployment, we want to go through each of the XML files and create Sitecore Installation Packages. Once we have them created, we have to install each of those packages in the Production environments . Is there a way to do this in few steps using this module?

Thanks in advance and would like to hear back suggestions as well based on my requirement.

Regards, SK

michaellwest commented 9 years ago

I think this is a great idea, but I would recommend a slight modification to your approach.

Have a look at the script located here: /sitecore/system/Modules/PowerShell/Script Library/Platform/Development/PowerShell Extensions Maintenance/Prepare Console Distribution

This is how we bundle up our changes into a package. Rather than start with a dependency on the Package Designer, go ahead and write a script that will do it for you.

Next you'll want to figure out how to best get those packages to your server. My guess is that you will have a package of items/files deployed to CM and a separate file-only zip for the CD. You can use the SPE Remoting module described here to handle the installation process from your CI server. Once the package or zip is on the server you can use SPE Remoting to handle the files or installation.

Let us know if this is a direction you consider a good fit for your environment.

AdamNaj commented 9 years ago

I think what you're looking for is the set of cmdlets using the Package noun

To get all package definition files located in the Sitecore package folder as objects that you can work with you can use something like:

$packages = Get-ChildItem "$SitecorePackageFolder" -Filter *.xml | 
    % { Get-Package -Path "$SitecorePackageFolder\$($_.Name)" }

once you have those objects you can manipulate those to add further sources, but you can also just turn them into ready-to-distribute zip packages by doing the following:

$packageNames = @() + (Get-ChildItem "$SitecorePackageFolder" -Filter *.xml | % { $_.Name })

foreach($packageName in $packageNames) {
    $package = Get-Package -Path "$SitecorePackageFolder\$packageName"
    $packageNameNoExt = [System.IO.Path]::GetFileNameWithoutExtension($packageName)
    Export-Package -Path "$SitecorePackageFolder\$packageNameNoExt.zip" -Project $package -Zip
}

I hope that's what you intended to do in the first place.

kondapallysrknth commented 9 years ago

Thanks for the prompt response Michael and Adam.

I will be trying out by installing the module and follow the approach shown by Adam above. Will keep you posted if I have any further questions.

Regards, Srikanth

kondapallysrknth commented 9 years ago

Hi there,

I have installed the Sitecore PowerShell Extensions-3.3 for Sitecore 7 and was able to use the script sent by Adam to generate the packages(.zip) using the xml files located under Sitecore Package Folder(These are created by multiple developers).

I went through the User Guide and Documentation and wanted to get more details about SPE Remoting module. Is this a different module compared to what I have installed?

Additional Question(s) Can we build a script to run it during deployment through Octopus by calling a web API so that we can migrate the packages created in one environment(Development) to other(Testing environment) followed by installing and publishing the packages

michaellwest commented 9 years ago

To your first question, the SPE Remoting module is designed for use outside of Sitecore. It's actually a Windows PowerShell script module that connects to an SPE webservice. Through this method you can run custom scripts that are either on you local/CI machine or run scripts stored inside a script library stored within SPE.

You can use the previous approach as well as save scripts in an SPE script library under the Web API integration point. You can then access the appropriate URL to execute the script. The book should have videos that cover both scenarios.