Skip to content

Instantly share code, notes, and snippets.

View natemcmaster's full-sized avatar

Nate McMaster natemcmaster

View GitHub Profile
@natemcmaster
natemcmaster / README.md
Last active August 4, 2024 18:15
ContentRoot, WebRoot, BaseDirectory, and CurrentDirectory

Assuming you use template defaults

public static void Main()
{
  var host = new WebHostBuilder()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .Build();
}

public Startup(IHostingEnvironment env)
@natemcmaster
natemcmaster / README.md
Last active April 2, 2024 18:27
runtimeconfig.json schema

This defines the schema for .NET Core's runtimeconfig.json file.

Usage in an editor

Using Visual Studio, you can get auto-completion if you import the schema in your .JSON file like this:

{
  "$schema": "https://gist.githubusercontent.com/natemcmaster/0bdee16450f8ec1823f2c11af880ceeb/raw/runtimeconfig.template.schema.json"
}
using System.Threading.Tasks;
using McMaster.Extensions.CommandLineUtils;
using NuGet.Common;
namespace custom_restore
{
internal class MyNuGetLogger : LoggerBase
{
private IReporter _reporter;
@natemcmaster
natemcmaster / zip2tgz.sh
Last active October 27, 2023 21:44
Convert zip to tar.gz file
#!/usr/bin/env bash
if [[ $# < 2 ]]; then
echo "Usage: [src] [dest]"
exit 1
fi
function realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

Keybase proof

I hereby claim:

  • I am natemcmaster on github.
  • I am natemcmaster (https://keybase.io/natemcmaster) on keybase.
  • I have a public key whose fingerprint is 7A31 3DC2 CB0F 494B 84E9 69B8 AE49 AC45 8DE4 0A8E

To claim this, I am signing this object:

@natemcmaster
natemcmaster / Vagrantfile
Last active February 8, 2019 15:07
DNVM on Ubuntu
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.box = "ubuntu/trusty64"
# Enable provisioning with a shell script.
config.vm.provision "shell", privileged: false, inline: <<-SHELL
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
@natemcmaster
natemcmaster / kestrel.md
Last active March 5, 2018 18:16
Design meeting notes: 2018-03-02 - Libuv and source build

Problem

In an effort to make it possible to build ASP.NET Core from source code only on a single machine without access to NuGet.org or already-built assets, we need to revisit the structuring of our package dependencies. The NuGet package that contains Libuv bundles binaries built on macOS, Windows, and Linux. This means it is not possible to build the package, Libuv.nupkg, from source code only -- you must have multiple machines. Furthermore, because Microsoft.AspNetCore.App depends on this package via transitive reference through Microsoft.AspNetCore.Server.Kestrel, a project restore against source-built only packages cannot succeed in offline mode.

Slide1

Possible solutions

We went over ways we could solve this. This includes:

@natemcmaster
natemcmaster / dependencies.props
Last active November 15, 2017 17:16
ASP.NET Core 2.0.3 package versions
<Project>
<PropertyGroup>
<MicrosoftAspNetCorePackageVersion>2.0.1</MicrosoftAspNetCorePackageVersion>
<MicrosoftAspNetCoreAllPackageVersion>2.0.3</MicrosoftAspNetCoreAllPackageVersion>
<MicrosoftAspNetCoreAntiforgeryPackageVersion>2.0.1</MicrosoftAspNetCoreAntiforgeryPackageVersion>
<MicrosoftAspNetCoreApplicationInsightsHostingStartupPackageVersion>2.0.1</MicrosoftAspNetCoreApplicationInsightsHostingStartupPackageVersion>
<MicrosoftAspNetCoreAuthenticationAbstractionsPackageVersion>2.0.1</MicrosoftAspNetCoreAuthenticationAbstractionsPackageVersion>
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.0.1</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.0.1</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
<MicrosoftAspNetCoreAuthenticationFacebookPackageVersion>2.0.1</MicrosoftAspNetCoreAuthenticationFacebookPackageVersion>
@natemcmaster
natemcmaster / Program.cs
Last active August 29, 2017 16:37
CustomCandidateNamingService
using System;
using Microsoft.EntityFrameworkCore.Scaffolding.Internal;
using Microsoft.Extensions.DependencyInjection;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
@natemcmaster
natemcmaster / Program.cs
Last active December 27, 2016 15:03
dotnet-names
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Diagnostics;
namespace DotnetNames.Tool
{
class Program
{