Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit c27c629

Browse files
kapunahelewongwardbell
authored andcommitted
docs(vs-cookbook, deployment): update for use in VS 2015 (#3433)
1 parent 60e38b0 commit c27c629

File tree

3 files changed

+130
-67
lines changed

3 files changed

+130
-67
lines changed

public/docs/ts/latest/cookbook/visual-studio-2015.jade

Lines changed: 113 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,35 @@ include ../_util-fns
88
Angular QuickStart files in **Visual Studio 2015 within an ASP.NET 4.x project**.
99
.l-sub-section
1010
:marked
11-
There is no *live example* for this cookbook because it describes Visual Studio, not the application.
11+
There is no *live example* for this cookbook because it describes Visual Studio, not
12+
the QuickStart application itself.
1213

1314
.l-main-section
1415
<a id="asp-net-4"></a>
1516
:marked
1617
## ASP.NET 4.x Project
1718

18-
This cookbook explains how to set up the QuickStart files with an **ASP.NET 4.x project** in
19-
Visual Studio 2015.
19+
To set up the QuickStart files with an **ASP.NET 4.x project** in
20+
Visual Studio 2015, follow these steps:
21+
22+
:marked
23+
* [Prerequisite](#prereq1): Install Node.js.
24+
* [Prerequisite](#prereq2): Install Visual Studio 2015 Update 3.
25+
* [Prerequisite](#prereq3): Configure external web tools.
26+
* [Prerequisite](#prereq4): Install TypeScript 2.2 for Visual Studio 2015.
27+
* [Step 1](#download): Download the QuickStart files.
28+
* [Step 2](#create-project): Create the Visual Studio ASP.NET project.
29+
* [Step 3](#copy): Copy the QuickStart files into the ASP.NET project folder.
30+
* [Step 4](#restore): Restore required packages.
31+
* [Step 5](#build-and-run): Build and run the app.
32+
2033
.l-sub-section
2134
:marked
2235
If you prefer a `File | New Project` experience and are using **ASP.NET Core**,
2336
then consider the _experimental_
2437
<a href="http://blog.stevensanderson.com/2016/10/04/angular2-template-for-visual-studio/" target="_blank">ASP.NET Core + Angular template for Visual Studio 2015</a>.
2538
Note that the resulting code does not map to the docs. Adjust accordingly.
26-
27-
:marked
28-
The steps are as follows:
29-
30-
* [Prerequisite](#prereq1): Install Node.js
31-
* [Prerequisite](#prereq2): Install Visual Studio 2015 Update 3
32-
* [Prerequisite](#prereq3): Configure External Web tools
33-
* [Prerequisite](#prereq4): Install TypeScript 2 for Visual Studio 2015
34-
* [Step 1](#download): Download the QuickStart files
35-
* [Step 2](#create-project): Create the Visual Studio ASP.NET project
36-
* [Step 3](#copy): Copy the QuickStart files into the ASP.NET project folder
37-
* [Step 4](#restore): Restore required packages
38-
* [Step 5](#build-and-run): Build and run the app
39-
39+
4040
.l-main-section
4141
h2#prereq1 Prerequisite: Node.js
4242
:marked
@@ -45,7 +45,7 @@ h2#prereq1 Prerequisite: Node.js
4545
.l-sub-section
4646
:marked
4747
**Verify that you are running node version `4.6.x` or greater, and npm `3.x.x` or greater**
48-
by running `node -v` and `npm -v` in a terminal/console window.
48+
by running `node -v` and `npm -v` in a terminal window.
4949
Older versions produce errors.
5050

5151
.l-main-section
@@ -63,29 +63,30 @@ h2#prereq3 Prerequisite: Configure External Web tools
6363
:marked
6464
Configure Visual Studio to use the global external web tools instead of the tools that ship with Visual Studio:
6565

66-
* Open the **Options** dialog with `Tools` | `Options`
66+
* Open the **Options** dialog with `Tools` | `Options`.
6767
* In the tree on the left, select `Projects and Solutions` | `External Web Tools`.
6868
* On the right, move the `$(PATH)` entry above the `$(DevEnvDir`) entries. This tells Visual Studio to
6969
use the external tools (such as npm) found in the global path before using its own version of the external tools.
7070
* Click OK to close the dialog.
7171
* Restart Visual Studio for this change to take effect.
7272

73-
Visual Studio will now look first for external tools in the current workspace and
74-
if not found then look in the global path and if it is not found there, Visual Studio
75-
will use its own versions of the tools.
73+
Visual Studio now looks first for external tools in the current workspace and
74+
if it doesn't find them, it looks in the global path. If Visual Studio doesn't
75+
find them in either location, it will use its own versions of the tools.
7676

7777
.l-main-section
78-
h2#prereq4 Prerequisite: Install TypeScript 2 for Visual Studio 2015
78+
h2#prereq4 Prerequisite: Install TypeScript 2.2 for Visual Studio 2015
7979
:marked
80-
While Visual Studio Update 3 ships with TypeScript support out of the box, it currently doesn’t ship with TypeScript 2,
80+
While Visual Studio Update 3 ships with TypeScript support out of the box, it currently doesn’t ship with TypeScript 2.2,
8181
which you need to develop Angular applications.
8282

83-
To install TypeScript 2:
83+
To install TypeScript 2.2:
84+
85+
* Download and install **[TypeScript 2.2 for Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48593)**
8486

85-
* Download and install **[TypeScript 2.0 for Visual Studio 2015](http://download.microsoft.com/download/6/D/8/6D8381B0-03C1-4BD2-AE65-30FF0A4C62DA/TS2.0.3-TS-release20-nightly-20160921.1/TypeScript_Dev14Full.exe)**
86-
* OR install it with npm: `npm install -g [email protected]`.
87+
* OR install it with npm: `npm install -g [email protected]`.
8788

88-
You can find out more about TypeScript 2 support in Visual studio **[here](https://blogs.msdn.microsoft.com/typescript/2016/09/22/announcing-typescript-2-0/)**
89+
You can find out more about TypeScript 2.2 support in Visual studio **[here](https://blogs.msdn.microsoft.com/typescript/2017/02/22/announcing-typescript-2-2/)**.
8990

9091
At this point, Visual Studio is ready. It’s a good idea to close Visual Studio and
9192
restart it to make sure everything is clean.
@@ -94,7 +95,7 @@ h2#prereq4 Prerequisite: Install TypeScript 2 for Visual Studio 2015
9495
h2#download Step 1: Download the QuickStart files
9596
:marked
9697
[Download the QuickStart source](https://github.com/angular/quickstart)
97-
from github. If you downloaded as a zip file, extract the files.
98+
from GitHub. If you downloaded as a zip file, extract the files.
9899

99100
.l-main-section
100101
h2#create-project Step 2: Create the Visual Studio ASP.NET project
@@ -109,25 +110,25 @@ h2#create-project Step 2: Create the Visual Studio ASP.NET project
109110

110111
.l-sub-section
111112
:marked
112-
In this cookbook we'll select the `Empty` template with no added folders,
113-
no authentication and no hosting. Pick the template and options appropriate for your project.
113+
This cookbook uses the `Empty` template with no added folders,
114+
no authentication, and no hosting. Pick the template and options appropriate for your project.
114115

115116
.l-main-section
116117
h2#copy Step 3: Copy the QuickStart files into the ASP.NET project folder
117118

118119
:marked
119-
Copy the QuickStart files we downloaded from github into the folder containing the `.csproj` file.
120+
Copy the QuickStart files you downloaded from GitHub into the folder containing the `.csproj` file.
120121
Include the files in the Visual Studio project as follows:
121122

122123
* Click the `Show All Files` button in Solution Explorer to reveal all of the hidden files in the project.
123124
* Right-click on each folder/file to be included in the project and select `Include in Project`.
124125
Minimally, include the following folder/files:
125-
126-
* app folder (answer *No* if asked to search for TypeScript Typings)
127-
* styles.css
128-
* index.html
126+
127+
* src/app folder (answer *No* if asked to search for TypeScript Typings)
128+
* src/styles.css
129+
* src/index.html
129130
* package.json
130-
* tsconfig.json
131+
* src/tsconfig.json
131132

132133
.l-main-section
133134
h2#restore Step 4: Restore the required packages
@@ -139,32 +140,94 @@ h2#restore Step 4: Restore the required packages
139140
It may take some time.
140141
* If desired, open the Output window (`View` | `Output`) to watch the npm commands execute.
141142
* Ignore the warnings.
142-
* When the restore is finished, a message should say: `npm command completed with exit code 0`.
143+
* When the restore is finished, a message in the bottom message bar of Visual Studio
144+
should say: `Installing packages complete`. Be patient. This could take a while.
143145
* Click the `Refresh` icon in Solution Explorer.
144146
* **Do not** include the `node_modules` folder in the project. Let it be a hidden project folder.
145147

146148
.l-main-section
147149
h2#build-and-run Step 5: Build and run the app
148150

149151
:marked
150-
First, ensure that `index.html` is set as the start page.
152+
First, ensure that `src/index.html` is set as the start page.
151153
Right-click `index.html` in Solution Explorer and select option `Set As Start Page`.
154+
155+
### To run in VS with F5
156+
157+
Most Visual Studio developers like to press the F5 key and see the IIS server come up.
158+
To use the IIS server with the QuickStart app, you must make the following three changes.
159+
160+
1. In `index.html`, change base href from `<base href="/">` to `<base href="/src/">`.
161+
2. Also in `index.html`, change the scripts to use `/node_modules` with a slash
162+
instead of `node_modules` without the slash.
163+
3. In `src/systemjs.config.js`, near the top of the file,
164+
change the npm `path` to `/node_modules/` with a slash.
152165

153-
Build and launch the app with debugger by clicking the **Run** button or press `F5`.
166+
.alert.is-important
167+
:marked
168+
After these changes, `npm start` no longer works.
169+
You must choose to configure _either_ for F5 with IIS _or_ for `npm start` with the lite-server.
170+
171+
:marked
172+
### For apps that use routing
173+
174+
If your app uses routing, you need to teach the server to always return
175+
`index.html` when the user asks for an HTML page
176+
for reasons explained in the [Deployment](deployment.html#fallback) guide.
177+
178+
Everything seems fine while you move about _within_ the app.
179+
But you'll see the problem right away if you refresh the browser
180+
or paste a link to an app page (called a "deep link") into the browser address bar.
181+
182+
You'll most likely get a *404 - Page Not Found* response from the serer
183+
for any address other than `/` or `/index.html`.
184+
185+
You have to configure the server to return `index.html` for requests to these "unknown" pages.
186+
The `lite-server` development server does out-of-the-box.
187+
If you've switched over to F5 and IIS, you have to configure IIS to do it.
188+
This section walks through the steps to adapt the QuickStart application.
189+
190+
#### Configure IIS rewrite rules
191+
192+
Visual Studio ships with IIS Express, which has the rewrite module baked in.
193+
However, if you're using regular IIS you'll have to install the rewrite
194+
module.
195+
196+
Tell Visual Studio how to handle requests for route app pages by adding these
197+
rewrite rules near the bottom of the `web.config`:
198+
199+
code-example(format='.').
200+
&lt;system.webServer&gt;
201+
&lt;rewrite&gt;
202+
&lt;rules&gt;
203+
&lt;rule name="Angular Routes" stopProcessing="true"&gt;
204+
&lt;match url=".*" /&gt;
205+
&lt;conditions logicalGrouping="MatchAll"&gt;
206+
&lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;
207+
&lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;
208+
&lt;/conditions&gt;
209+
&lt;action type="Rewrite" url="/src/" /&gt;
210+
&lt;/rule&gt;
211+
&lt;/rules&gt;
212+
&lt;/rewrite&gt;
213+
&lt;/system.webServer&gt;
214+
215+
.l-sub-section
216+
:marked
217+
The match url, `<match url=".*" />`, will rewrite every request. You'll have to adjust this if
218+
you want some requests to get through, such as web API requests.
219+
220+
The URL in `<action type="Rewrite" url="/src/"/>` should
221+
match the base href in `index.html`.
222+
223+
:marked
224+
Build and launch the app with debugger by clicking the **Run** button or by pressing `F5`.
225+
154226
.l-sub-section
155227
:marked
156228
It's faster to run without the debugger by pressing `Ctrl-F5`.
157229
:marked
158230
The default browser opens and displays the QuickStart sample application.
159231

160-
Try editing any of the project files. *Save* and refresh the browser to
232+
Try editing any of the project files. Save and refresh the browser to
161233
see the changes.
162-
163-
.l-main-section
164-
h2#routing Note on Routing Applications
165-
:marked
166-
If this application used the Angular router, a browser refresh could return a *404 - Page Not Found*.
167-
Look at the address bar. Does it contain a navigation url (a "deep link") ... any path other than `/` or `/index.html`?
168-
169-
You'll have to configure the server to return `index.html` for these requests.
170-
Until you do, remove the navigation path and refresh again.

public/docs/ts/latest/guide/deployment.jade

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -456,21 +456,21 @@ code-example(format=".").
456456
:marked
457457
* [IIS](https://www.iis.net/): add a rewrite rule to `web.config`, similar to the one shown
458458
[here](http://stackoverflow.com/a/26152011/2116927):
459-
code-example(format="." escape="html").
460-
<system.webServer>
461-
<rewrite>
462-
<rules>
463-
<rule name="Angular Routes" stopProcessing="true">
464-
<match url=".*" />
465-
<conditions logicalGrouping="MatchAll">
466-
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
467-
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
468-
</conditions>
469-
<action type="Rewrite" url="/" />
470-
</rule>
471-
</rules>
472-
</rewrite>
473-
</system.webServer>
459+
code-example(format='.').
460+
&lt;system.webServer&gt;
461+
&lt;rewrite&gt;
462+
&lt;rules&gt;
463+
&lt;rule name="Angular Routes" stopProcessing="true"&gt;
464+
&lt;match url=".*" /&gt;
465+
&lt;conditions logicalGrouping="MatchAll"&gt;
466+
&lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;
467+
&lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;
468+
&lt;/conditions&gt;
469+
&lt;action type="Rewrite" url="/src/" /&gt;
470+
&lt;/rule&gt;
471+
&lt;/rules&gt;
472+
&lt;/rewrite&gt;
473+
&lt;/system.webServer&gt;
474474

475475
:marked
476476
* [GitHub Pages](https://pages.github.com/): you can't

public/docs/ts/latest/guide/testing.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ figure.image-display
16821682
`By.css('*:not([highlight])')` finds _any_ element that does not have the directive.
16831683

16841684
// Removed on 12/02/2016 when ceased public discussion of the `Renderer`. Revive in future?
1685-
1685+
:marked
16861686
* `DebugElement.styles` affords access to element styles even in the absence of a real browser, thanks to the `DebugElement` abstraction.
16871687
But feel free to exploit the `nativeElement` when that seems easier or more clear than the abstraction.
16881688

@@ -1692,7 +1692,7 @@ figure.image-display
16921692
and its `defaultColor`.
16931693

16941694
// Removed on 12/02/2016 when ceased public discussion of the `Renderer`. Revive in future?
1695-
1695+
:marked
16961696
* `DebugElement.properties` affords access to the artificial custom property that is set by the directive.
16971697

16981698
a(href="#top").to-top Back to top

0 commit comments

Comments
 (0)