Skip to content

Instantly share code, notes, and snippets.

View patriksvensson's full-sized avatar

Patrik Svensson patriksvensson

View GitHub Profile
using System;
using Cake.Common.Diagnostics;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Frosting;
public class Program
{
public static int Main(string[] args)
{
@patriksvensson
patriksvensson / NSubstituteTest.cs
Last active August 28, 2016 11:41
NSubstitute problem: How do I verify the call to IBuilder.Register(Action<IContainer>)?
public class BuilderExtensionsTests
{
public class TheRegisterFooMethod
{
[Fact]
public void Should_Register_Foo_With_Container()
{
// Given
var builder = Substitute.For<IBuilder>();
@patriksvensson
patriksvensson / statuscode.cake
Created August 17, 2016 19:00
Cake script: Gets the status code from a web request and outputs it.
// Cake script
#r "System.Net"
using System.Net;
var request = (HttpWebRequest)WebRequest.Create("http://google.com");
var response = (HttpWebResponse)request.GetResponse();
var statusCode = response.StatusCode;
Information("Received {0}!", statusCode);
var platform = (int)Environment.OSVersion.Platform;
if (platform == (int)PlatformID.MacOSX)
{
OperatingSystem = OperatingSystemFamily.OSX;
}
else if ((platform == 4) || (platform == 6) || (platform == 128))
{
OperatingSystem = OperatingSystemFamily.Linux;
}
else if((platform <= 3) || (platform == 5))
@patriksvensson
patriksvensson / powershell.cake
Created March 8, 2016 09:20
Run PowerShell scripts from Cake
// Tools and addins
#addin "nuget:?package=System.Management.Automation&version=6.1.7601.17515"
using System.Collections;
using System.Management.Automation;
using System.Management.Automation.Internal;
using System.Management.Automation.Runspaces;
using System.Threading;
///////////////////////////////////////////////////////////////////////////////
@patriksvensson
patriksvensson / Dockerfile
Created November 21, 2015 15:15
Dockerfile for Jenkins build agent using Cake
FROM ubuntu:15.10
MAINTAINER Patrik Svensson "[email protected]"
# Make sure everything is up to date.
RUN apt-get update
RUN apt-get -y upgrade
# Install SSH server.
RUN apt-get install -y openssh-server
RUN sed -i 's|session required pam_loginuid.so|session optional pam_loginuid.so|g' /etc/pam.d/sshd
@patriksvensson
patriksvensson / build.cake
Last active August 29, 2015 14:26
GitReleaseManager
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var config = Argument("config", "Debug");
//////////////////////////////////////////////////////////////////////
// DIRECTORIES
//////////////////////////////////////////////////////////////////////
@patriksvensson
patriksvensson / build.sh
Last active August 29, 2015 14:24
Cake bootstrapper script
#!/bin/bash
###############################################################
# This is the Cake bootstrapper script that is responsible for
# downloading Cake and all specified tools from NuGet.
###############################################################
# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools
NUGET_EXE=$TOOLS_DIR/nuget.exe
@patriksvensson
patriksvensson / Program.cs
Created June 24, 2015 09:44
Simple console application to embed Cake.
using System;
using System.Collections.Generic;
using Cake.Common.IO;
using Cake.Common.Tools.MSBuild;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Core.IO.NuGet;
namespace MyBuildScript
public void DoMagic()
{
// TODO: magic
}