This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Detects failure from an external script has failed based on both $? and $LASTEXITCODE checking | |
Tested with a .net console app in 4 modes: | |
- no stderr, exit 0 (should be the only passing case) | |
- stderr, exit 0 ($? should indicate failure) | |
- no stderr, exit 1 ($LASTEXITCODE should indicate failure) | |
- stderr, exit 1 (both $? and $LASTEXITCODE should indicate failure) | |
See http://stackoverflow.com/questions/10666101/lastexitcode-0-but-false-in-powershell-redirecting-stderr-to-stdout-gives-n for background | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:on error exit | |
:setvar databaseName TeamCity | |
:setvar serviceAccount DOMAIN\ACCOUNT | |
/* | |
Creates a blank database suitable for use with TeamCity | |
See https://confluence.jetbrains.com/display/TCD9/Setting+up+an+External+Database#SettingupanExternalDatabase-MicrosoftSQLServer | |
Important bit is to get the case-sensitive colation correct (_CS_AS), | |
which is required for non-Windows build agents (if ever required in future) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:on error exit | |
:setvar databaseName OctopusDeploy | |
:setvar serviceAccount DOMAIN\ACCOUNT | |
/* | |
Creates a blank database suitable for use with Octopus Deploy | |
See http://docs.octopusdeploy.com/display/OD/SQL+Server+Database+Requirements | |
Important bits: | |
- must be CASE INSENSITIVE | |
- must setup Octopus service account as dbo_owner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enter file contents hereparam( | |
[Parameter(Mandatory=$true)] [string]$sqlServer | |
) | |
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") > $null | |
$smoServer = new-object Microsoft.SqlServer.Management.Smo.Server $sqlServer | |
$str = $smoServer.DefaultFile # or .DefaultLog for tlog files | |
if ($str) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .Synopsys | |
# Sets up Beyond Compare professional as Diff tool for all instances of Visual Studio on this PC | |
# If you don't use TFS, change the sccProvider as appropriate | |
[CmdLetBinding()] | |
param( | |
$bcPath = 'C:\Program Files (x86)\Beyond Compare 3\BComp.exe', | |
$sccProvider = 'TeamFoundation' | |
) | |
$ErrorActionPreference = 'stop'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Performs a projection on a heirachical sequence, without flattening | |
/// </summary> | |
/// <remarks>ie given an input type of X, each item of which has children which are also of type X, | |
/// execute a single selector across all X in the tree to retrieve a new target heirachy | |
/// </remarks> | |
public static IEnumerable<TOut> SelectRecurse<TIn,TOut>(IEnumerable<TIn> items, Func<TIn, IEnumerable<TIn>> childSelector, Func<TIn, IEnumerable<TOut>, TOut> selector){ | |
foreach(var item in items){ | |
var children = childSelector(item); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Autofac; | |
using Autofac.Core; | |
namespace Autofac.Logging | |
{ | |
/// <summary> | |
/// Sets up automatic DI for service dependencies on <typeparamref name="TLogger"/>, | |
/// via an external factory that resolves based on the type of the resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://gist.github.com/piers7/91141f39715a2ec133e5 | |
// Example of how to interpret SQL server CDC LSNs in C# / .Net | |
// This is required when polling a server for updates in order to determine | |
// if a previously stored LSN is still valid (ie > min LSN available) | |
// Requires .Net 4 (or equivilent BigInteger implementation) | |
// Sample is a Linqpad script, but you get the idea | |
// NB: That SQL uses big-endian representation for it's LSNs is not | |
// (as best I know) something they guarantee not to change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Loads TeamCity system build properties into the current scope | |
Unless forced, doesn't do anything if not running under TeamCity | |
#> | |
param( | |
$prefix = 'TeamCity.', | |
$file = $env:TEAMCITY_BUILD_PROPERTIES_FILE + ".xml", | |
[switch] $inTeamCity = (![String]::IsNullOrEmpty($env:TEAMCITY_VERSION)) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Adds/sets environment variables on the local machine for common build dependencies | |
#> | |
$ErrorActionPreference = 'stop'; | |
$programFiles32 = $env:ProgramFiles | |
if (Test-Path environment::"ProgramFiles(x86)") { $programFiles32 = (gi "Env:ProgramFiles(x86)").Value }; | |
# Accumulate the variables that we will be creating | |
$environmentVars = @{} |
NewerOlder