Skip to content

Instantly share code, notes, and snippets.

View cassidydotdk's full-sized avatar

Mark Cassidy cassidydotdk

  • Cassidy Consult
  • Kiel, Germany
View GitHub Profile
@cassidydotdk
cassidydotdk / EntryPoint.ps1
Created August 3, 2021 16:01
A replacement for Sitecore's Development.ps1 Docker entrypoint script that does not blow up if you do not volume mount C:\deploy
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[hashtable]$WatchDirectoryParameters
)
# Setup
$ErrorActionPreference = "Stop"
$InformationPreference = "Continue"
$timeFormat = "HH:mm:ss:fff"
@cassidydotdk
cassidydotdk / DockerFile
Created August 1, 2021 09:53
Setting up a Docker based VSTS Agent that can run Docker commands
# escape=`
ARG BUILD_IMAGE
FROM ${BUILD_IMAGE}
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Set-ExecutionPolicy RemoteSigned -Force; Set-ExecutionPolicy Unrestricted -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
RUN choco install docker -y
@cassidydotdk
cassidydotdk / Build.ps1
Last active May 23, 2021 06:01
Complete Build and Publish Script. Will deploy all projects to publishing target, no HPP required.
param(
[Parameter()]
[switch]$NoBuild,
[Parameter()]
[switch]$NoSync,
[Parameter()]
[string]$CmHost="https://habitatstarterkit.local",
[Parameter()]
[string]$SolutionName="HabitatStarterKit.sln",
[Parameter()]
- Create your VM as normal, get Windows installed and so on
- Power the VM down, to "Off" state
- On the HOST pc, execute the following 2 commands from an elevated Powershell prompt
Set-VMProcessor -VMName "Name of your VM" -ExposeVirtualizationExtensions $true
Get-VMNetworkAdapter -VMName "Name of your VM" | Set-VMNetworkAdapter -MacAddressSpoofing On
- Start up the VM again
- Inside the VM, execute the following command from an elevated Powershell prompt
@cassidydotdk
cassidydotdk / Setup Unicorn in Docker.txt
Last active September 27, 2019 19:22
How to configure Unicorn with a volume mapping for your CM server Docker container
How to set up Unicorn in your Docker container
Since all writing to Unicorn files happens inside the container, and the container is now linked to .\unicorn,
all you need to do is ensure that .\unicorn is included under source control.
This gets even better if you use Transparent Sync.
@cassidydotdk
cassidydotdk / Gulpfile.js
Last active July 1, 2019 22:30
Managing Unicorn targetDataStore in Gulp pipeline
var rename = require('gulp-rename');
var replace = require('gulp-replace');
...
gulp.task("B04-Sync-Unicorn",
function(callback) {
console.log("Executing Unicorn Sync");
gulp.src([path.resolve(config.websiteRoot + '/App_Config/Include/zzz/Unicorn.TargetDataStore.config.EDITME')])
@cassidydotdk
cassidydotdk / gulp-config.js
Last active January 31, 2023 15:49
Task to build and publish a .SLN file from gulp using "msbuild" instead of "gulp-msbuild". Version 16.0 for VS2019, use 15.0 for VS2017.
module.exports = function () {
var config = {
websiteRoot: "C:\\inetpub\\wwwroot\\sc911.sc",
sitecoreLibraries: "C:\\inetpub\\wwwroot\\sc911.sc\\bin",
hostName: "http://sc911.sc",
solutionName: "sc911",
buildConfiguration: "Debug",
runCleanBuilds: false,
toolsVersion: "16.0"
}
@cassidydotdk
cassidydotdk / Install-Solr.ps1
Created April 12, 2019 12:23
Install-Solr.ps1
Param(
$installFolder = "c:\solr",
$solrPort = "8721",
$solrHost = "solr",
$solrSSL = $true,
$downloadFolder = "$PSScriptRoot"
)
$solrVersion = "7.2.1"
$solrName = "solr-$solrVersion"
public virtual Tuple<string, string> GetAdaptiveImageUrls(Item item, string imageFieldName, int maxWidth = 300)
{
Assert.IsNotNull(item, nameof(item));
Assert.IsNotNullOrEmpty(imageFieldName, nameof(imageFieldName));
ImageField imageField = item.Fields[imageFieldName];
if (imageField?.MediaItem != null /*&& imageField.MediaItem.Versions.Count > 0*/)
{
string imageUrl = HashingUtils.ProtectAssetUrl(MediaManager.GetMediaUrl(imageField.MediaItem, new MediaUrlOptions {MaxWidth = maxWidth}));
@cassidydotdk
cassidydotdk / gist:519dee612ca4683a18303298a429715c
Created August 15, 2016 12:26
Controller Factory Handling - Sitecore 8.1 and Castle Windsor
using System.Web.Mvc;
using Castle.Windsor;
using Sitecore.Mvc.Controllers;
using Sitecore.Mvc.Pipelines.Loader;
using Sitecore.Pipelines;
using Interfaces.Managers.Windsor;
using ControllerBuilder = System.Web.Mvc.ControllerBuilder;
namespace Website
{