natemcmaster - dotnet-serve 1.4.0-build.91

A simple command-line HTTP server.

This package was build from source code at https://github.com/natemcmaster/dotnet-serve/tree/73055da380ad1422d96a608d3d6102357654fb8a

PM> Install-Package dotnet-serve -Version 1.4.0-build.91 -Source https://www.myget.org/F/natemcmaster/api/v3/index.json

Copy to clipboard

> nuget.exe install dotnet-serve -Version 1.4.0-build.91 -Source https://www.myget.org/F/natemcmaster/api/v3/index.json

Copy to clipboard

> dotnet tool install -g dotnet-serve --version 1.4.0-build.91 --add-source https://www.myget.org/F/natemcmaster/api/v3/index.json

Copy to clipboard
<DotNetCliToolReference Include="dotnet-serve" Version="1.4.0-build.91" />
Copy to clipboard
source https://www.myget.org/F/natemcmaster/api/v3/index.json

nuget dotnet-serve  ~> 1.4.0-build.91
Copy to clipboard

> choco install dotnet-serve --version 1.4.0-build.91 --source https://www.myget.org/F/natemcmaster/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "natemcmaster" -SourceLocation "https://www.myget.org/F/natemcmaster/api/v2"
Install-Module -Name "dotnet-serve" -RequiredVersion "1.4.0-build.91" -Repository "natemcmaster" -AllowPreRelease
Copy to clipboard

dotnet-serve

Build Status Code Coverage NuGet NuGet Downloads

A simple command-line HTTP server.

It launches a server in the current working directory and serves all files from that directory.

Get started

Install .NET and run this command:

dotnet tool install --global dotnet-serve

Start a simple server and open the browser by running:

dotnet serve -o

And with HTTPS:

dotnet serve -o -S

With a specific port (otherwise, it defaults to a random unused port):

dotnet serve --port 8080

Allow access from remote machines (defaults to loopback only). Use this if running inside Docker:

dotnet serve --address any

Usage

Usage: dotnet serve [options]

Options:
  --version                            Show version information.
  -d|--directory <DIR>                 The root directory to serve. [Current directory]
  -o|--open-browser[:<PATH>]           Open a web browser when the server starts. [Default false]
                                       You can also provide the subpath to launch by using -o:<PATH>.
                                       Example: -o:/path/index.html
  -p|--port <PORT>                     Port to use [8080]. Use 0 for a dynamic port.
  -a|--address <ADDRESS>               Address to use. [Default = localhost].
                                       Accepts IP addresses,
                                       'localhost' to accept only loopback requests, or
                                       'any' to accept requests from any IP address.
  --path-base <PATH>                   The base URL path appended to the site URL.
  --reverse-proxy <MAPPING>            Map a path pattern to another url.
                                       Expected format is <SOURCE_PATH_PATTERN>=<DESTINATION_URL_PREFIX>.
                                       SOURCE_PATH_PATTERN uses ASP.NET routing syntax. Use {**all} to match anything.
  --default-extensions[:<EXTENSIONS>]  A comma-delimited list of extensions to use when no extension is provided in the URL. [.html,.htm]
  -q|--quiet                           Show less console output.
  -v|--verbose                         Show more console output.
  -h|--headers <HEADER_AND_VALUE>      A header to return with all file/directory responses. e.g. -h "X-XSS-Protection: 1; mode=block"
  -S|--tls                             Enable TLS (HTTPS)
  --cert                               A PEM encoded certificate file to use for HTTPS connections.
                                       Defaults to file in current directory named 'cert.pem'
  --key                                A PEM encoded private key to use for HTTPS connections.
                                       Defaults to file in current directory named 'private.key'
  --pfx                                A PKCS#12 certificate file to use for HTTPS connections.
                                       Defaults to file in current directory named 'cert.pfx'
  --pfx-pwd                            The password to open the certificate file. (Optional)
  -m|--mime <MAPPING>                  Add a mapping from file extension to MIME type. Empty MIME removes a mapping.
                                       Expected format is <EXT>=<MIME>.
  -z|--gzip                            Enable gzip compression
  -b|--brotli                          Enable brotli compression
  -c|--cors                            Enable CORS (it will enable CORS for all origins and all methods)
  --save-options                       Save specified options to .netconfig for subsequent runs.
  --config-file                          Use the given .netconfig file.
  --fallback-file                       The path to a file which is served for requests that do not match known file names.
                                       This is commonly used for single-page applications.
  -?|--help                            Show help information.

