Skip to content

Instantly share code, notes, and snippets.


John Rappel jraps20

View GitHub Profile
jraps20 / build.yml
Created Aug 12, 2019
Cache NuGet Packages with Cache Task in Azure DevOps YAML
View build.yml
- powershell: | # generates a hash of all packages.config and saves each on a single line on 'hash.txt'
Get-FileHash -Algorithm MD5 -Path (Get-ChildItem packages.config -Recurse) >> hash.txt
Write-Host "Hash File saved to $pwd\hash.txt"
workingDirectory: src
displayName: 'Calculate and save packages.config hash'
- task: CacheBeta@0 # speed up builds by caching packages folder
key: nuget|1|$(Agent.OS)|$(Build.SourcesDirectory)\src\hash.txt # hash map generated in previous step
path: $(Build.SourcesDirectory)\src\packages
View Example.cs
var localCopyrightSettingsItem = Context.Items.Get(MultisiteConstants.LocalCopyrightSettingsItem);
View ItemsLookup.cs
namespace MyProject.Pipelines
public class ItemsLookup : HttpRequestProcessor
public override void Process(HttpRequestArgs args)
// Shared Data Folder
Context.Items.SetLazy(MultisiteConstants.SharedDataFolderItem, () =>
Context.Database.GetItem(new ID(MultisiteConstants.SharedDataFolderId))
View ItemsContextExtensions.cs
namespace MyProject.Extensions
public static class ItemsContextExtensions
public static Item Get(this ItemsContext source, string identifier)
if (string.IsNullOrWhiteSpace(identifier))
throw new Exception("Must set identifier for getting global property");
var dictionary = source as IDictionary;
View zItemsLookup.xml
<?xml version="1.0"?>
<configuration xmlns:patch="">
<processor type="MyProject.Pipelines.ItemsLookup, MyProject" resolve="true" patch:after="*[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']" />
jraps20 / RemoteDelete.config
Created Jul 3, 2018
Delete Sitecore items from remote databases when delete occurs in master.
View RemoteDelete.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="">
<event name="item:deleting">
<handler type="MyProject.MyNamespace.RemoteDeleteHandler, MyProject" method="OnItemDeleting" />
View ExampleSiteCronJob.cs
using Quartz;
public class TestJob : SiteCronBase
protected override void Run(IJobExecutionContext context)
WriteLogLine(context, "Starting SiteCron job");
// core functionality lives here
// obtain databases with Factory.GetDatabase("master"); for example
View SiteCronBase.cs
using Quartz;
using Sitecron.SitecronSettings;
public abstract class SiteCronBase : IJob
private DateTime _lastLogEntry;
protected abstract void Run(IJobExecutionContext args);
public void Execute(IJobExecutionContext context)
View Call Pipeline.cs
var pipelineItem = Factory.GetDatabase("master").GetItem("/sitecore/content/My Pipeline");
var pipelineArgs = new PipelineArgs();
Pipeline.Start(pipelineItem, pipelineArgs);
var customData = pipelineArgs.CustomData;
View Step1.cs
public class Step1
public void Process(PipelineArgs args)
var processorItem = args.ProcessorItem;
var customField = processorItem.InnerItem["Custom Referenced Item"];
var referencedItem = processorItem.InnerItem.Database.GetItem(new ID(customField));