Skip to content

Instantly share code, notes, and snippets.

View GeorgDangl's full-sized avatar
😎
Coding

Georg Dangl GeorgDangl

😎
Coding
View GitHub Profile
@GeorgDangl
GeorgDangl / PublishFunction.ps1
Last active November 6, 2017 16:22
Azure Functions deployment for CI environments via WebDeploy / MSDeploy
Param(
[string]$deployUsername,
[string]$deployPassword
)
$VisualStudioVersion = "15.0" # 15 == VS 2017
$msDeployPath = "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe"
$MsBuildPath = $(Get-ItemProperty "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7").$VisualStudioVersion + "MSBuild\15.0\Bin\MSBuild.exe"
$sourcePath = "'$PSScriptRoot/src/<ProjectFolder>/bin/Release/net461'"
@GeorgDangl
GeorgDangl / configure-identity.cs
Created November 8, 2017 20:53
Challenging multiple authentication schemes in Asp.Net Core 2.0 with a default policy on all actions
services.AddIdentity<AppUser, AppRole>();
services.AddAuthentication()
.AddIdentityServerAuthentication(o =>
{
o.RequireHttpsMetadata = !environment.IsDevelopment();
o.ApiName = "api";
o.Authority = configuration["IdentityServer:Authority"];
});
@GeorgDangl
GeorgDangl / fix-links.ps1
Last active November 12, 2017 21:25
This snippet is useful when using DocFX in Jenkins to fix broken GitHub View Source links. https://blog.dangl.me/archive/creating-correct-source-code-links-with-docfx-in-jenkins/
@GeorgDangl
GeorgDangl / correct-setup.cs
Created November 21, 2017 22:55
How to not implement your HttpMessageHandler when using the Asp.Net Core TestHost
public class IntegrationTestsHttpMessageHandler : HttpMessageHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var handler = TestServer.CreateHandler();
return handler.SendAsync(request, cancellationToken);
}
}
@GeorgDangl
GeorgDangl / errormessage.bat
Last active November 30, 2017 10:43
Fixing xUnit not recognizing .Net Core framework 2.0
C:\Solution\test\Project.Tests>dotnet xunit
Detecting target frameworks in Project.Tests.csproj...
Building for framework netcoreapp2.0...
Dangl.AVA -> C:\Solution\src\Project\bin\Debug\netstandard1.3\Project.dll
Dangl.AVA.Tests -> C:\Solution\test\Project.Tests\bin\Debug\netcoreapp2.0\Project.Tests.dll
Running .NET Core 2.0 tests for framework netcoreapp2.0...
The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.
- Check application dependencies and target a framework version installed at:
\
export class MainComponent {
onEditorClosed(hasChanged: boolean) {
if (hasChanged) {
this.dataService.forceRefresh();
this.dataService.paginationResult
.skip(1) // Discard the current value from the ReplaySubject
.take(1) // To release the subscription again
.subscribe(() => this.dataService.getDataById(this.data.id)
.then(data => {
@GeorgDangl
GeorgDangl / AccountController.cs
Created December 24, 2017 12:39
Appending custom claims when logging in via cookie with Asp.Net Core Identity
public class AccountController : Controller
{
[HttpPost("login")]
[AllowAnonymous]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public async Task<IActionResult> Login([FromBody] LoginPost model)
{
var user = await _userManager.FindByEmailAsync(model.Identifier)
?? await _userManager.FindByNameAsync(model.Identifier);
using Microsoft.Web.Deployment;
using System;
using System.IO;
namespace Nuke.Common.Tools.WebDeploy
{
public class AppOfflineWrapper : IDisposable
{
private readonly WebDeploySettings _settings;
private string _tempAppOfflinePath;
class Build : NukeBuild
{
[Parameter] readonly string Environment;
[Parameter] readonly string WebDeployUsername;
[Parameter] readonly string WebDeployPassword;
[Parameter] readonly string WebDeployPublishUrl;
[Parameter] readonly string WebDeploySiteName;
Target Publish => _ => _
.Requires(() => Environment)
namespace InMemoreCompilation
{
public static class CodeGenerator
{
public static string GenerateCalculator()
{
var calculator = @"namespace Calculator
{
public class Calculator
{