Tip: single letters for options can be combined. Example: dotnet serve -Sozq

Configuring HTTPS

dotnet serve -S will serve requests over HTTPS. By default, it will attempt to find an appropriate certificate on the machine.

By default, dotnet serve will look for, in order:

  • A pair of files named cert.pem and private.key in the current directory
  • A file named cert.pfx in the current directory
  • The ASP.NET Core Developer Certificate (localhost only)

You can also manually specify certificates as command line options (see below):

See also this doc for how to create a self-signed HTTPS certificate.

.pem files

Use this when you have your certificate and private key stored in separate files (PEM encoded):

dotnet serve --cert ./cert.pem --key ./private.pem

Note: currently only RSA private keys are supported.

.pfx file

Use this when you have your certificate as a .pfx/.p12 file (PKCS#12 format):

dotnet serve --pfx myCert.pfx --pfx-pwd certPass123

Using the ASP.NET Core Developer Certificate

The developer certificate is automatically created the first time you use dotnet. When serving on 'localhost', dotnet-serve will discover and use it when you run:

dotnet serve -S

Reverse Proxy

dotnet-serve --reverse-proxy /api/{**all}=http://localhost:5000 will proxy all requests matching /api/* to http://localhost:5000/api/*.

The source path pattern uses ASP.NET routing syntax. See the ASP.NET docs for more info.

Multiple --reverse-proxy <MAPPING> directives can be defined.

Reusing options with .netconfig

dotnet-serve supports reading and saving options using dotnet-config, which provides hierarchical inherited configuration for any .NET tool. This means you can save your frequently used options to .netconfig so you don't need to specify them every time and for every folder you serve across your machine.

To save the options used in a particular run to the current directory's .netconfig, just append --save-options:

dotnet serve -p 8080 --gzip --cors --quiet --save-options

After running that command, a new .netconfig will be created (if there isn't one already there) with the following section for dotnet-serve:

[serve]
	port = 8000
	quiet
	gzip
	cors
	header = X-My-Option: foo
	header = X-Another: bar

Note: multiple header, mime type mappings, and exclude-file entries can be provided as individual variables.

You can place those settings in any parent folder, and they will be reused across all descendant folders. Alternatively, they can be saved to global (user profile) or system locations. To easily configure these options at those levels, use the dotnet-config tool itself:

dotnet config --global --set serve.port 8000

This will default the port to 8000 whenever a port is not specified in the command line. You can open the saved .netconfig at %USERPROFILE%\.netconfig or ~/.netconfig.

The cert, key and pfx values, in particular, can be relative paths that are resolved relative to the location of the declaring .netconfig file, which can be very convenient.

  • Support running on .NET Core 3.0

See https://github.com/natemcmaster/dotnet-serve/blob/master/CHANGELOG.md#v140 for release notes.

  • .NETCoreApp 2.1: 2.1.0.0
  • .NETCoreApp 3.0: 3.0.0.0

Signature validation information

Informational

Signature Hash Algorithm: SHA256

Timestamp: 9/20/2019 6:46:52 AM

Verifying author primary signature's timestamp with timestamping service certificate: 
  Subject Name: CN=DigiCert SHA2 Timestamp Responder, O=DigiCert, C=US
  SHA1 hash: 400191475C98891DEBA104AF47091B5EB6D4CBCB
  SHA256 hash: FC834D5BFFDE31DBA5B79BF95F573F7953BCBF9156E8525163E828EB92EA8A93
  Issued by: CN=DigiCert SHA2 Assured ID Timestamping CA, OU=www.digicert.com, O=DigiCert Inc, C=US
  Valid from: 1/4/2017 12:00:00 AM to 1/18/2028 12:00:00 AM

Signature type: Author

Verifying the author primary signature with certificate: 
  Subject Name: CN=Nathan McMaster, O=Nathan McMaster, L=Redmond, S=WA, C=US
  SHA1 hash: 43BEB98AA1E8C9EC89B3930C59FF34173044A3B8
  SHA256 hash: BC51EBF05EB96010FF3EEED195DE3EC028884A5B4DD9EABF233A16E048401878
  Issued by: CN=DigiCert SHA2 Assured ID Code Signing CA, OU=www.digicert.com, O=DigiCert Inc, C=US
  Valid from: 6/7/2019 12:00:00 AM to 6/9/2020 12:00:00 PM

Owners

Nate McMaster

Authors

Nate McMaster

Project URL

https://github.com/natemcmaster/dotnet-serve

License

Apache-2.0

Signature

Validation: Valid

Info

8200 total downloads
76 downloads for version 1.4.0-build.91
Download (2.59 MB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.7.120 2.79 MB Sat, 14 Mar 2020 17:43:12 GMT 77
1.7.119 2.79 MB Sat, 29 Feb 2020 18:32:20 GMT 84
1.7.117 2.76 MB Tue, 11 Feb 2020 05:21:03 GMT 87
1.7.116 2.76 MB Tue, 11 Feb 2020 05:24:52 GMT 83
1.6.0 2.72 MB Wed, 04 Dec 2019 05:24:46 GMT 93
1.6.0-build.115 2.76 MB Tue, 11 Feb 2020 05:09:02 GMT 85
1.6.0-build.114 2.76 MB Sun, 09 Feb 2020 05:12:17 GMT 83
1.6.0-build.113 2.76 MB Sun, 09 Feb 2020 05:10:56 GMT 80
1.6.0-build.112 2.76 MB Tue, 07 Jan 2020 05:05:05 GMT 95
1.6.0-build.111 2.72 MB Sat, 07 Dec 2019 23:53:47 GMT 66
1.6.0-build.110 2.72 MB Sat, 07 Dec 2019 23:53:01 GMT 83
1.6.0-build.108 2.72 MB Wed, 04 Dec 2019 05:23:42 GMT 85
1.5.0-build.107 2.72 MB Wed, 04 Dec 2019 05:20:55 GMT 78
1.5.0-build.106 2.72 MB Fri, 22 Nov 2019 05:26:41 GMT 93
1.5.0-build.103 2.72 MB Mon, 18 Nov 2019 15:36:13 GMT 96
1.5.0-build.102 2.72 MB Mon, 11 Nov 2019 16:10:23 GMT 76
1.5.0-build.101 2.72 MB Tue, 05 Nov 2019 05:48:49 GMT 84
1.5.0-build.100 2.64 MB Tue, 05 Nov 2019 05:41:35 GMT 90
1.4.1 2.59 MB Sat, 21 Sep 2019 04:27:19 GMT 87
1.4.1-build.98 2.64 MB Mon, 21 Oct 2019 15:26:20 GMT 79
1.4.1-build.97 2.64 MB Tue, 01 Oct 2019 00:52:30 GMT 85
1.4.1-build.96 2.64 MB Sat, 21 Sep 2019 22:00:04 GMT 78
1.4.1-build.95 2.64 MB Sat, 21 Sep 2019 18:21:32 GMT 88
1.4.1-build.94 2.64 MB Sat, 21 Sep 2019 18:20:23 GMT 86
1.4.1-build.92 2.59 MB Sat, 21 Sep 2019 04:13:44 GMT 88
1.4.0 2.59 MB Fri, 20 Sep 2019 06:49:54 GMT 84
1.4.0-build.91 2.59 MB Fri, 20 Sep 2019 06:48:39 GMT 76
1.3.0 1.3 MB Thu, 29 Aug 2019 05:40:42 GMT 90
1.3.0-build.88 1.3 MB Sat, 14 Sep 2019 06:06:37 GMT 85
1.3.0-build.87 1.3 MB Wed, 04 Sep 2019 03:49:43 GMT 81
1.3.0-build.86 1.3 MB Wed, 04 Sep 2019 00:48:30 GMT 84
1.3.0-build.84 1.3 MB Thu, 29 Aug 2019 05:32:10 GMT 92
1.3.0-build.81+36ba62dd 1.3 MB Thu, 29 Aug 2019 05:01:44 GMT 85
1.3.0-build.80+e8187ead 1.29 MB Thu, 29 Aug 2019 04:40:21 GMT 70
1.2.0 1.3 MB Mon, 25 Feb 2019 20:18:10 GMT 83
1.2.0-build.98 1.31 MB Wed, 31 Oct 2018 00:37:28 GMT 86
1.2.0-build.97 1.31 MB Wed, 31 Oct 2018 00:34:45 GMT 76
1.2.0-build.96 1.31 MB Wed, 31 Oct 2018 00:32:42 GMT 82
1.2.0-build.79+6572f03b 1.3 MB Mon, 25 Feb 2019 19:45:29 GMT 86
1.1.1-build.93 1.31 MB Fri, 26 Oct 2018 04:15:29 GMT 75
1.1.1-build.91 1.31 MB Fri, 26 Oct 2018 04:06:48 GMT 91
1.1.1-build.89 1.31 MB Thu, 18 Oct 2018 03:34:32 GMT 94
1.1.0 1.31 MB Thu, 18 Oct 2018 03:30:48 GMT 88
1.1.0-build.87 1.31 MB Thu, 18 Oct 2018 03:26:19 GMT 68
1.1.0-build.86 1.31 MB Thu, 18 Oct 2018 03:21:23 GMT 87
1.1.0-build.85 1.31 MB Thu, 18 Oct 2018 03:17:52 GMT 84
1.1.0-build.83 1.31 MB Thu, 18 Oct 2018 02:44:40 GMT 85
1.1.0-build.81 1.3 MB Thu, 18 Oct 2018 02:19:28 GMT 85
1.1.0-build.80 1.3 MB Thu, 18 Oct 2018 02:15:52 GMT 81
1.1.0-build.79 1.3 MB Thu, 18 Oct 2018 02:13:45 GMT 73
1.1.0-build.78 1.3 MB Thu, 18 Oct 2018 02:12:07 GMT 86
1.1.0-build.77 1.3 MB Thu, 18 Oct 2018 02:07:46 GMT 82
1.1.0-build.75 1.3 MB Wed, 17 Oct 2018 04:24:57 GMT 94
1.1.0-build.74 1.3 MB Wed, 17 Oct 2018 04:19:31 GMT 88
1.0.1-build.72 1.24 MB Fri, 28 Sep 2018 11:36:33 GMT 92
1.0.1-build.71 1.24 MB Fri, 17 Aug 2018 05:49:55 GMT 95
1.0.0 1.24 MB Wed, 30 May 2018 17:32:23 GMT 79
1.0.0-build.70 1.24 MB Tue, 07 Aug 2018 18:27:02 GMT 77
1.0.0-build.69 1.24 MB Tue, 07 Aug 2018 18:24:51 GMT 82
1.0.0-build.67 1.24 MB Sat, 09 Jun 2018 22:52:30 GMT 69
1.0.0-build.66 1.24 MB Wed, 30 May 2018 17:41:25 GMT 76
1.0.0-build.64 1.24 MB Fri, 25 May 2018 04:15:30 GMT 74
0.4.1-build.60 1.24 MB Fri, 11 May 2018 05:39:11 GMT 83
0.4.1-build.58 1.24 MB Fri, 11 May 2018 05:27:34 GMT 82
0.4.1-build.57 1.24 MB Fri, 11 May 2018 05:22:58 GMT 78
0.4.1-build.56 1.24 MB Fri, 11 May 2018 05:14:54 GMT 76
0.4.1-build.55 1.24 MB Fri, 11 May 2018 04:33:45 GMT 80
0.4.1-build.54 1.24 MB Fri, 11 May 2018 04:09:59 GMT 86
0.4.1-build.53 1.24 MB Fri, 11 May 2018 04:08:03 GMT 86
0.4.0 94.8 KB Fri, 11 May 2018 00:11:03 GMT 81
0.4.0-build.51 94.81 KB Fri, 11 May 2018 00:08:14 GMT 93
0.4.0-alpha.49 94.81 KB Fri, 11 May 2018 00:02:50 GMT 84
0.4.0-alpha.48 94.82 KB Thu, 10 May 2018 23:55:56 GMT 68
0.4.0-alpha.47 94.81 KB Thu, 10 May 2018 23:51:18 GMT 81
0.4.0-alpha.43 94.8 KB Wed, 09 May 2018 05:18:23 GMT 81
0.4.0-alpha.42 93.89 KB Tue, 08 May 2018 00:25:12 GMT 86
0.4.0-alpha.40 93.85 KB Fri, 04 May 2018 06:30:26 GMT 75
0.4.0-alpha 94.81 KB Fri, 11 May 2018 00:04:44 GMT 85
0.3.0 91.23 KB Wed, 11 Apr 2018 15:49:18 GMT 80
0.3.0-rtm.38 91.25 KB Wed, 11 Apr 2018 15:46:50 GMT 93
0.3.0-rtm.37 91.25 KB Wed, 11 Apr 2018 15:43:50 GMT 83
0.3.0-rc1.35 90.84 KB Tue, 10 Apr 2018 04:11:28 GMT 92
0.3.0-rc1.29 90.91 KB Thu, 05 Apr 2018 08:07:54 GMT 90
0.3.0-alpha1.28 10.8 MB Sat, 31 Mar 2018 07:37:39 GMT 78
0.3.0-alpha1.27 10.8 MB Sat, 31 Mar 2018 05:44:15 GMT 73
0.3.0-alpha1.25 10.8 MB Wed, 28 Mar 2018 17:39:32 GMT 89
0.2.1 74.1 KB Wed, 28 Mar 2018 02:08:32 GMT 101
0.2.1-rtm.24 10.8 MB Wed, 28 Mar 2018 15:45:36 GMT 81
0.2.1-rtm.22 74.11 KB Wed, 28 Mar 2018 02:06:43 GMT 88
0.2.1-alpha.19 74.12 KB Sat, 17 Mar 2018 06:56:07 GMT 72
0.2.1-alpha.18 74.12 KB Sat, 17 Mar 2018 06:48:13 GMT 95
0.2.1-alpha.17 74.12 KB Sat, 17 Mar 2018 06:19:34 GMT 85
0.2.1-alpha.13 73.75 KB Thu, 15 Mar 2018 07:43:46 GMT 85
0.2.1-alpha.11 73.7 KB Thu, 15 Mar 2018 07:31:27 GMT 86
0.2.0 73.55 KB Mon, 12 Mar 2018 02:33:19 GMT 92
0.2.0-rtm.9 73.55 KB Mon, 12 Mar 2018 02:31:41 GMT 83
0.2.0-alpha.6 49.33 KB Sun, 04 Feb 2018 02:47:01 GMT 90
0.1.0-rtm.2 9.42 KB Wed, 13 Dec 2017 04:52:03 GMT 85