├── .gitignore
├── LICENSE
├── README.md
├── manuscript
├── 00-intro.md
├── 20-execution.md
├── 25-http.md
├── 30-publishing.md
├── 40-configuration.md
├── 50-octopus.md
├── book.txt
├── diagrams
│ ├── iis-kestrel.txt
│ └── kestrel.txt
└── images
│ ├── app-pool.png
│ ├── build-once.png
│ ├── dnu-console-output.png
│ ├── iis-add.png
│ ├── iis-kestrel-request.png
│ ├── iis-process-model.png
│ ├── kestrel-request.png
│ ├── myapp-procexp.png
│ ├── myapp-taskmgr-dnx.png
│ ├── myapp-taskmgr-legacy.png
│ ├── no-aspnet.png
│ ├── run-kestrel.png
│ ├── title_page.jpg
│ └── title_page.psd
└── samples
├── MyApp-CLR
├── App.config
├── MyApp-CLR.csproj
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── MyApp-DNX
├── MyApp-DNX.xproj
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── launchSettings.json
├── global.json
└── project.json
├── Samples.sln
└── WebApp
├── Controllers
└── ValuesController.cs
├── Project_Readme.html
├── Properties
└── launchSettings.json
├── Startup.cs
├── WebApp.xproj
├── appsettings.json
├── project.json
└── wwwroot
└── web.config
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 | project.lock.json
198 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### ASP.NET 5 Application Deployment Guide
2 |
3 | This is the GitHub repository for the mini ebook: [_ASP.NET 5 Application Deployment Guide_](https://leanpub.com/aspnetdeployment).
4 |
5 | If you have a suggestion, notice something missing from the book or a mistake, use the issues list. You can also fork this repository and send a pull request to add content. The book is licensed under a [CC By 3.0](http://creativecommons.org/licenses/by/3.0/deed.en_US) license.
6 |
7 |
--------------------------------------------------------------------------------
/manuscript/00-intro.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | ASP.NET was first released in 2002. Over the last decade, it has undergone significant changes and investment by Microsoft. From Web Forms to MVC and Web API, from ASP.NET AJAX to SignalR, ASP.NET has never stood still. And yet the architecture that underpins the platform never really changed: ASP.NET was coupled to IIS, IIS was coupled to Windows. The .NET runtime is installed globally and new versions were only released once every couple of years.
4 |
5 | ASP.NET 5 isn't just a few new features with a major version stamp. It's a significant architectural rebuild of the platform underneath ASP.NET. ASP.NET 5 is all about choice:
6 |
7 | - **Choice of operating systems**
8 | ASP.NET 5 applications can target .NET Core, a cross-platform .NET runtime. .NET Core is supported on Windows, OSX and Linux, all by Microsoft.
9 | - **Choice of web servers**
10 | ASP.NET 5 is no longer coupled to IIS. Any [OWIN-compatible](http://owin.org/) server can host ASP.NET. You can run ASP.NET under IIS, or under a new, cross-platform HTTP server called Kestrel, or embedded in your own server applications.
11 | - **Choice of framework versions**
12 | .NET Core is portable. If you target .NET Core, the entire runtime can be bundled and deployed side by side with your application. When Microsoft make improvements to the framework, your application can use them immediately, without affecting other applications.
13 |
14 | ## Goal of this book
15 |
16 | Have you ever had this experience? You decide to learn a new programming language, and you set out to build an application with it. You learn the language, write the code, and slowly your application takes shape. It runs locally in your development environment just fine. You want to deploy it somewhere for others to try, or maybe put it into production, and then you realize: you have no idea how to go about deploying it. Plenty of tutorials will teach you the frameorks and development environments, but finding good information on how to deploy and run the application in a production-like environment is really difficult.
17 |
18 | This book won't teach you how to *develop* ASP.NET 5 applications. There are plenty of great resources that can do that, from the [official ASP.NET 5 documentation](http://docs.asp.net) to books and blog posts and presentations. The purpose of this book is to teach you how to *deploy* them. As you learn ASP.NET 5 and prepare to deploy your applications, you'll find that many things have changed:
19 |
20 | - The way ASP.NET is hosted has changed
21 | - The way you compile and publish applications has changed
22 | - The way you configure applications for production has changed
23 |
24 | The goal of this book is to walk you through these changes, and to give you everything you need to successfully deploy your first ASP.NET 5 application to production.
25 |
26 | ## Target environments
27 |
28 | This book covers deployments to servers that you configure and manage yourself. That includes:
29 |
30 | - Infrastructure-as-a-service (IaaS) offerings, including from Amazon (EC2) and Microsoft Azure (Virtual Machines)
31 | - Your own on-premises Windows Server instances
32 |
33 | This book doesn't cover deployment to Platform-as-a-service (PaaS) offerings, like Microsoft Azure Web Apps.
34 |
35 | I> #### Work in progress
36 | I> This book is a work in progress. It's based on ASP.NET 5 RC1, and it's being written as we learn more about the platform. Follow the progress on the book by adding it to your cart in Leanpub:
37 | I>
38 | I> https://leanpub.com/aspnetdeployment
39 |
--------------------------------------------------------------------------------
/manuscript/20-execution.md:
--------------------------------------------------------------------------------
1 | # Runtimes and Execution
2 |
3 | To understand how ASP.NET 5.0 applications will run in production, it helps to first understand what .NET Core and DNX are. In this chapter, we'll take some time to understand them, and to understand some of the changes to how .NET applications run under DNX.
4 |
5 | ## Runtimes: .NET Framework vs. .NET Core
6 |
7 | When .NET Framework 4.0 shipped, it came bundled with Windows Server 2012, and as a 48MB MSI for older versions of Windows. The .NET Framework contains just about everything, from UI toolkits (WPF and Windows Forms), to communication libraries (WCF/HTTP), to web application stacks (ASP.NET Web Forms). Because the framework ships as one big package, it's difficult to tease components apart, to iterate on them, or to ever remove something from them.
8 |
9 | To combat this, and to take .NET cross platform, ".NET Core" was created. This is a new take on the CLR, which has been mercilessly factored into small assemblies that are available as packages on NuGet. It has a few benefits:
10 |
11 | - **Cross platform**
12 | .NET Core is supported on Windows, Linux and OSX.
13 | - **Portable**
14 | .NET Core can be packaged and deployed as part of your application; no global installation required.
15 | - **Lightweight**
16 | Only the packages you actually use are imported.
17 |
18 | A> ####Portability is a major production benefit
19 | A> Remember when .NET 4.5 shipped, and you really wanted to use features of it, but since it was an in-place upgrade you had to wait for months for it to be tested against all of the enterprise's other applications before you could use it?
20 | A>
21 | A> Under .NET Core, that problem disappears. Different teams can use different versions of .NET Core without any one affecting another.
22 |
23 | I believe that .NET Core is the future, and the only reason .NET Framework isn't obsolete is that it will simply take a long time for types to be made cross platform, tested and ported. As the surface area of .NET Core grows, third party packages will start to target .NET Core, and eventually it will have a big enough surface area to become the default choice for all applications.
24 |
25 | ### ASP.NET 5.0 targets both
26 |
27 | For this reason, ASP.NET 5.0 targets both the .NET Framework, and .NET Core. That is, you can make use of new features and architectural improvements in ASP.NET 5.0, but still use the regular desktop .NET runtime without being limited to the .NET Core surface area.
28 |
29 | When you sit down to build an ASP.NET 5.0 application, it's very unlikely that you'll target both .NET Core and .NET Framework. You'll make a choice:
30 |
31 | | .NET Core | .NET Framework |
32 | |-----------------------------------|--------------------------------------------|
33 | | Cross platform | Windows only |
34 | | Lightweight | Heavy |
35 | | Portable (bundle with your app) | Global, admin install |
36 | | Iterates quickly | Slow upgrade cycle |
37 | | Small surface area for now | Everything but the kitchen sink |
38 |
39 | Class libraries and some utility tools, however, will likely targetting both runtimes. So what's needed is some way to figure out what runtime to invoke when running an application. That's where DNX comes in.
40 |
41 | ## Execution: DNX
42 |
43 | Whether your application targets the full .NET Framework or just .NET Core, it can be executed with DNX. Think of DNX as a host for your .NET applications, much like the way `python.exe` hosts a Python script. It's easier to understand this by looking at what it does at the process level Take this simple C# console application:
44 |
45 | ```
46 | using System;
47 | using System.Threading;
48 |
49 | namespace MyApp
50 | {
51 | class Program
52 | {
53 | static void Main(string[] args)
54 | {
55 | Console.WriteLine("Hello, world!");
56 | Thread.Sleep(10000);
57 | }
58 | }
59 | }
60 | ```
61 |
62 | Before DNX, this code would get compiled into an `.exe` file. The top of the `.exe` file would contain a small bit of native code that would check the .NET runtime is installed globally, then load the runtime, and then the runtime would run the rest of the application. In task manager, you would see your executable as the top process:
63 |
64 | 
65 |
66 | Under DNX, this all changes. Firstly, I get to choose my runtime. Will this console application target the .NET Framework, .NET Core, or both?
67 |
68 | Secondly, in development, there is no compilation step - code is compiled on the fly with Roslyn, so you'll never see a `.dll` or `.exe` in the first place when you hit F5 locally. When you are ready to ship the application, though, you'll eventually compile it. You do this using the `dnu` tool:
69 |
70 | ```
71 | dnu publish --no-source
72 | ```
73 |
74 | Instead of creating a `.exe` as you might expect, the code is actually compiled into a `.dll` inside a directory structure. The directories contain the application bundled as a NuGet package, plus various JSON configuration files. At the root is a `.cmd` batch file which invokes the application:
75 |
76 | 
77 |
78 | The batch file invokes `DNX.exe` (the actual batch file is longer than this - snipped for brevity). This tool is called the DNX Application Host, and it takes care of running applications built for DNX:
79 |
80 | ```
81 | IF "%DNX_PATH%" == "" (
82 | SET "DNX_PATH=dnx.exe"
83 | )
84 | @"%DNX_PATH%" --project "%~dp0packages\MyApp-DNX\1.0.0\root" --configuration Debug MyApp %*
85 | ```
86 |
87 | The `MyApp` file without the extension is a shell script, so the same application can run on Linux (again, snipped):
88 |
89 | ```
90 | exec "dnx" --project "$DIR/packages/MyApp-DNX/1.0.0/root" --configuration Debug MyApp "$@"
91 | ```
92 |
93 | The trick that DNX uses is similar to how Java applications run. Java applications aren't compiled into an `.exe`, they just ship as a `.jar` file which is then loaded by the Java executable:
94 |
95 | ```
96 | java.exe myapp.jar
97 | ```
98 |
99 | Something you'll notice is that if you look in task manager, you won't see the name of your console app anywhere - just DNX. In fact I'm not even sure which one of these three DNX processes contains my application:
100 |
101 | 
102 |
103 | A good way to figure that out is by using SysInternals Process Explorer:
104 |
105 | 
106 |
107 | One of the great benefits of DNX is that if your application targets CoreCLR, the runtime can be distributed with your application. You can now see how this can work - since the CoreCLR includes DNX.exe, all you need to do is distribute the CoreCLR runtime files with your application, and your batch file will invoke that DNX version. You can bundle the runtime and have your batch file call that simply by specifying the option when publishing:
108 |
109 | ```
110 | dnu publish --runtime active --no-source
111 | ```
112 |
113 | A> ## Room for improvement?
114 | A> Personally, I think this folder structure is a bit messy and makes this seem more complicated than it should be. There's a good opportunity to hide all of these etails by keeping the shell script and batch file, but compressing the rest of the files into a NuGet package. `dnx myapp.1.0.0.nupkg` would be much neater.
115 |
116 | Now that you are familiar with how DNX invokes processes, let's look at two HTTP server options for ASP.NET 5.0.
117 |
118 | ### Summary
119 |
120 | .NET Core is an ambitious attempt to tease apart the monolithic .NET Framework into something that is portable, cross-platform and iterates quickly. DNX is a new way to build and run applications, whether they run on .NET Core *or* .NET Framework. We've looked at how DNX fits in with console applications; in the next chapter we'll look at how DNX executes ASP.NET applications.
121 |
--------------------------------------------------------------------------------
/manuscript/25-http.md:
--------------------------------------------------------------------------------
1 | # Web Servers
2 |
3 | Historically, there have been very few choices for deploying ASP.NET applications in production. ASP.NET was tightly coupled to IIS, which was tightly coupled to Windows, so the stack was chosen for you. As we discussed in chapter 1, ASP.NET 5.0 is about choice.
4 |
5 | Of course, IIS is still supported in ASP.NET 5.0. But since ASP.NET 5.0 builds on top of OWIN, any HTTP server that can host OWIN can host ASP.NET 5.0. And since .NET Core is cross-platform and IIS is not, we need new choices for HTTP servers when running ASP.NET 5 outside of Windows.
6 |
7 | In this chapter, we'll focus on the two HTTP servers that we expect will comprise of the majority of production ASP.NET 5.0 deployments: the new kid on the block, Kestrel, and the old, reliable IIS.
8 |
9 | ## Kestrel
10 |
11 | Kestrel is a cross-platform, open source HTTP server for ASP.NET 5.0. It's built by the same team at Microsoft that built ASP.NET 5.0, and it allows ASP.NET 5.0 applications to run consistently across Windows, Linux, and OSX.
12 |
13 | Where web servers like IIS and Apache are designed to be general-purpose web servers, with support for many languages and features like directory browsing and static content serving, Kestrel is designed specifically for hosting ASP.NET 5.0. Architectually, Kestrel builds on top of:
14 |
15 | - **`libuv`**, the open source asynchronous event library used by Node.js. This provides asynchronous TCP sockets to Kestrel in an OS-agnostic manner.
16 | - **`SslStream`**, a .NET framework class to turn an ordinary stream into a TLS stream. This allows Kestrel to support HTTPS, including client-side certificates. On Windows, `SslStream` builds on `SChannel`, the standard Windows TLS components also used by IIS. In practical terms, this means that HTTPS with Kestrel is as secure as HTTPS with IIS.
17 |
18 | Kestrel is entirely user-mode and binds to a TCP port directly to listen for requests. Kestrel can be used to run your ASP.NET 5.0 application, or embedded inside your own process. This is handy when building long-running services that sometimes need to present a web interface.
19 |
20 | 
21 |
22 | ## IIS
23 |
24 | IIS is a general purpose web server which can also host ASP.NET 5.0. However, the way IIS hosts ASP.NET 5.0 is dramatically different than previous versions of ASP.NET. Let's first look at the architecture of IIS and how ASP.NET was traditionally hosted, and how it now works with ASP.NET 5.0.
25 |
26 | ### IIS Architecture
27 |
28 | Windows ships with a kernel-mode device driver called HTTP.sys, which listens for HTTP connections and hands them over to an appropriate application. It allows multiple applications to effectively share the same IP/port combinations by performing some HTTP parsing in the kernel before dispatching to the application. For example:
29 |
30 | http://server:80/app1 # hosted by IIS
31 | http://server:80/app2 # hosted by a different process
32 |
33 | IIS builds on top of HTTP.sys - the request is initially received by HTTP.sys (which also performs some security filtering, like Windows Authentication or client certificates), which in turn hands it to IIS. It then sends the response from IIS back to the client.
34 |
35 | Each application running on IIS belongs to an application pool, and a worker process is created to serve requests to that application pool. This is the W3WP process you'll sometimes see in task manager. If the process runs for significant time, or experiences severe memory leaks and runs out of memory, or hangs, IIS can terminate it and create a new worker process.
36 |
37 | In previous versions of ASP.NET, the CLR was loaded into the worker process[^classic]. Under ASP.NET 5.0, this changes.
38 |
39 | [^classic]: In Integrated pipeline mode, IIS hosts the CLR and all IIS modules are managed modules. With Classic pipeline mode, IIS used unmanaged modules, and then the CLR ran its own unmanaged modules.
40 |
41 | - The worker process no longer contains the CLR - it's entirely unmanaged
42 | - All requests are routed to a new, unmanaged extension called the [HTTP Platform Handler](https://azure.microsoft.com/en-us/blog/announcing-the-release-of-the-httpplatformhandler-module-for-iis-8/)
43 | - The HTTP Platform Handler launches a DNX process by invoking the batch files we saw in the section on DNX. It sets an environment variable to tell the launched process what port to listen on.
44 | - DNX loads Kestrel!
45 | - HTTP Platform Handler then proxies the request to Kestrel in the DNX process, and proxies the response back
46 |
47 | Processing a request in IIS for ASP.NET 5 looks like this:
48 |
49 | 
50 |
51 | This architecture will be familar to users who have done development with platforms like Node.js, where it is common to have a server like NGINX accepting the initial request, then reverse proxying them to a node.exe process which listens on its own TCP port.
52 |
53 | Here's the process tree in SysInternals Process Explorer:
54 |
55 | 
56 |
57 | ### IIS setup notes
58 |
59 | Due to these major architectural changes, the way you set up and configure IIS for ASP.NET 5 changes quite a bit.
60 |
61 | First, you must download and install the [HTTP Platform Handler](http://www.iis.net/downloads/microsoft/httpplatformhandler) extension. Eventually I expect this will ship out of the box with IIS, but for now it's a separate download.
62 |
63 | Second, since application pool worker processes no longer host the CLR (since all they do is call an extension to run a batch file), you can configure them to not load it:
64 |
65 | 
66 |
67 | Third, if your IIS server isn't going to be running older versions of ASP.NET, you don't even need to install the ASP.NET IIS components at all!
68 |
69 | 
70 |
71 | ### Benefits of IIS
72 |
73 | Given that IIS effectively just proxies requests to and from Kestrel, what value does it provide? The main benefit would appear to be worker process management: if the DNX process becomes unresponsive, IIS can terminate the worker process tree, and a new one will be created, keeping the application responsive.
74 |
75 | On the other hand, the responsibilities of IIS have been dramatically reduced to that of a process manager and reverse proxy server: a Microsoft equivalent of NGINX. It remains to be seen whether many .NET applications will run directly under Kestrel without IIS in the middle.
76 |
77 | TODO: I need to confirm how other managed modules still work in this model. The HTTP Platform Handler extension is added and accepts all requests, but it doesn't remove any other modules, so presumably the CLR is still loaded into the worker process to call some of the native IIS modules.
78 |
79 | ### Summary
80 |
81 | The hosting architecture of ASP.NET 5 is radically different to previous versions, and for good reasons. By decoupling ASP.NET from IIS, a lot of choice is available and the team can iterate much more quickly. And yet IIS is still supported, acting as a reverse proxy instead of a web server, borrowing from the model of other web stacks. And there's still a lot of consistency: whichever approach you use, it's will still be ASP.NET hosted in Kestrel/DNX.
82 |
83 | Now that you know how applications will run in production, the next chapter will look at publishing applications.
84 |
--------------------------------------------------------------------------------
/manuscript/30-publishing.md:
--------------------------------------------------------------------------------
1 | # Publishing Applications for Deployment
2 |
3 | In this chapter, we'll take a deep look into how to publish your ASP.NET 5 application so that you can deploy it for other people to use. Rather than spend time on wizards in Visual Studio, we'll concentrate on using the command line to publish, so that we can automate it as part of our automated build and deployment process.
4 |
5 | Prior to ASP.NET 5, publishing applications from the command line was arcane and fiddly. The good news is that it gets much, much easier with the new `dnu` tool.
6 |
7 | ## Publishing with DNU
8 |
9 | DNU is a command-line tool that is part of DNX, and contains a number of utilities for building, packaging and publishing applications. When you're past the "works on my machine" stage of development and you're ready to run the application on another server, `dnu` is your friend.
10 |
11 | Publish a DNX application by calling `dnu publish` from the project directory. Here's what I recommend:
12 |
13 | ```
14 | dnu publish --runtime active --no-source -o ..\published-webapp --configuration Release
15 | ```
16 |
17 | The structure of a published web application looks like this:
18 |
19 | - **approot**
20 | - **packages**
21 | Any libraries from NuGet packages that you use will be copied to a directory structure under here. When you pass the `--no-source` option (more below) your own application is also compiled into a NuGet package under here.
22 | - **runtimes**
23 | The CLR runtime that you are using is copied here, with a folder per runtime. For .NET Core, this will be the full runtime - every file you need to run the application. For .NET Framework, it will just contain a few DNX-related assemblies and `DNX.exe`; it will rely on the full .NET Framework being installed globally.
24 | - **logs**
25 | By default this is an empty folder; you can enable logs manually. We'll cover this in a later section.
26 | - **wwwroot**
27 | This will contain a small web.config that is used only when hosting your application under IIS; it simply tells IIS to call the HTTP Platform Handler and let DNX take care of the rest. The folder will also contain any static files (CSS, JavaScript, images, etc.) that your application uses.
28 |
29 | Remember that DNX applications don't simply run - they have to be run by `DNX.exe`. `DNX.exe` must either be bundled with your application (which is why we pass `--runtime active`), or available on the PATH environment variable. As a developer, you have a version of DNX in your path already, but your production server won't.
30 |
31 | I> #### Active runtime?
32 | I> The active runtime is defined as a per-user environment variable. You can change the current runtime using `dnvm`, the .NET version manager. It's worth keeping this in mind - sometimes your active runtime will be different to what you might expect.
33 |
34 | ## To compile, or not to compile
35 |
36 | I also pass the `--no-source` flag when publishing. This ensures that `dnu publish` compiles the code and only publishes the compiled output, not the source code. Without this argument, DNX will dynamically compile the application on the fly as it runs with Roslyn. The Roslyn dynamic compilation features of ASP.NET 5 were designed to make for a better development experience; there's really no benefit to using them in production.
37 |
38 | In addition, publishing source code always leaves the chance that subsequent compilations could result in slightly different behavior. This is especially true if you target the full .NET Framework, since it is installed globally and could vary between machines depending on patches. When I test code in a pre-production environment and promote it to production, I want to feel confident that what I deploy to production is as similar as possible to what I tested. Compiling the source code into assemblies as part of the publish step removes one more possible cause of production problems.
39 |
40 | ## Publish once, deploy many times
41 |
42 | If you have more than one target environment, or more than one target server, then you should develop the habit of publishing once, deploying many times. In other words, publish the project once, then use the same published outputs when promoting between environments:
43 |
44 | 
45 |
46 | ## Running with Kestrel
47 |
48 | Now that you have published your application, you can test that it runs. Running it under Kestrel is easy. Simply go to the `approot` folder of your published directory, and run the `web.cmd` batch script:
49 |
50 | 
51 |
52 | This is made possible by the `commands` element inside your `project.json` file. The `dnu publish` tool takes any commands, and turns them into batch files. In my case, `project.json` contains:
53 |
54 | ```
55 | {
56 | // snip for brevity...
57 | "dependencies": {
58 | "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
59 | // ...
60 | },
61 |
62 | "commands": {
63 | "web": "Microsoft.AspNet.Server.Kestrel"
64 | }
65 | }
66 | ```
67 |
68 | So the `web.cmd` file that `dnu publish` generates calls DNX over the Kestrel console application, as we saw in the first chapter. Kestrel then listens on a port and serves the application.
69 |
70 | ## Running with IIS
71 |
72 | The published output folder is also ready to be used by IIS. Simply point IIS at the `wwwroot` folder of the published output:
73 |
74 | 
75 |
76 | T> #### Install HTTP Platform Handler
77 | T> Remember that DNX on IIS [requires the HTTP Platform Handler extension](http://www.iis.net/downloads/microsoft/httpplatformhandler) to be installed.
78 |
79 | This is made possible by the small `web.config` file inside `wwwroot`, which tells the worker process to dispatch all requests through the HTTP Platform Handler:
80 |
81 | ```
82 |
83 |
84 |
85 |
87 |
88 |
91 |
92 |
93 |
94 | ```
95 |
96 | Notice how the `processPath` attribute points back to the same `web.cmd` file that we called when we ran the app directly under Kestrel.
97 |
98 | ## Logging
99 |
100 | Whether you run your application directly under Kestrel or via IIS, DNX is still running as a console application. This means that you can capture log output from the console and send it to the `logs` folder that was created as part of the published output. Simply change the `stdoutLogEnabled` attribute in `web.config` to `true`.
101 |
102 | ### Summary
103 |
104 | In this chapter we explored `dnu publish`, a new standard way to prepare DNX applications for deployment. We reviewed some best practices like publish once, deploy many times, and saw how to run the application manually under Kestrel or IIS.
105 |
106 | In the next chapters we'll look at automating the publishing and deployment as part of a continuous delivery pipeline.
107 |
--------------------------------------------------------------------------------
/manuscript/40-configuration.md:
--------------------------------------------------------------------------------
1 | # Configuring Applications
2 |
3 | Long-time .NET developers will be familiar with configuration files like `web.config` and `app.config`, as well as web configuration transform files (`web.release.config`). Applications read configuration from these files using the `System.Configuration` assembly.
4 |
5 | In ASP.NET 5 and DNX, the configuration model has changed. Instead of the `.config` file format, you can provide configuration data from a variety of sources:
6 |
7 | - In code
8 | - JSON files
9 | - XML files
10 | - INI files
11 | - Environment variables
12 | - Command line arguments
13 |
14 | At runtime,
15 |
16 |
--------------------------------------------------------------------------------
/manuscript/50-octopus.md:
--------------------------------------------------------------------------------
1 | # Deployment with Octopus
2 |
3 | In this chapter, we will set up an automated deployment pipeline of our application using Octopus Deploy.
4 |
5 | ## Introducing Octopus Deploy
6 |
7 | ## Setting up the environment
8 |
9 | ## Deployment process
10 |
11 | ## Configuration and AppSettings.json
12 |
13 | ## Deployment
14 |
15 | ### Summary
16 |
--------------------------------------------------------------------------------
/manuscript/book.txt:
--------------------------------------------------------------------------------
1 | 00-intro.md
2 | 20-execution.md
3 | 25-http.md
4 | 30-publishing.md
5 | 50-octopus.md
6 |
--------------------------------------------------------------------------------
/manuscript/diagrams/iis-kestrel.txt:
--------------------------------------------------------------------------------
1 | Client->HTTP.sys: Request
2 | HTTP.sys->SVCHost.exe (WAS+WWW): Request
3 | SVCHost.exe (WAS+WWW)-->*W3WP.exe Worker Process: Ensure worker process
4 | note right of W3WP.exe Worker Process:
5 | Only loads HTTPPlatformHandler module
6 | end note
7 | HTTP.sys->W3WP.exe Worker Process: Request
8 | W3WP.exe Worker Process-->*DNX.exe (Kestrel): Starts
9 | W3WP.exe Worker Process->+DNX.exe (Kestrel): Request
10 | note right of DNX.exe (Kestrel):
11 | - OWIN middleware
12 | - ASP.NET 5.0
13 | - Your code
14 | end note
15 |
16 | DNX.exe (Kestrel)->-W3WP.exe Worker Process: Response
17 | W3WP.exe Worker Process->HTTP.sys: Response
18 | HTTP.sys->Client: Response
19 |
--------------------------------------------------------------------------------
/manuscript/diagrams/kestrel.txt:
--------------------------------------------------------------------------------
1 | Client->+DNX.exe (Kestrel): Request
2 | note right of DNX.exe (Kestrel):
3 | - OWIN middleware
4 | - ASP.NET 5.0
5 | - Your code
6 | end note
7 | DNX.exe (Kestrel)->Client: Response
8 |
--------------------------------------------------------------------------------
/manuscript/images/app-pool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/app-pool.png
--------------------------------------------------------------------------------
/manuscript/images/build-once.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/build-once.png
--------------------------------------------------------------------------------
/manuscript/images/dnu-console-output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/dnu-console-output.png
--------------------------------------------------------------------------------
/manuscript/images/iis-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/iis-add.png
--------------------------------------------------------------------------------
/manuscript/images/iis-kestrel-request.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/iis-kestrel-request.png
--------------------------------------------------------------------------------
/manuscript/images/iis-process-model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/iis-process-model.png
--------------------------------------------------------------------------------
/manuscript/images/kestrel-request.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/kestrel-request.png
--------------------------------------------------------------------------------
/manuscript/images/myapp-procexp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/myapp-procexp.png
--------------------------------------------------------------------------------
/manuscript/images/myapp-taskmgr-dnx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/myapp-taskmgr-dnx.png
--------------------------------------------------------------------------------
/manuscript/images/myapp-taskmgr-legacy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/myapp-taskmgr-legacy.png
--------------------------------------------------------------------------------
/manuscript/images/no-aspnet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/no-aspnet.png
--------------------------------------------------------------------------------
/manuscript/images/run-kestrel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/run-kestrel.png
--------------------------------------------------------------------------------
/manuscript/images/title_page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/title_page.jpg
--------------------------------------------------------------------------------
/manuscript/images/title_page.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OctopusDeploy/ASP.NET-Deployment-Book/baad6a34bf5af78b7bea49992b4f33a3052e8d67/manuscript/images/title_page.psd
--------------------------------------------------------------------------------
/samples/MyApp-CLR/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/MyApp-CLR/MyApp-CLR.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {969D6C16-0B6A-4ACF-917A-FF8529BF020D}
8 | Exe
9 | Properties
10 | MyApp
11 | MyApp
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
--------------------------------------------------------------------------------
/samples/MyApp-CLR/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace MyApp
5 | {
6 | class Program
7 | {
8 | static void Main(string[] args)
9 | {
10 | Console.WriteLine("Hello, world!");
11 | Thread.Sleep(10000);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/samples/MyApp-CLR/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyApp-CLR")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("969d6c16-0b6a-4acf-917a-ff8529bf020d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/samples/MyApp-DNX/MyApp-DNX.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 | b64d3af1-88e5-4290-b47a-b3cbcba1cfc1
10 | MyApp
11 | ..\artifacts\obj\$(MSBuildProjectName)
12 | ..\artifacts\bin\$(MSBuildProjectName)\
13 |
14 |
15 | 2.0
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/MyApp-DNX/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace MyApp
5 | {
6 | class Program
7 | {
8 | static void Main(string[] args)
9 | {
10 | Console.WriteLine("Hello, world!");
11 | //Thread.Sleep(10000);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/samples/MyApp-DNX/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyApp_DNX")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b64d3af1-88e5-4290-b47a-b3cbcba1cfc1")]
24 |
--------------------------------------------------------------------------------
/samples/MyApp-DNX/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {}
3 | }
--------------------------------------------------------------------------------
/samples/MyApp-DNX/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "1.0.0-rc1-final"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/samples/MyApp-DNX/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "description": "MyApp-DNX Console Application",
4 | "authors": [ "Administrator" ],
5 | "tags": [ "" ],
6 | "projectUrl": "",
7 | "licenseUrl": "",
8 |
9 | "compilationOptions": {
10 | "emitEntryPoint": true
11 | },
12 |
13 | "dependencies": {
14 | },
15 |
16 | "commands": {
17 | "MyApp": "MyApp-DNX"
18 | },
19 |
20 | "frameworks": {
21 | "dnx451": { },
22 | "dnxcore50": {
23 | "dependencies": {
24 | "Microsoft.CSharp": "4.0.1-beta-23516",
25 | "System.Collections": "4.0.11-beta-23516",
26 | "System.Console": "4.0.0-beta-23516",
27 | "System.Linq": "4.0.1-beta-23516",
28 | "System.Threading": "4.0.11-beta-23516"
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/samples/Samples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.23107.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp-CLR", "MyApp-CLR\MyApp-CLR.csproj", "{969D6C16-0B6A-4ACF-917A-FF8529BF020D}"
7 | EndProject
8 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyApp-DNX", "MyApp-DNX\MyApp-DNX.xproj", "{B64D3AF1-88E5-4290-B47A-B3CBCBA1CFC1}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{58EB186D-2402-47AE-93D1-ED4E392FF94B}"
11 | ProjectSection(SolutionItems) = preProject
12 | MyApp-DNX\global.json = MyApp-DNX\global.json
13 | EndProjectSection
14 | EndProject
15 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WebApp", "WebApp\WebApp.xproj", "{FD7CA51D-3DF3-426E-93EF-E2EFD19ABC10}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Release|Any CPU = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {969D6C16-0B6A-4ACF-917A-FF8529BF020D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {969D6C16-0B6A-4ACF-917A-FF8529BF020D}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {969D6C16-0B6A-4ACF-917A-FF8529BF020D}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {969D6C16-0B6A-4ACF-917A-FF8529BF020D}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {B64D3AF1-88E5-4290-B47A-B3CBCBA1CFC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {B64D3AF1-88E5-4290-B47A-B3CBCBA1CFC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {B64D3AF1-88E5-4290-B47A-B3CBCBA1CFC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {B64D3AF1-88E5-4290-B47A-B3CBCBA1CFC1}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {FD7CA51D-3DF3-426E-93EF-E2EFD19ABC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {FD7CA51D-3DF3-426E-93EF-E2EFD19ABC10}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {FD7CA51D-3DF3-426E-93EF-E2EFD19ABC10}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {FD7CA51D-3DF3-426E-93EF-E2EFD19ABC10}.Release|Any CPU.Build.0 = Release|Any CPU
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | EndGlobal
40 |
--------------------------------------------------------------------------------
/samples/WebApp/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNet.Mvc;
6 |
7 | namespace WebApp.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | public class ValuesController : Controller
11 | {
12 | // GET: api/values
13 | [HttpGet]
14 | public IEnumerable Get()
15 | {
16 | return new string[] { "value1", "value2" };
17 | }
18 |
19 | // GET api/values/5
20 | [HttpGet("{id}")]
21 | public string Get(int id)
22 | {
23 | return "value";
24 | }
25 |
26 | // POST api/values
27 | [HttpPost]
28 | public void Post([FromBody]string value)
29 | {
30 | }
31 |
32 | // PUT api/values/5
33 | [HttpPut("{id}")]
34 | public void Put(int id, [FromBody]string value)
35 | {
36 | }
37 |
38 | // DELETE api/values/5
39 | [HttpDelete("{id}")]
40 | public void Delete(int id)
41 | {
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/samples/WebApp/Project_Readme.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Welcome to ASP.NET 5
6 |
127 |
128 |
129 |
130 |
138 |
139 |
140 |
141 |
This application consists of:
142 |
143 | - Sample pages using ASP.NET MVC 6
144 | - Gulp and Bower for managing client-side libraries
145 | - Theming using Bootstrap
146 |
147 |
148 |
160 |
161 |
Overview
162 |
171 |
172 |
173 |
Run & Deploy
174 |
180 |
181 |
182 |
185 |
186 |
187 |
188 |
189 |
--------------------------------------------------------------------------------
/samples/WebApp/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:61994/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "launchUrl": "api/values",
15 | "environmentVariables": {
16 | "Hosting:Environment": "Development"
17 | }
18 | },
19 | "web": {
20 | "commandName": "web",
21 | "environmentVariables": {
22 | "Hosting:Environment": "Development"
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/samples/WebApp/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNet.Builder;
6 | using Microsoft.AspNet.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace WebApp
12 | {
13 | public class Startup
14 | {
15 | public Startup(IHostingEnvironment env)
16 | {
17 | // Set up configuration sources.
18 | var builder = new ConfigurationBuilder()
19 | .AddJsonFile("appsettings.json")
20 | .AddEnvironmentVariables();
21 | Configuration = builder.Build();
22 | }
23 |
24 | public IConfigurationRoot Configuration { get; set; }
25 |
26 | // This method gets called by the runtime. Use this method to add services to the container.
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 | // Add framework services.
30 | services.AddMvc();
31 | }
32 |
33 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
34 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
35 | {
36 | loggerFactory.AddConsole(Configuration.GetSection("Logging"));
37 | loggerFactory.AddDebug();
38 |
39 | app.UseIISPlatformHandler();
40 |
41 | app.UseStaticFiles();
42 |
43 | app.UseMvc();
44 | }
45 |
46 | // Entry point for the application.
47 | public static void Main(string[] args) => WebApplication.Run(args);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/samples/WebApp/WebApp.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 | fd7ca51d-3df3-426e-93ef-e2efd19abc10
10 | WebApp
11 | ..\artifacts\obj\$(MSBuildProjectName)
12 | ..\artifacts\bin\$(MSBuildProjectName)\
13 |
14 |
15 | 2.0
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/samples/WebApp/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Verbose",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/samples/WebApp/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "compilationOptions": {
4 | "emitEntryPoint": true
5 | },
6 |
7 | "dependencies": {
8 | "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
9 | "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
10 | "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
11 | "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
12 | "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
13 | "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
14 | "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
15 | "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
16 | "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
17 | },
18 |
19 | "commands": {
20 | "web": "Microsoft.AspNet.Server.Kestrel"
21 | },
22 |
23 | "frameworks": {
24 | "dnx451": { },
25 | "dnxcore50": { }
26 | },
27 |
28 | "exclude": [
29 | "wwwroot",
30 | "node_modules"
31 | ],
32 | "publishExclude": [
33 | "**.user",
34 | "**.vspscc"
35 | ]
36 | }
37 |
--------------------------------------------------------------------------------
/samples/WebApp/wwwroot/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------