Skip to content

Instantly share code, notes, and snippets.

View vtml's full-sized avatar

Vincent Lui vtml

View GitHub Profile
@vtml
vtml / SomeService.cs
Created March 19, 2019 11:56
Sitecore Super Power Friendly Dependency Injection
public interface ISomeService
{
void Run(IGlassBase glassBase);
}
public class SomeService : ISomeService
{
public Run(IGlassBase glassBase)
{
// do something
@vtml
vtml / ServiceCollectionExtensions.cs
Created March 19, 2019 10:25
Sitecore Super Power Friendly Dependency Injection
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web.Http.Controllers;
using System.Web.Mvc;
using Isobar.Foundation.SitecoreUtilities.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@vtml
vtml / ReflectionExtensions.cs
Last active February 5, 2021 11:07
Sitecore Super Power Friendly Dependency Injection
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
namespace Isobar.Foundation.SitecoreUtilities.Extensions
{
@vtml
vtml / Sitecore.HistoryEngine.config
Created January 11, 2019 11:36
Sitecore 9.x History Engine Configuration
<?xml version="1.0" encoding="utf-8" ?>
<!--
Purpose: This include file enables the History Engine for Sitecore databases.
To enable this include file, rename it to have a ".config" extension.
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
param(
[string] $LastGitCommitId,
[string] $AccessToken,
[string] $AzureDevOpsAccountName,
[string] $TeamProjectId,
[string] $ReleaseDefinitionId
)
if ([string]::IsNullOrEmpty($LastGitCommitId))
{
$hdrs = @{}
@vtml
vtml / Determining Last Successful Build Git Commit Hash
Created October 31, 2018 13:21
TeamCity Build Step to determine last successful build Git Commit ID
######################################################
# Retrieves the last successful build of a TeamCity Project
# Finding the Commit Hash
# http://blogs.lessthandot.com/index.php/uncategorized/access-git-commits-during-a-teamcity-build-using-powershell/
######################################################
function Get-TeamCityLastSuccessfulRun([string] $TeamCityUrl, [string] $TeamCityBuildTypeId, [string] $TeamCityUsername, [string] $TeamCityPassword)
{
$Credentials = "$($TeamCityUsername):$($TeamCityPassword)"
$AuthString = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$Credentials"))
@vtml
vtml / PackageInstaller.ps1
Created October 31, 2018 12:57
Gluing the whole Developer Workstation TDS Install Process together
.".\PackageInstallerFunction.ps1"
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
PackageInstall "Website" $PSScriptRoot "https:\\some.website"
@vtml
vtml / PackageInstallerFunction.ps1
Last active October 31, 2018 12:56
Package Installer
function PackageInstall($WebSiteFolder, $PSScriptRoot, $sitecoreUrl)
{
#build tds projects
& "..\\VS Build Scripts\\DeveloperTdsBuild.bat"
#set package installer paths
$RepoDir = Split-Path $PSScriptRoot -parent
$parentDir = Split-Path $RepoDir -parent
$TDSPackagesFolder = $RepoDir + "\TDSPackages"
$PackageInstallerExePath = $RepoDir + "\TdsPackageInstaller\PackageInstaller.exe"
@vtml
vtml / VS Build Scripts\DeveloperTdsBuild.bat
Created October 31, 2018 12:43
Building a TDS Package on a Developer's workstation
@echo off
:: global parameters
set msbuild="C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
set solution="..\Some.Sitecore.sln"
echo Please enter a Git Commit Hash, leaving it empty to build the entire TDS packages.
set GitCommitId =
set /P GitCommitId=
If "%GitCommitId%" == "" GOTO BuildFullTds
@vtml
vtml / Whatever.TDS.scproj
Created October 31, 2018 12:18
TDS projects using Nuget package
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Hedgehog.TDS.BuildExtensions.GitDeltaDeploy.2.0.2\build\Hedgehog.TDS.BuildExtensions.GitDeltaDeploy.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Hedgehog.TDS.BuildExtensions.GitDeltaDeploy.2.0.2\build\Hedgehog.TDS.BuildExtensions.GitDeltaDeploy.targets'))" />
<Error Condition="!Exists('..\packages\HedgehogDevelopment.TDS.5.7.0.10\build\HedgehogDevelopment.TDS.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\HedgehogDevelopment.TDS.5.7.0.10\build\HedgehogDevelopment.TDS.targets'))" />
</Target>
<Import Project="..\packages\HedgehogDevelopment.TDS.5