Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

ASP.NET Core to Azure from the Command Line with Git and VS Code.

Tags: asp.net-core, azure, continuous-integration, git, github, command-line, vscode

Directory Structure

Program.cs
project.json
web.config

Program.cs

using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;

public class Program
{
    public void Configure(IApplicationBuilder app)
    {
        app.Run(async (context) =>
        {
            await context.Response.WriteAsync("Hello World!");
        });
    }

    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Program>()
            .Build();

        host.Run();
    }
}

project.json

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "publishOptions": {
    "include": [
      "web.config"
    ]
  },
  "scripts": {
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  }
}

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
    <handlers>
    <add name="aspNetCore" 
        path="*" 
        verb="*" 
        modules="AspNetCoreModule" 
        resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" 
        arguments="%LAUNCHER_ARGS%" 
        stdoutLogEnabled="false" 
        stdoutLogFile=".\logs\stdout" 
        forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>

Azure Web App Result

D:\home\site\wwwroot

    refs
    Microsoft.AspNetCore.Hosting.Abstractions.dll
    Microsoft.AspNetCore.Hosting.dll
    Microsoft.AspNetCore.Hosting.Server.Abstractions.dll
    Microsoft.AspNetCore.Http.Abstractions.dll
    Microsoft.AspNetCore.Http.dll
    Microsoft.AspNetCore.Http.Extensions.dll
    Microsoft.AspNetCore.Http.Features.dll
    Microsoft.AspNetCore.HttpOverrides.dll
    Microsoft.AspNetCore.Server.IISIntegration.dll
    Microsoft.AspNetCore.Server.Kestrel.dll
    Microsoft.AspNetCore.WebUtilities.dll
    Microsoft.Extensions.Configuration.Abstractions.dll
    Microsoft.Extensions.Configuration.dll
    Microsoft.Extensions.Configuration.EnvironmentVariables.dll
    Microsoft.Extensions.DependencyInjection.Abstractions.dll
    Microsoft.Extensions.DependencyInjection.dll
    Microsoft.Extensions.FileProviders.Abstractions.dll
    Microsoft.Extensions.FileProviders.Physical.dll
    Microsoft.Extensions.FileSystemGlobbing.dll
    Microsoft.Extensions.Logging.Abstractions.dll
    Microsoft.Extensions.Logging.dll
    Microsoft.Extensions.ObjectPool.dll
    Microsoft.Extensions.Options.dll
    Microsoft.Extensions.PlatformAbstractions.dll
    Microsoft.Extensions.Primitives.dll
    Microsoft.Net.Http.Headers.dll
    repository.deps.json
    repository.dll
    repository.pdb
    repository.runtimeconfig.json
    System.Diagnostics.Contracts.dll
    System.Net.WebSockets.dll
    System.Text.Encodings.Web.dll
    web.config