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

Commit 0162c19

Browse files
authored
MSBuildifying gulpified node (#237)
- Creating an MSBuild project for the TS client - Adding project references to the TS client project from projects that need the client - (ensures the correct targets dependency graph and prevents building the client multiple times and related races) - Removing gulp tasks from individual projects (allows containing npm only in the TS client source and node tests) - Using incremental compilation to build the TS client only when inputs change (prevents building the client multiple times or when not needed at all) - Removing `npm install` from all the projects (takes up to 10 seconds even if there is nothing to restore) - npm packages will still be installed when running full build (if needed) or need to be installed manually
1 parent 485f959 commit 0162c19

File tree

8 files changed

+59
-54
lines changed

8 files changed

+59
-54
lines changed

SignalR.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 15
3-
VisualStudioVersion = 15.0.26208.0
3+
VisualStudioVersion = 15.0.26222.1
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DA69F624-5398-4884-87E4-B816698CDE65}"
66
EndProject
@@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Socket
5959
EndProject
6060
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Sockets.Common.Tests", "test\Microsoft.AspNetCore.Sockets.Common.Tests\Microsoft.AspNetCore.Sockets.Common.Tests.csproj", "{B0D32729-48AA-4841-B52A-2A61B60EED61}"
6161
EndProject
62+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Client.TS", "src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj", "{333526A4-633B-491A-AC45-CC62A0012D1C}"
63+
EndProject
6264
Global
6365
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6466
Debug|Any CPU = Debug|Any CPU
@@ -157,6 +159,10 @@ Global
157159
{B0D32729-48AA-4841-B52A-2A61B60EED61}.Debug|Any CPU.Build.0 = Debug|Any CPU
158160
{B0D32729-48AA-4841-B52A-2A61B60EED61}.Release|Any CPU.ActiveCfg = Release|Any CPU
159161
{B0D32729-48AA-4841-B52A-2A61B60EED61}.Release|Any CPU.Build.0 = Release|Any CPU
162+
{333526A4-633B-491A-AC45-CC62A0012D1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
163+
{333526A4-633B-491A-AC45-CC62A0012D1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
164+
{333526A4-633B-491A-AC45-CC62A0012D1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
165+
{333526A4-633B-491A-AC45-CC62A0012D1C}.Release|Any CPU.Build.0 = Release|Any CPU
160166
EndGlobalSection
161167
GlobalSection(SolutionProperties) = preSolution
162168
HideSolutionNode = FALSE
@@ -185,5 +191,6 @@ Global
185191
{455B68D2-C5B6-4BF4-A685-964B07AFAAF8} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
186192
{F3EFFD9F-DD85-48A2-9B11-83A133ECC099} = {DA69F624-5398-4884-87E4-B816698CDE65}
187193
{B0D32729-48AA-4841-B52A-2A61B60EED61} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
194+
{333526A4-633B-491A-AC45-CC62A0012D1C} = {DA69F624-5398-4884-87E4-B816698CDE65}
188195
EndGlobalSection
189196
EndGlobal

build/repo.targets

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<Project>
2-
<Target Name="CleanNpm" AfterTargets="Clean">
3-
<RemoveDir Directories="$(RepositoryRoot)node_modules" />
4-
</Target>
5-
62
<Target Name="RestoreNpm" AfterTargets="Restore">
73
<Message Text="Restoring NPM modules" Importance="high" />
84
<Exec Command="npm install" WorkingDirectory="$(RepositoryRoot)" />

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"gulp-typescript": "^3.1.3",
3030
"jasmine": "^2.5.2",
3131
"typescript": "^2.0.10",
32-
"vinyl-source-stream": "^1.1.0",
33-
"yargs": "^6.4.0"
32+
"vinyl-source-stream": "^1.1.0"
3433
}
3534
}

samples/ChatSample/ChatSample.csproj

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
15+
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
1516
</ItemGroup>
1617

1718
<ItemGroup>
@@ -37,15 +38,9 @@
3738
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
3839
</ItemGroup>
3940

40-
<Target Name="BuildTSClient" BeforeTargets="BeforeBuild">
41-
<PropertyGroup>
42-
<SignalRClientDistPath>..\..\dist\browser\signalr-client.js</SignalRClientDistPath>
43-
<SignalRClientTargetFolder>$(MSBuildProjectDirectory)/wwwroot/lib/signalr-client/</SignalRClientTargetFolder>
44-
<SignalRClientTargetPath>$(MSBuildProjectDirectory)/wwwroot/lib/signalr-client/signalr-client.js</SignalRClientTargetPath>
45-
</PropertyGroup>
46-
<Copy Condition="Exists('$(SignalRClientDistPath)')" SourceFiles="$(SignalRClientDistPath)" DestinationFolder="$(SignalRClientTargetFolder)"/>
47-
<Exec Condition="!Exists('$(SignalRClientDistPath)')" Command="npm install" />
48-
<Exec Condition="!Exists('$(SignalRClientDistPath)')" Command="npm run gulp -- --gulpfile $(MSBuildProjectDirectory)/../../src/Microsoft.AspNetCore.SignalR.Client.TS/gulpfile.js bundle-client --bundleOutDir $(SignalRClientTargetFolder)" />
41+
<Target Name="CopyTSClient" BeforeTargets="AfterBuild">
42+
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\..\dist\browser\signalr-client.js"
43+
DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" />
4944
</Target>
5045

5146
<Target Name="BowerInstall" BeforeTargets="PrepareForPublish">

samples/SocketsSample/SocketsSample.csproj

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@
1111

1212
<ItemGroup>
1313
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Redis\Microsoft.AspNetCore.SignalR.Redis.csproj" />
14+
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
15+
1416
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
1517
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
1618
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
1719
<PackageReference Include="Google.Protobuf" Version="3.1.0" />
1820
</ItemGroup>
1921

20-
<Target Name="BuildTSClient" BeforeTargets="BeforeBuild">
21-
<PropertyGroup>
22-
<SignalRClientDistPath>..\..\dist\browser\signalr-client.js</SignalRClientDistPath>
23-
<SignalRClientTargetFolder>$(MSBuildProjectDirectory)/wwwroot/lib/signalr-client/</SignalRClientTargetFolder>
24-
<SignalRClientTargetPath>$(MSBuildProjectDirectory)/wwwroot/lib/signalr-client/signalr-client.js</SignalRClientTargetPath>
25-
</PropertyGroup>
26-
<Copy Condition="Exists('$(SignalRClientDistPath)')" SourceFiles="$(SignalRClientDistPath)" DestinationFolder="$(SignalRClientTargetFolder)"/>
27-
<Exec Condition="!Exists('$(SignalRClientDistPath)')" Command="npm install" />
28-
<Exec Condition="!Exists('$(SignalRClientDistPath)')" Command="npm run gulp -- --gulpfile $(MSBuildProjectDirectory)/../../src/Microsoft.AspNetCore.SignalR.Client.TS/gulpfile.js bundle-client --bundleOutDir $(SignalRClientTargetFolder)" />
22+
<Target Name="CopyTSClient" BeforeTargets="AfterBuild">
23+
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\..\dist\browser\signalr-client.js"
24+
DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" />
2925
</Target>
3026

31-
</Project>
27+
</Project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<Import Project="..\..\build\common.props" />
4+
5+
<PropertyGroup>
6+
<TargetFramework>netstandard1.0</TargetFramework>
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<PropertyGroup>
11+
<SignalRClientDistFolder>$(MSBuildThisFileDirectory)..\..\dist\</SignalRClientDistFolder>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<Inputs Include="*.ts;" />
16+
<Outputs Include="@(Inputs -> '$(SignalRClientDistFolder)src\%(FileName).d.ts')" />
17+
<Outputs Include="@(Inputs -> '$(SignalRClientDistFolder)src\%(FileName).js')" />
18+
<Outputs Include="$(SignalRClientDistFolder)browser\signalr-client.js" />
19+
</ItemGroup>
20+
<ItemGroup>
21+
<None Include="tsconfig.json" />
22+
</ItemGroup>
23+
24+
<!-- this target relies on npm packages being restored manually or when running full build -->
25+
<Target Name="BuildTSClient" Inputs="@(Inputs)" Outputs="@(Outputs)" BeforeTargets="Build">
26+
<Exec Command="npm run gulp -- --gulpfile $(MSBuildThisFileDirectory)gulpfile.js build-ts-client" />
27+
</Target>
28+
29+
<Target Name="CleanTSClient" AfterTargets="Clean">
30+
<RemoveDir Directories="$(SignalRClientDistFolder)" />
31+
</Target>
32+
</Project>

src/Microsoft.AspNetCore.SignalR.Client.TS/gulpfile.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const browserify = require('browserify');
33
const ts = require('gulp-typescript');
44
const source = require('vinyl-source-stream');
55
const del = require('del');
6-
const argv = require('yargs').argv;
76

87
const tsProject = ts.createProject('./tsconfig.json');
98
const clientOutDir = tsProject.options.outDir;
@@ -27,14 +26,4 @@ gulp.task('browserify-client', ['compile-ts-client'], () => {
2726

2827
gulp.task('build-ts-client', ['clean', 'compile-ts-client', 'browserify-client']);
2928

30-
gulp.task('bundle-client', ['build-ts-client'], () => {
31-
if (!argv.bundleOutDir) {
32-
console.log('Use \'--bundleOutDir\' option to specify the target file for the bundled client.');
33-
}
34-
else {
35-
return gulp.src(clientOutDir + '/../browser/signalr-client.js')
36-
.pipe(gulp.dest(argv.bundleOutDir));
37-
}
38-
});
39-
4029
gulp.task('default', ['build-ts-client']);

test/Microsoft.AspNetCore.SignalR.Test.Server/Microsoft.AspNetCore.SignalR.Test.Server.csproj

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,29 @@
33
<Import Project="..\..\build\common.props" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
6+
<TargetFramework>netcoreapp1.1</TargetFramework>
77
</PropertyGroup>
88

99
<ItemGroup>
1010
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
11+
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
1112
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="$(AspNetCoreVersion)" />
1213
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
1314
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
1415
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
1516
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
1617
</ItemGroup>
1718

18-
<Target Name="NpmInstall">
19-
<Exec Command="npm install" />
20-
</Target>
21-
22-
<Target Name="CopyJasmine" BeforeTargets="BeforeBuild" DependsOnTargets="NpmInstall">
19+
<!-- these targets relies on npm packages being restored when building the TS client -->
20+
<Target Name="CopyRequiredArtifacts" BeforeTargets="AfterBuild">
2321
<ItemGroup>
24-
<JasmineFiles Include="../../node_modules/jasmine-core/lib/jasmine-core/*.js" />
25-
<JasmineFiles Include="../../node_modules/jasmine-core/lib/jasmine-core/*.css" />
22+
<JasmineFiles Include="$(MSBuildProjectDirectory)../../node_modules/jasmine-core/lib/jasmine-core/*.js" />
23+
<JasmineFiles Include="$(MSBuildProjectDirectory)../../node_modules/jasmine-core/lib/jasmine-core/*.css" />
2624
</ItemGroup>
2725
<Copy SourceFiles="@(JasmineFiles)" DestinationFolder="$(MSBuildProjectDirectory)/wwwroot/lib/jasmine" />
28-
</Target>
2926

30-
<Target Name="BuildTSClient" BeforeTargets="BeforeBuild" DependsOnTargets="NpmInstall">
31-
<PropertyGroup>
32-
<SignalRClientDistPath>..\..\dist\browser\signalr-client.js</SignalRClientDistPath>
33-
<SignalRClientTargetFolder>$(MSBuildProjectDirectory)/wwwroot/lib/signalr-client/</SignalRClientTargetFolder>
34-
<SignalRClientTargetPath>$(MSBuildProjectDirectory)/wwwroot/lib/signalr-client/signalr-client.js</SignalRClientTargetPath>
35-
</PropertyGroup>
36-
<Copy Condition="Exists('$(SignalRClientDistPath)')" SourceFiles="$(SignalRClientDistPath)" DestinationFolder="$(SignalRClientTargetFolder)"/>
37-
<Exec Condition="!Exists('$(SignalRClientDistPath)')" Command="npm run gulp -- --gulpfile $(MSBuildProjectDirectory)/../../src/Microsoft.AspNetCore.SignalR.Client.TS/gulpfile.js bundle-client --bundleOutDir $(SignalRClientTargetFolder)" />
27+
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\..\dist\browser\signalr-client.js"
28+
DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client"/>
3829
</Target>
3930

4031
</Project>

0 commit comments

Comments
 (0)