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

MSBuildifying gulpified node #237

Merged
merged 2 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion SignalR.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26208.0
VisualStudioVersion = 15.0.26222.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DA69F624-5398-4884-87E4-B816698CDE65}"
EndProject
Expand Down Expand Up @@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Socket
EndProject
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}"
EndProject
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -157,6 +159,10 @@ Global
{B0D32729-48AA-4841-B52A-2A61B60EED61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0D32729-48AA-4841-B52A-2A61B60EED61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0D32729-48AA-4841-B52A-2A61B60EED61}.Release|Any CPU.Build.0 = Release|Any CPU
{333526A4-633B-491A-AC45-CC62A0012D1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{333526A4-633B-491A-AC45-CC62A0012D1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{333526A4-633B-491A-AC45-CC62A0012D1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{333526A4-633B-491A-AC45-CC62A0012D1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -185,5 +191,6 @@ Global
{455B68D2-C5B6-4BF4-A685-964B07AFAAF8} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
{F3EFFD9F-DD85-48A2-9B11-83A133ECC099} = {DA69F624-5398-4884-87E4-B816698CDE65}
{B0D32729-48AA-4841-B52A-2A61B60EED61} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
{333526A4-633B-491A-AC45-CC62A0012D1C} = {DA69F624-5398-4884-87E4-B816698CDE65}
EndGlobalSection
EndGlobal
4 changes: 0 additions & 4 deletions build/repo.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project>
<Target Name="CleanNpm" AfterTargets="Clean">
<RemoveDir Directories="$(RepositoryRoot)node_modules" />
</Target>

<Target Name="RestoreNpm" AfterTargets="Restore">
<Message Text="Restoring NPM modules" Importance="high" />
<Exec Command="npm install" WorkingDirectory="$(RepositoryRoot)" />
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"gulp-typescript": "^3.1.3",
"jasmine": "^2.5.2",
"typescript": "^2.0.10",
"vinyl-source-stream": "^1.1.0",
"yargs": "^6.4.0"
"vinyl-source-stream": "^1.1.0"
}
}
13 changes: 4 additions & 9 deletions samples/ChatSample/ChatSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try adding ReferenceOutputAssembly="false" to all ProjectReference to the TS project. This will suppress NuGet attempting to use the project reference as a compile reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turned out that I can't do that. With this settings I can build from command line but when I build with VS it fails to build the project due to:
Cannot find project info for 'C:\Source\SignalR-Core\src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj'. This can indicate a missing project reference.

</ItemGroup>

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

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

<Target Name="BowerInstall" BeforeTargets="PrepareForPublish">
Expand Down
16 changes: 6 additions & 10 deletions samples/SocketsSample/SocketsSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Redis\Microsoft.AspNetCore.SignalR.Redis.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />

<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Google.Protobuf" Version="3.1.0" />
</ItemGroup>

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

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: suggest changing extension to .proj. This isn't a C# project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with .proj but VS refused to add it to the solution. Hence changing to project to pretend it's a .csproj

<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this even a typescript project?

Copy link
Contributor

@natemcmaster natemcmaster Feb 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need to reference Microsoft.NET.Sdk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above - it makes project references work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify - currently there is no Typescript support/tooling for VS2017. I wanted to see what they did in previous versions and if you create a "Typescript project" in VS2015 it will be a *.csproj. I tried using their MSBuild tasks from VS2015 but they are compiled against .NET Framework and "our" MSBuild could not load them. When they have tools for VS2017 and netcore MSBuild tasks we need to make sure that there is an easy way to use the latest version of the compiler (i.e. you don't have to reinstall typescript MSBuild/tools if you want to move to a new compiler version)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Import Project="..\..\build\common.props" />

<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup>
<SignalRClientDistFolder>$(MSBuildThisFileDirectory)..\..\dist\</SignalRClientDistFolder>
</PropertyGroup>

<ItemGroup>
<Inputs Include="*.ts;" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how well VS does with this project. You might try using None instead so VS recognizes the files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS showed the files just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also able to build the ts client.

<Outputs Include="@(Inputs -> '$(SignalRClientDistFolder)src\%(FileName).d.ts')" />
<Outputs Include="@(Inputs -> '$(SignalRClientDistFolder)src\%(FileName).js')" />
<Outputs Include="$(SignalRClientDistFolder)browser\signalr-client.js" />
</ItemGroup>
<ItemGroup>
<None Include="tsconfig.json" />
</ItemGroup>

<!-- this target relies on npm packages being restored manually or when running full build -->
<Target Name="BuildTSClient" Inputs="@(Inputs)" Outputs="@(Outputs)" BeforeTargets="Build">
<Exec Command="npm run gulp -- --gulpfile $(MSBuildThisFileDirectory)gulpfile.js build-ts-client" />
</Target>

<Target Name="CleanTSClient" AfterTargets="Clean">
<RemoveDir Directories="$(SignalRClientDistFolder)" />
</Target>
</Project>
11 changes: 0 additions & 11 deletions src/Microsoft.AspNetCore.SignalR.Client.TS/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const browserify = require('browserify');
const ts = require('gulp-typescript');
const source = require('vinyl-source-stream');
const del = require('del');
const argv = require('yargs').argv;

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

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

gulp.task('bundle-client', ['build-ts-client'], () => {
if (!argv.bundleOutDir) {
console.log('Use \'--bundleOutDir\' option to specify the target file for the bundled client.');
}
else {
return gulp.src(clientOutDir + '/../browser/signalr-client.js')
.pipe(gulp.dest(argv.bundleOutDir));
}
});

gulp.task('default', ['build-ts-client']);
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,29 @@
<Import Project="..\..\build\common.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>

<Target Name="NpmInstall">
<Exec Command="npm install" />
</Target>

<Target Name="CopyJasmine" BeforeTargets="BeforeBuild" DependsOnTargets="NpmInstall">
<!-- these targets relies on npm packages being restored when building the TS client -->
<Target Name="CopyRequiredArtifacts" BeforeTargets="AfterBuild">
<ItemGroup>
<JasmineFiles Include="../../node_modules/jasmine-core/lib/jasmine-core/*.js" />
<JasmineFiles Include="../../node_modules/jasmine-core/lib/jasmine-core/*.css" />
<JasmineFiles Include="$(MSBuildProjectDirectory)../../node_modules/jasmine-core/lib/jasmine-core/*.js" />
<JasmineFiles Include="$(MSBuildProjectDirectory)../../node_modules/jasmine-core/lib/jasmine-core/*.css" />
</ItemGroup>
<Copy SourceFiles="@(JasmineFiles)" DestinationFolder="$(MSBuildProjectDirectory)/wwwroot/lib/jasmine" />
</Target>

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

</Project>