{"componentChunkName":"component---src-templates-handbook-tsx","path":"/docs/handbook/asp-net-core.html","result":{"data":{"markdownRemark":{"id":"9b022709-7d0a-59bb-94a3-9d3635b9c46e","excerpt":"Setup Install ASP.NET Core and TypeScript First, install ASP.NET Core if you need it. This quick-start guide requires Visual Studio 2015 or 2017. Next, if your…","html":"<h1 id=\"setup\"><a href=\"#setup\" aria-label=\"setup permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setup</h1>\n<h2 id=\"install-aspnet-core-and-typescript\"><a href=\"#install-aspnet-core-and-typescript\" aria-label=\"install aspnet core and typescript permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Install ASP.NET Core and TypeScript</h2>\n<p>First, <a href=\"https://get.asp.net\">install ASP.NET Core</a> if you need it. This quick-start guide requires Visual Studio 2015 or 2017.</p>\n<p>Next, if your version of Visual Studio does not already have the latest TypeScript, you can <a href=\"http://www.microsoft.com/en-us/download/details.aspx?id=48593\">install it</a>.</p>\n<h2 id=\"create-a-new-project\"><a href=\"#create-a-new-project\" aria-label=\"create a new project permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Create a new project</h2>\n<ol>\n<li>Choose <strong>File</strong></li>\n<li>Choose <strong>New Project</strong> (Ctrl + Shift + N)</li>\n<li>Choose <strong>Visual C#</strong></li>\n<li>\n<p>For VS2015, choose <strong>ASP.NET Web Application</strong> > <strong>ASP.NET 5 Empty</strong>, and let’s uncheck “Host in the cloud” since we’re going to run this locally.</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/new-asp-project-empty.png\" alt=\"Use empty template\"></p>\n<p>For VS2017, choose <strong>ASP.NET Core Web Application (.NET Core)</strong> > <strong>ASP.NET Core 1.1 Empty</strong> instead.</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/new-asp-project-empty-17.PNG\" alt=\"Use empty template VS2017\"></p>\n</li>\n</ol>\n<p>Run the application and make sure that it works.</p>\n<h2 id=\"set-up-the-server\"><a href=\"#set-up-the-server\" aria-label=\"set up the server permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Set up the server</h2>\n<h3 id=\"vs2015\"><a href=\"#vs2015\" aria-label=\"vs2015 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>VS2015</h3>\n<p>In <code>project.json</code> add another entry in <code>\"dependencies\"</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #A31515\">\"Microsoft.AspNet.StaticFiles\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0.0-rc1-final\"</span></code></div></pre>\n<p>The resulting dependencies should look like this:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"dependencies\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"Microsoft.AspNet.IISPlatformHandler\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0.0-rc1-final\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"Microsoft.AspNet.Server.Kestrel\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0.0-rc1-final\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"Microsoft.AspNet.StaticFiles\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0.0-rc1-final\"</span>\n<span style=\"color: #000000\">  },</span></code></div></pre>\n<p>Replace the body of <code>Configure</code> in <code>Startup.cs</code> with</p>\n<pre><code class=\"language-cs\">public void Configure(IApplicationBuilder app)\n{\n    app.UseIISPlatformHandler();\n    app.UseDefaultFiles();\n    app.UseStaticFiles();\n}\n</code></pre>\n<h3 id=\"vs2017\"><a href=\"#vs2017\" aria-label=\"vs2017 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>VS2017</h3>\n<p>Open <strong>Dependencies</strong> > <strong>Manage NuGet Packages</strong> > <strong>Browse</strong>. Search and install <code>Microsoft.AspNetCore.StaticFiles</code> 1.1.2:</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/install-nuget-packages.png\" alt=\"Install Microsoft.AspNetCore.StaticFiles\"></p>\n<p>Replace the body of <code>Configure</code> in <code>Startup.cs</code> with</p>\n<pre><code class=\"language-cs\">public void Configure(IApplicationBuilder app)\n{\n    app.UseDefaultFiles();\n    app.UseStaticFiles();\n}\n</code></pre>\n<p>You may need to restart VS for the red squiggly lines below <code>UseDefaultFiles</code> and <code>UseStaticFiles</code> to disappear.</p>\n<h1 id=\"add-typescript\"><a href=\"#add-typescript\" aria-label=\"add typescript permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add TypeScript</h1>\n<p>The next step is to add a folder for TypeScript.</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/new-folder.png\" alt=\"Create new folder\"></p>\n<p>We’ll just call it <code>scripts</code>.</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/scripts-folder.png\" alt=\"scripts folder\"></p>\n<h2 id=\"add-typescript-code\"><a href=\"#add-typescript-code\" aria-label=\"add typescript code permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add TypeScript code</h2>\n<p>Right click on <code>scripts</code> and click <strong>New Item</strong>.\nThen choose <strong>TypeScript File</strong> (it may be in the .NET Core section) and name the file <code>app.ts</code>.</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/new-item.png\" alt=\"New item\"></p>\n<h2 id=\"add-example-code\"><a href=\"#add-example-code\" aria-label=\"add example code permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add example code</h2>\n<p>Type the following code into app.ts.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> sayHello() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> compiler = (document.getElementById(</span><span style=\"color: #A31515\">\"compiler\"</span><span style=\"color: #000000\">) </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> HTMLInputElement).value;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> framework = (document.getElementById(</span><span style=\"color: #A31515\">\"framework\"</span><span style=\"color: #000000\">) </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> HTMLInputElement).value;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">`Hello from </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\">compiler</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\"> and </span><span style=\"color: #0000FF\">${</span><span style=\"color: #A31515\">framework</span><span style=\"color: #0000FF\">}</span><span style=\"color: #A31515\">!`</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"set-up-the-build\"><a href=\"#set-up-the-build\" aria-label=\"set up the build permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Set up the build</h2>\n<h3 id=\"configure-the-typescript-compiler\"><a href=\"#configure-the-typescript-compiler\" aria-label=\"configure the typescript compiler permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configure the TypeScript compiler</h3>\n<p>First we need to tell TypeScript how to build.\nRight click on the scripts folder and click <strong>New Item</strong>.\nThen choose <strong>TypeScript Configuration File</strong> and use the default name <code>tsconfig.json</code>.</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/new-tsconfig.png\" alt=\"Create tsconfig.json\"></p>\n<p>Replace the default <code>tsconfig.json</code> with the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0451A5\">\"noImplicitAny\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0451A5\">\"noEmitOnError\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0451A5\">\"sourceMap\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0451A5\">\"target\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"es5\"</span>\n<span style=\"color: #000000\">  },</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"files\"</span><span style=\"color: #000000\">: [</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #A31515\">\"./app.ts\"</span>\n<span style=\"color: #000000\">  ],</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"compileOnSave\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This is similar to the default, with the following differences:</p>\n<ol>\n<li>It sets <code>\"noImplicitAny\": true</code>.</li>\n<li>It explicitly lists <code>\"files\"</code> instead of relying on <code>\"excludes\"</code>.</li>\n<li>It sets <code>\"compileOnSave\": true</code>.</li>\n</ol>\n<p><code>\"noImplicitAny\"</code> is good idea whenever you’re writing new code — you can make sure that you don’t write any untyped code by mistake.\n<code>\"compileOnSave\"</code> makes it easy to update your code in a running web app.</p>\n<h3 id=\"set-up-npm\"><a href=\"#set-up-npm\" aria-label=\"set up npm permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Set up NPM</h3>\n<p>Now we need to set up NPM so we can download JavaScript packages.\nRight click on the project and click <strong>New Item</strong>.\nThen choose <strong>NPM Configuration File</strong> and use the default name <code>package.json</code>.\nInside <code>\"devDependencies\"</code> add “gulp” and “del”:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #A31515\">\"devDependencies\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"gulp\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"3.9.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"del\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"2.2.0\"</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Visual Studio should start installing gulp and del as soon as you save the file.\nIf not, right-click package.json and then <strong>Restore Packages</strong>.</p>\n<h3 id=\"set-up-gulp\"><a href=\"#set-up-gulp\" aria-label=\"set up gulp permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Set up gulp</h3>\n<p>Finally, add a new JavaScript file named <code>gulpfile.js</code>.\nPut the following code inside:</p>\n<pre class=\"shiki\"><div class=\"language-id\">js</div><div class='code-container'><code><span style=\"color: #008000\">/// &lt;binding AfterBuild='default' Clean='clean' /&gt;</span>\n<span style=\"color: #008000\">/*</span>\n<span style=\"color: #008000\">This file is the main entry point for defining Gulp tasks and using Gulp plugins.</span>\n<span style=\"color: #008000\">Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007</span>\n<span style=\"color: #008000\">*/</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> gulp = require(</span><span style=\"color: #A31515\">'gulp'</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> del = require(</span><span style=\"color: #A31515\">'del'</span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #0000FF\">var</span><span style=\"color: #000000\"> paths = {</span>\n<span style=\"color: #000000\">    scripts: [</span><span style=\"color: #A31515\">'scripts/**/*.js'</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">'scripts/**/*.ts'</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">'scripts/**/*.map'</span><span style=\"color: #000000\">],</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #000000\">gulp.task(</span><span style=\"color: #A31515\">'clean'</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> () {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> del([</span><span style=\"color: #A31515\">'wwwroot/scripts/**/*'</span><span style=\"color: #000000\">]);</span>\n<span style=\"color: #000000\">});</span>\n\n<span style=\"color: #000000\">gulp.task(</span><span style=\"color: #A31515\">'default'</span><span style=\"color: #000000\">, </span><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> () {</span>\n<span style=\"color: #000000\">    gulp.src(paths.scripts).pipe(gulp.dest(</span><span style=\"color: #A31515\">'wwwroot/scripts'</span><span style=\"color: #000000\">))</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<p>The first line tells Visual Studio to run the task ‘default’ after the build finishes.\nIt will also run the ‘clean’ task when you ask Visual Studio to clean the build.</p>\n<p>Now right-click on <code>gulpfile.js</code> and click <strong>Task Runner Explorer</strong>.\nIf ‘default’ and ‘clean’ tasks don’t show up, refresh the explorer:</p>\n<p><img src=\"../../assets/images/tutorials/aspnet/task-runner-explorer.png\" alt=\"Refresh Task Runner Explorer\"></p>\n<h2 id=\"write-an-html-page\"><a href=\"#write-an-html-page\" aria-label=\"write an html page permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Write an HTML page</h2>\n<p>Add a New Item named <code>index.html</code> inside <code>wwwroot</code>.\nUse the following code for <code>index.html</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">html</div><div class='code-container'><code><span style=\"color: #800000\">&lt;!</span><span style=\"color: #000000\">DOCTYPE html</span><span style=\"color: #800000\">&gt;</span>\n<span style=\"color: #800000\">&lt;html&gt;</span>\n<span style=\"color: #800000\">&lt;head&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;meta</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">charset</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"utf-8\"</span><span style=\"color: #800000\"> /&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;script</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">src</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"scripts/app.js\"</span><span style=\"color: #800000\">&gt;&lt;/script&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;title&gt;&lt;/title&gt;</span>\n<span style=\"color: #800000\">&lt;/head&gt;</span>\n<span style=\"color: #800000\">&lt;body&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;div</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">id</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"message\"</span><span style=\"color: #800000\">&gt;&lt;/div&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;div&gt;</span>\n<span style=\"color: #000000\">        Compiler: </span><span style=\"color: #800000\">&lt;input</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">id</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"compiler\"</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">value</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"TypeScript\"</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">onkeyup</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"document.getElementById('message').innerText = sayHello()\"</span><span style=\"color: #800000\"> /&gt;&lt;br /&gt;</span>\n<span style=\"color: #000000\">        Framework: </span><span style=\"color: #800000\">&lt;input</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">id</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"framework\"</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">value</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"ASP.NET\"</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">onkeyup</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"document.getElementById('message').innerText = sayHello()\"</span><span style=\"color: #800000\"> /&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;/div&gt;</span>\n<span style=\"color: #800000\">&lt;/body&gt;</span>\n<span style=\"color: #800000\">&lt;/html&gt;</span></code></div></pre>\n<h2 id=\"test\"><a href=\"#test\" aria-label=\"test permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Test</h2>\n<ol>\n<li>Run the project.</li>\n<li>You should see a message when you type in the input boxes:</li>\n</ol>\n<p><img src=\"../../assets/images/tutorials/aspnet/running-demo.png\" alt=\"Picture of running demo\"></p>\n<h2 id=\"debug\"><a href=\"#debug\" aria-label=\"debug permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Debug</h2>\n<ol>\n<li>In Edge, press F12 and click the <strong>Debugger</strong> tab.</li>\n<li>Look in the first localhost folder, then scripts/app.ts</li>\n<li>Put a breakpoint on the line with <code>return</code>.</li>\n<li>Type in the boxes and confirm that the breakpoint hits in TypeScript code and that inspection works correctly.</li>\n</ol>\n<p><img src=\"../../assets/images/tutorials/aspnet/paused-demo.png\" alt=\"Demo paused on breakpoint\"></p>\n<p>That’s all you need to know to include basic TypeScript in your ASP.NET project.\nNext we’ll include Angular and write a simple Angular app.</p>\n<h1 id=\"add-angular-2\"><a href=\"#add-angular-2\" aria-label=\"add angular 2 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add Angular 2</h1>\n<h2 id=\"add-npm-dependencies\"><a href=\"#add-npm-dependencies\" aria-label=\"add npm dependencies permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add NPM dependencies</h2>\n<p>Add Angular 2 and SystemJS to <code>dependencies</code> in <code>package.json</code>.</p>\n<p>For VS2015, the new <code>dependencies</code> list:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"dependencies\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"angular2\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"2.0.0-beta.11\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"systemjs\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"0.19.24\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"gulp\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"3.9.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"del\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"2.2.0\"</span>\n<span style=\"color: #000000\">  },</span></code></div></pre>\n<p>For VS2017, due to the deprecation of peer dependencies in NPM3, we need to list Angular 2’s peer dependencies directly as dependencies as well:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">  </span><span style=\"color: #A31515\">\"dependencies\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"angular2\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"2.0.0-beta.11\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"reflect-metadata\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"0.1.2\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"rxjs\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"5.0.0-beta.2\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"zone.js\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"^0.6.4\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"systemjs\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"0.19.24\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"gulp\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"3.9.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"del\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"2.2.0\"</span>\n<span style=\"color: #000000\">  },</span></code></div></pre>\n<h2 id=\"update-tsconfigjson\"><a href=\"#update-tsconfigjson\" aria-label=\"update tsconfigjson permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Update tsconfig.json</h2>\n<p>Now that Angular 2 and its dependencies are installed, we need to enable TypeScript’s experimental support for decorators.\nWe also need to add declarations for ES2015, since Angular uses core-js for things like <code>Promise</code>.\nIn the future decorators will be the default and these settings will not be needed.</p>\n<p>Add <code>\"experimentalDecorators\": true, \"emitDecoratorMetadata\": true</code> to the <code>\"compilerOptions\"</code> section.\nNext, add <code>\"lib\": [\"es2015\", \"es5\", \"dom\"]</code> to <code>\"compilerOptions\"</code> as well to bring in declarations from ES2015.\nFinally, we’ll need to add a new entry in <code>\"files\"</code> for another file, <code>\"./model.ts\"</code>, which we’ll create.\nOur tsconfig should now look like this:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"compilerOptions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"noImplicitAny\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"noEmitOnError\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"sourceMap\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"experimentalDecorators\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"emitDecoratorMetadata\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"target\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"es5\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0451A5\">\"lib\"</span><span style=\"color: #000000\">: [</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #A31515\">\"es2015\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"es5\"</span><span style=\"color: #000000\">, </span><span style=\"color: #A31515\">\"dom\"</span>\n<span style=\"color: #000000\">        ]</span>\n<span style=\"color: #000000\">    },</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"files\"</span><span style=\"color: #000000\">: [</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"./app.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"./model.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #A31515\">\"./main.ts\"</span>\n<span style=\"color: #000000\">    ],</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"compileOnSave\"</span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">true</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"add-angular-to-the-gulp-build\"><a href=\"#add-angular-to-the-gulp-build\" aria-label=\"add angular to the gulp build permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add Angular to the gulp build</h2>\n<p>Finally, we need to make sure that the Angular files are copied as part of the build.\nWe need to add:</p>\n<ol>\n<li>The paths to the library files.</li>\n<li>Add a <code>lib</code> task to pipe the files to <code>wwwroot</code>.</li>\n<li>Add a dependency on <code>lib</code> to the <code>default</code> task.</li>\n</ol>\n<p>The updated <code>gulpfile.js</code> should look like this:</p>\n<pre class=\"shiki\"><div class=\"language-id\">xml</div><div class='code-container'><code><span style=\"color: #000000\">/// </span><span style=\"color: #800000\">&lt;binding</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">AfterBuild</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">'default'</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">Clean</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">'clean'</span><span style=\"color: #000000\"> </span><span style=\"color: #800000\">/&gt;</span>\n<span style=\"color: #000000\">/*</span>\n<span style=\"color: #000000\">This file is the main entry point for defining Gulp tasks and using Gulp plugins.</span>\n<span style=\"color: #000000\">Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007</span>\n<span style=\"color: #000000\">*/</span>\n\n<span style=\"color: #000000\">var gulp = require('gulp');</span>\n<span style=\"color: #000000\">var del = require('del');</span>\n\n<span style=\"color: #000000\">var paths = {</span>\n<span style=\"color: #000000\">    scripts: ['scripts/**/*.js', 'scripts/**/*.ts', 'scripts/**/*.map'],</span>\n<span style=\"color: #000000\">    libs: ['node_modules/angular2/bundles/angular2.js',</span>\n<span style=\"color: #000000\">           'node_modules/angular2/bundles/angular2-polyfills.js',</span>\n<span style=\"color: #000000\">           'node_modules/systemjs/dist/system.src.js',</span>\n<span style=\"color: #000000\">           'node_modules/rxjs/bundles/Rx.js']</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #000000\">gulp.task('lib', function () {</span>\n<span style=\"color: #000000\">    gulp.src(paths.libs).pipe(gulp.dest('wwwroot/scripts/lib'));</span>\n<span style=\"color: #000000\">});</span>\n\n<span style=\"color: #000000\">gulp.task('clean', function () {</span>\n<span style=\"color: #000000\">    return del(['wwwroot/scripts/**/*']);</span>\n<span style=\"color: #000000\">});</span>\n\n<span style=\"color: #000000\">gulp.task('default', ['lib'], function () {</span>\n<span style=\"color: #000000\">    gulp.src(paths.scripts).pipe(gulp.dest('wwwroot/scripts'));</span>\n<span style=\"color: #000000\">});</span></code></div></pre>\n<p>Again, make sure that Task Runner Explorer sees the new <code>lib</code> task after you save the gulpfile.</p>\n<h2 id=\"write-a-simple-angular-app-in-typescript\"><a href=\"#write-a-simple-angular-app-in-typescript\" aria-label=\"write a simple angular app in typescript permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Write a simple Angular app in TypeScript</h2>\n<p>First, change the code in <code>app.ts</code> to:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> {Component} </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"angular2/core\"</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> {MyModel} </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./model\"</span>\n\n<span style=\"color: #000000\">@Component({</span>\n<span style=\"color: #000000\">    selector: </span><span style=\"color: #A31515\">`my-app`</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    template: </span><span style=\"color: #A31515\">`&lt;div&gt;Hello from {{getCompiler()}}&lt;/div&gt;`</span>\n<span style=\"color: #000000\">})</span>\n<span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyApp {</span>\n<span style=\"color: #000000\">    model = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> MyModel();</span>\n<span style=\"color: #000000\">    getCompiler() {</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.model.compiler;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Then add another TypeScript file in <code>scripts</code> named <code>model.ts</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">export</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> MyModel {</span>\n<span style=\"color: #000000\">    compiler = </span><span style=\"color: #A31515\">\"TypeScript\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>And then another TypeScript file in <code>scripts</code> named <code>main.ts</code>:</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> {bootstrap} </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"angular2/platform/browser\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #0000FF\">import</span><span style=\"color: #000000\"> {MyApp} </span><span style=\"color: #0000FF\">from</span><span style=\"color: #000000\"> </span><span style=\"color: #A31515\">\"./app\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">bootstrap(MyApp);</span></code></div></pre>\n<p>Finally, change the code in <code>index.html</code> to the following:</p>\n<pre class=\"shiki\"><div class=\"language-id\">html</div><div class='code-container'><code><span style=\"color: #800000\">&lt;!</span><span style=\"color: #000000\">DOCTYPE html</span><span style=\"color: #800000\">&gt;</span>\n<span style=\"color: #800000\">&lt;html&gt;</span>\n<span style=\"color: #800000\">&lt;head&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;meta</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">charset</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"utf-8\"</span><span style=\"color: #800000\"> /&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;script</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">src</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"scripts/lib/angular2-polyfills.js\"</span><span style=\"color: #800000\">&gt;&lt;/script&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;script</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">src</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"scripts/lib/system.src.js\"</span><span style=\"color: #800000\">&gt;&lt;/script&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;script</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">src</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"scripts/lib/rx.js\"</span><span style=\"color: #800000\">&gt;&lt;/script&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;script</span><span style=\"color: #000000\"> </span><span style=\"color: #DC0000\">src</span><span style=\"color: #000000\">=</span><span style=\"color: #0000FF\">\"scripts/lib/angular2.js\"</span><span style=\"color: #800000\">&gt;&lt;/script&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;script&gt;</span>\n<span style=\"color: #000000\">    System.config({</span>\n<span style=\"color: #000000\">        packages: {</span>\n<span style=\"color: #000000\">            </span><span style=\"color: #A31515\">'scripts'</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">                format: </span><span style=\"color: #A31515\">'cjs'</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">                defaultExtension: </span><span style=\"color: #A31515\">'js'</span>\n<span style=\"color: #000000\">            }</span>\n<span style=\"color: #000000\">        }</span>\n<span style=\"color: #000000\">    });</span>\n<span style=\"color: #000000\">    System.import(</span><span style=\"color: #A31515\">'scripts/main'</span><span style=\"color: #000000\">).then(</span><span style=\"color: #0000FF\">null</span><span style=\"color: #000000\">, console.error.bind(console));</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;/script&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;title&gt;&lt;/title&gt;</span>\n<span style=\"color: #800000\">&lt;/head&gt;</span>\n<span style=\"color: #800000\">&lt;body&gt;</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #800000\">&lt;my-app&gt;</span><span style=\"color: #000000\">Loading...</span><span style=\"color: #800000\">&lt;/my-app&gt;</span>\n<span style=\"color: #800000\">&lt;/body&gt;</span>\n<span style=\"color: #800000\">&lt;/html&gt;</span></code></div></pre>\n<p>This loads the app.\nWhen you run the ASP.NET application you should see a div that says “Loading…” and then updates to say “Hello from TypeScript”.</p>","headings":[{"value":"Setup","depth":1},{"value":"Install ASP.NET Core and TypeScript","depth":2},{"value":"Create a new project","depth":2},{"value":"Set up the server","depth":2},{"value":"VS2015","depth":3},{"value":"VS2017","depth":3},{"value":"Add TypeScript","depth":1},{"value":"Add TypeScript code","depth":2},{"value":"Add example code","depth":2},{"value":"Set up the build","depth":2},{"value":"Configure the TypeScript compiler","depth":3},{"value":"Set up NPM","depth":3},{"value":"Set up gulp","depth":3},{"value":"Write an HTML page","depth":2},{"value":"Test","depth":2},{"value":"Debug","depth":2},{"value":"Add Angular 2","depth":1},{"value":"Add NPM dependencies","depth":2},{"value":"Update tsconfig.json","depth":2},{"value":"Add Angular to the gulp build","depth":2},{"value":"Write a simple Angular app in TypeScript","depth":2}],"frontmatter":{"permalink":"/docs/handbook/asp-net-core.html","title":"ASP.NET Core"}}},"pageContext":{"slug":"/docs/handbook/asp-net-core.html","isOldHandbook":true}}}