Skip to content

Commit 4eef768

Browse files
authored
Get Aurelia working in ASP.NET Core 2 (#16)
1 parent 68795d7 commit 4eef768

33 files changed

+67503
-2749
lines changed

ASP.NET Core Basics/src/Aurelia/.gitignore

Lines changed: 0 additions & 247 deletions
This file was deleted.
Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,44 @@
1-
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
23
<PropertyGroup>
3-
<TargetFramework>netcoreapp1.1</TargetFramework>
4+
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">netcoreapp2.0</TargetFramework>
5+
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework>
46
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
7+
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
58
<IsPackable>false</IsPackable>
6-
<TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
79
</PropertyGroup>
8-
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
11-
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="1.1.0" />
12-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
13-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
10+
11+
<ItemGroup Condition="'$(TargetFrameworkOverride)' == ''">
12+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
1413
</ItemGroup>
14+
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
15+
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
16+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
17+
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.0" />
18+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
19+
</ItemGroup>
20+
1521
<ItemGroup>
16-
<!-- Files not to show in IDE -->
17-
<None Remove="yarn.lock" />
22+
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
1823
</ItemGroup>
19-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
24+
25+
<!--/-:cnd:noEmit -->
26+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
27+
<!-- Ensure Node.js is installed -->
28+
<Exec Command="node --version" ContinueOnError="true">
29+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
30+
</Exec>
31+
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
32+
33+
<!-- In development, the dist files won't exist on the first run or when cloning to
34+
a different machine, so rebuild them if not already present. -->
35+
<Message Importance="high" Text="Performing first-run Webpack build..." />
36+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
37+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
38+
</Target>
39+
<!--/+:cnd:noEmit -->
40+
41+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
2042
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2143
<Exec Command="npm install" />
2244
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
@@ -31,4 +53,5 @@
3153
</ResolvedFileToPublish>
3254
</ItemGroup>
3355
</Target>
34-
</Project>
56+
57+
</Project>

ASP.NET Core Basics/src/Aurelia/ClientApp/app/components/app/app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Aurelia } from 'aurelia-framework';
1+
import { Aurelia, PLATFORM } from 'aurelia-framework';
22
import { Router, RouterConfiguration } from 'aurelia-router';
33

44
export class App {
@@ -10,36 +10,36 @@ export class App {
1010
route: ['', 'home'],
1111
name: 'home',
1212
settings: { icon: 'home' },
13-
moduleId: '../home/home',
13+
moduleId: PLATFORM.moduleName('../home/home'),
1414
nav: true,
1515
title: 'Home'
1616
}, {
1717
route: 'counter',
1818
name: 'counter',
1919
settings: { icon: 'education' },
20-
moduleId: '../counter/counter',
20+
moduleId: PLATFORM.moduleName('../counter/counter'),
2121
nav: true,
2222
title: 'Counter'
2323
}, {
2424
route: 'fetch-data',
2525
name: 'fetchdata',
2626
settings: { icon: 'th-list' },
27-
moduleId: '../fetchdata/fetchdata',
27+
moduleId: PLATFORM.moduleName('../fetchdata/fetchdata'),
2828
nav: true,
2929
title: 'Fetch data'
3030
},
3131
{
3232
route: 'contact-list',
3333
name: 'contactlist',
3434
settings: { icon: 'list-alt' },
35-
moduleId: '../contacts/contactList',
35+
moduleId: PLATFORM.moduleName('../contacts/contactList'),
3636
nav: true,
3737
title: 'Contact List'
3838
},
3939
{
4040
route: 'contact-detail/:id?',
4141
name: 'contactdetail',
42-
moduleId: '../contacts/contactDetail',
42+
moduleId: PLATFORM.moduleName('../contacts/contactDetail'),
4343
nav: false,
4444
title: 'Contact Detail'
4545
}]);

ASP.NET Core Basics/src/Aurelia/ClientApp/app/components/contacts/contact.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
phone: string;
99
email: string;
1010

11-
constructor(data?) {
11+
constructor(data?: any) {
1212
if (data == null) return;
1313
Object.assign(this, data);
1414
}

ASP.NET Core Basics/src/Aurelia/ClientApp/app/components/contacts/contactDetail.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export class ContactDetail {
99

1010
constructor(private contactService: ContactService) { }
1111

12-
activate(parms, routeConfig) {
12+
activate(parms: any, routeConfig: any) {
1313
this.hasContactId = parms.id;
1414

1515
if (this.hasContactId) {
1616
return this.contactService.getById(parms.id)
17-
.then(contact => this.contact = contact);
17+
.then(contact => this.contact = contact);
1818
}
1919

2020
return null;

0 commit comments

Comments
 (0)