Skip to content

Instantly share code, notes, and snippets.

View wellingtonjhn's full-sized avatar

Wellington Nascimento wellingtonjhn

View GitHub Profile
@wellingtonjhn
wellingtonjhn / Startup.cs
Created February 26, 2018 23:40
ASP.Net Core Response Compression
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
@wellingtonjhn
wellingtonjhn / build.cake
Last active December 16, 2017 05:16
Script Cake para publicar pacotes Nuget .Net Core
#tool "nuget:?package=GitVersion.CommandLine"
#addin nuget:?package=Newtonsoft.Json
using Newtonsoft.Json;
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var artifactsDirectory = MakeAbsolute(Directory("./artifacts"));
Setup(context =>
@wellingtonjhn
wellingtonjhn / appveyor.yml
Created November 26, 2017 06:24
Arquivo de configuração do AppVeyor para .net Core
version: '{build}'
pull_requests:
do_not_increment_build_number: true
environment:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_API_KEY:
secure: hQ5LogWZGZTKK4u/AlC/X4ThwiCq0JbYNxuOCVMFWzRJwH8VSYHuVry/At69M1kH
build_script:
- ps: .\build.ps1
@wellingtonjhn
wellingtonjhn / .travis.yml
Created November 26, 2017 04:50
Arquivo de configuração do Travis para .net Core
language: csharp
os: linux
sudo: required
dist: trusty
addons:
apt:
packages:
- gettext
- libcurl4-openssl-dev
- libicu-dev
@wellingtonjhn
wellingtonjhn / task-dotnet-nuget-push.cake
Created November 20, 2017 22:21
Task do Cake para publicar pacote Nuget
Task("Push-Nuget-Package")
.IsDependentOn("Create-Nuget-Package")
.Does(() =>
{
var apiKey = "b5819ebc-3fd4-4e98-b391-665f36aff91e"; //EnvironmentVariable("apiKey");
foreach (var package in GetFiles($"{artifactsDirectory}/*.nupkg"))
{
NuGetPush(package,
new NuGetPushSettings {
@wellingtonjhn
wellingtonjhn / task-dotnetcore-pack.cake
Last active November 21, 2017 22:03
Task do Cake para criar pacotes Nuget
Task("Create-Nuget-Pack")
.IsDependentOn("Test")
.Does(() =>
{
foreach (var project in GetFiles("./src/**/*.csproj"))
{
DotNetCorePack(
project.GetDirectory().FullPath,
new DotNetCorePackSettings()
{
@wellingtonjhn
wellingtonjhn / task-dotnetcore-test.cake
Last active November 18, 2017 15:11
Task do Cake para execução de Testes de Unidade em projetos .Net Core
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
foreach(var project in GetFiles("./tests/**/*.csproj"))
{
DotNetCoreTest(
project.GetDirectory().FullPath,
new DotNetCoreTestSettings()
{
@wellingtonjhn
wellingtonjhn / task-dotnetcore-build.cake
Last active November 18, 2017 15:10
Task do Cake para fazer o Build em projetos .Net Core
Task("Build")
.Does(() =>
{
foreach(var project in GetFiles("./src/**/*.csproj"))
{
DotNetCoreBuild(
project.GetDirectory().FullPath,
new DotNetCoreBuildSettings()
{
Configuration = configuration
@wellingtonjhn
wellingtonjhn / initial-config.cake
Last active November 21, 2017 22:02
Configuração inicial do script Cake
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var artifactsDirectory = MakeAbsolute(Directory("./artifacts"));
/// Aqui devem ser definidas as tasks
Task("Default");
RunTarget(target);
@wellingtonjhn
wellingtonjhn / pre-push
Last active November 10, 2017 21:42
Pre-push git hook to run unit tests for .Net Core applications
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
RED='\033[0;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# only run this if you are pushing to master
if [[ $current_branch = $protected_branch ]] ; then