Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ version: '{build}'
os: Visual Studio 2015
install:
- set PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin;%PATH%
- dnvm update-self
- dnvm install 1.0.0-rc1-update1
build:
project: build.proj
Copy link
Member

Choose a reason for hiding this comment

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

Should this run the equivalent dotnet command to ensure RC2 is installed on the build machine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I know it no longer works that way in RC2. There is no equivalent to dnvm in the new toolset. If you have .NET Core RC2 installed already, you can just get the ASP.NET Core packages using NuGet.
That was one of the biggest changes from RC1 to RC2, and it was done in order to make all .NET Core environments consistent with each other.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the info 👍

Copy link
Member

Choose a reason for hiding this comment

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

Looks like they've got an install script for CI servers (see https://dotnet.github.io/docs/core-concepts/dnx-migration.html). However, their docs for AppVeyor just say "TODO" (https://dotnet.github.io/docs/core-concepts/core-sdk/cli/using-ci-with-cli.html). It's fine to ignore that for now if the AppVeyor build actually works with no changes.

verbosity: normal
Expand Down
32 changes: 16 additions & 16 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ of patent rights can be found in the PATENTS file in the same directory.
<PackageAssemblies Include="Cassette.React" />
<PackageAssemblies Include="React.MSBuild" />
<PackageAssemblies Include="React.Owin" />
<PackageAssembliesAspNet5 Include="React.AspNet" />
<AspNet5ProjectJson Include="src/React.AspNet/project.json" />
<AspNet5ProjectJson Include="src/React.Sample.Mvc6/project.json" />
<AspNet5ProjectJson Include="src/wrap/**/project.json" />
<PackageAssembliesAspNetCore Include="React.AspNet" />
<AspNetCoreProjectJson Include="src/wrap/**/project.json" />
<AspNetCoreProjectJson Include="src/React.AspNet/project.json" />
<AspNetCoreProjectJson Include="src/React.Sample.Mvc6/project.json" />
</ItemGroup>

<Import Project="src/React.tasks.proj" />
Expand All @@ -42,10 +42,10 @@ of patent rights can be found in the PATENTS file in the same directory.
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="tools\NuGet\nuget.exe restore $(SolutionFile)"
/>
<!-- NuGet packages for ASP.NET 5 projects -->
<!-- NuGet packages for ASP.NET Core projects -->
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dnu restore --quiet --parallel src\React.AspNet src\React.Sample.Mvc6"
Command="dotnet restore --quiet src\React.AspNet src\React.Sample.Mvc6"
/>
<!-- npm packages -->
<Exec
Expand Down Expand Up @@ -81,7 +81,7 @@ of patent rights can be found in the PATENTS file in the same directory.
AssemblyInformationalVersion="$(Major).$(Minor).$(FullBuild)"
/>
<!--
Set version for ASP.NET 5 projects. In theory K_BUILD_VERSION should work but it doesn't seem
Set version for ASP.NET Core projects. In theory K_BUILD_VERSION should work but it doesn't seem
to be functional yet :(. We work around this by physically writing the build number to the
project.json files. For development builds we write the full version number (including
build date) and reset it later so the dev build number isn't commited to the repo.
Expand All @@ -91,18 +91,18 @@ of patent rights can be found in the PATENTS file in the same directory.
Value="$(Build)"
/-->
<UpdateAspNetProjectVersion
Files="@(AspNet5ProjectJson)"
Files="@(AspNetCoreProjectJson)"
Version="$(Major).$(Minor).$(FullBuild)"
/>
</Target>

<Target Name="Clean" BeforeTargets="Build">
<!--
ASP.NET 5 projects don't delete generated .nupkg files when cleaned or rebuilt, so we need to
ASP.NET Core projects don't delete generated .nupkg files when cleaned or rebuilt, so we need to
do it here. See https://github.com/aspnet/XRE/issues/1301
-->
<DeleteTree Directories="src/artifacts" />
<DeleteTree Directories="bin/%(PackageAssembliesAspNet5.Identity)/Release" />
<DeleteTree Directories="bin/%(PackageAssembliesAspNetCore.Identity)/Release" />
</Target>

<Target Name="Build" DependsOnTargets="RestorePackages;UpdateVersion">
Expand All @@ -112,9 +112,9 @@ of patent rights can be found in the PATENTS file in the same directory.
</Target>

<Target Name="ResetAspNetVersion" AfterTargets="Build">
<!-- Resets the version number in ASP.NET project.json files so we don't commit -dev- version numbers -->
<!-- Resets the version number in ASP.NET Core project.json files so we don't commit -dev- version numbers -->
<UpdateAspNetProjectVersion
Files="@(AspNet5ProjectJson)"
Files="@(AspNetCoreProjectJson)"
Version="$(Major).$(Minor).$(Build)-*"
/>
</Target>
Expand Down Expand Up @@ -148,13 +148,13 @@ of patent rights can be found in the PATENTS file in the same directory.
Command="tools\NuGet\nuget.exe pack src/%(PackageAssemblies.Identity)/%(PackageAssemblies.Identity).csproj -IncludeReferencedProjects -Symbols -Prop Configuration=Release -OutputDirectory output"
/>
</Target>

<Target Name="CopyAspNetPackages" AfterTargets="Package">
<!-- Copy over ASP.NET 5 packages -->
<!-- Copy over ASP.NET Core packages -->
<ItemGroup>
<AspNet5Packages Include="bin/%(PackageAssembliesAspNet5.Identity)/Release/*.nupkg" />
<AspNetCorePackages Include="bin/%(PackageAssembliesAspNetCore.Identity)/*.nupkg" />
</ItemGroup>
<Copy SourceFiles="@(AspNet5Packages)" DestinationFolder="$(PackageOutputDir)" />
<Copy SourceFiles="@(AspNetCorePackages)" DestinationFolder="$(PackageOutputDir)" />
</Target>

<Target Name="Push">
Expand Down
2 changes: 1 addition & 1 deletion src/React.AspNet/AspNetFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

using System.IO;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNetCore.Hosting;

namespace React.AspNet
{
Expand Down
37 changes: 19 additions & 18 deletions src/React.AspNet/BabelFileMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.StaticFiles;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace React.AspNet
{
Expand Down Expand Up @@ -73,22 +74,22 @@ public async Task Invoke(HttpContext context)
/// <returns></returns>
private StaticFileMiddleware CreateFileMiddleware(IBabel babel)
{
return new StaticFileMiddleware(
return new StaticFileMiddleware(
_next,
_hostingEnv,
new StaticFileOptions
{
ContentTypeProvider = _options.StaticFileOptions.ContentTypeProvider,
DefaultContentType = _options.StaticFileOptions.DefaultContentType,
OnPrepareResponse = _options.StaticFileOptions.OnPrepareResponse,
RequestPath = _options.StaticFileOptions.RequestPath,
ServeUnknownFileTypes = _options.StaticFileOptions.ServeUnknownFileTypes,
FileProvider = new BabelFileSystem(
babel,
_options.StaticFileOptions.FileProvider ?? _hostingEnv.WebRootFileProvider,
_options.Extensions
)
},
Options.Create(new StaticFileOptions
Copy link
Member

Choose a reason for hiding this comment

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

Could you please adjust the spacing here? It should be using tabs rather than spaces. I though there was an Editorconfig file in the repo but it looks like I forgot to commit it.

{
ContentTypeProvider = _options.StaticFileOptions.ContentTypeProvider,
DefaultContentType = _options.StaticFileOptions.DefaultContentType,
OnPrepareResponse = _options.StaticFileOptions.OnPrepareResponse,
RequestPath = _options.StaticFileOptions.RequestPath,
ServeUnknownFileTypes = _options.StaticFileOptions.ServeUnknownFileTypes,
FileProvider = new BabelFileSystem(
babel,
_options.StaticFileOptions.FileProvider ?? _hostingEnv.WebRootFileProvider,
_options.Extensions
)
}),
_loggerFactory
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/React.AspNet/BabelFileOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#if OWIN
using Microsoft.Owin.StaticFiles;
#else
using Microsoft.AspNet.StaticFiles;
using Microsoft.AspNetCore.Builder;
#endif

#if OWIN
Expand Down
6 changes: 3 additions & 3 deletions src/React.AspNet/BabelFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
using Microsoft.Owin.FileSystems;
using IOwinFileSystem = Microsoft.Owin.FileSystems.IFileSystem;
#else
using Microsoft.AspNet.FileProviders;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Primitives;
using IOwinFileSystem = Microsoft.AspNet.FileProviders.IFileProvider;
using PhysicalFileSystem = Microsoft.AspNet.FileProviders.PhysicalFileProvider;
using IOwinFileSystem = Microsoft.Extensions.FileProviders.IFileProvider;
using PhysicalFileSystem = Microsoft.Extensions.FileProviders.PhysicalFileProvider;
#endif

#if OWIN
Expand Down
4 changes: 2 additions & 2 deletions src/React.AspNet/HtmlHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
using System.Web.Mvc;
using IHtmlHelper = System.Web.Mvc.HtmlHelper;
#else
using Microsoft.AspNet.Mvc.Rendering;
using IHtmlString = Microsoft.AspNet.Html.Abstractions.IHtmlContent;
using Microsoft.AspNetCore.Mvc.Rendering;
using IHtmlString = Microsoft.AspNetCore.Html.IHtmlContent;
#endif

#if LEGACYASPNET
Expand Down
18 changes: 2 additions & 16 deletions src/React.AspNet/HttpContextLifetimeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System;
using System.Collections.Concurrent;
using System.Linq;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Http;
using React.Exceptions;
using React.TinyIoC;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -43,28 +43,14 @@ public HttpContextLifetimeProvider(IServiceProvider appServiceProvider)
/// </summary>
private readonly string _keyName = PREFIX + Guid.NewGuid();

/// <summary>
/// Gets the <see cref="HttpContext" /> of the current request.
/// </summary>
private HttpContext HttpContext =>
_appServiceProvider.GetRequiredService<IHttpContextAccessor>().HttpContext;

/// <summary>
/// Gets the current per-request registrations for the current request.
/// </summary>
private PerRequestRegistrations Registrations
{
get
{
var requestServices = HttpContext.RequestServices;
if (requestServices == null)
{
throw new ReactNotInitialisedException(
"ASP.NET request services have not been initialised correctly. Please " +
"ensure you are calling app.UseRequestServices() before app.UseReact()."
);
}
var registrations = requestServices.GetService<PerRequestRegistrations>();
var registrations = _appServiceProvider.GetService<PerRequestRegistrations>();
Copy link
Member

Choose a reason for hiding this comment

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

This change was incorrect, it wasn't handling per-request singletons properly and was instead just using a single instance for the entire app. I fixed it in a4992da 👍

if (registrations == null)
{
throw new ReactNotInitialisedException(
Expand Down
8 changes: 8 additions & 0 deletions src/React.AspNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("React.AspNet")]
[assembly: AssemblyDescription("ReactJS and Babel tools for ASP.NET Core, including ASP.NET Core MVC")]
[assembly: ComVisible(false)]
[assembly: Guid("f0e355fc-a89f-4fd6-b171-1ef03c838a67")]
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this now that you reverted it from being a .csproj?

31 changes: 8 additions & 23 deletions src/React.AspNet/React.AspNet.xproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>a7acdb56-5e43-40a6-92c9-2c52228e6074</ProjectGuid>
<ProjectGuid>f0e355fc-a89f-4fd6-b171-1ef03c838a67</ProjectGuid>
Copy link
Member

Choose a reason for hiding this comment

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

Keep the GUID the same? I don't see a reason to change it :)

<RootNamespace>React.AspNet</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AssemblyName>React.AspNet</AssemblyName>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>

<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\React.Core\React.Core.csproj" />
</ItemGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties />
</VisualStudio>
</ProjectExtensions>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" />
</Project>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
5 changes: 2 additions & 3 deletions src/React.AspNet/ReactBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

using System;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.PlatformAbstractions;
using React.Exceptions;
using React.TinyIoC;
Expand Down Expand Up @@ -40,7 +40,6 @@ public static IApplicationBuilder UseReact(
// Register IApplicationEnvironment in our dependency injection container
// Ideally this would be in AddReact(IServiceCollection) but we can't
// access IApplicationEnvironment there.
React.AssemblyRegistration.Container.Register(app.ApplicationServices.GetRequiredService<IApplicationEnvironment>());
React.AssemblyRegistration.Container.Register(app.ApplicationServices.GetRequiredService<IHostingEnvironment>());
Copy link
Member

Choose a reason for hiding this comment

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

Remove the comment too, please.


Initializer.Initialize(registerOptions => AsPerRequestSingleton(app.ApplicationServices, registerOptions));
Expand Down
77 changes: 43 additions & 34 deletions src/React.AspNet/project.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
{
"version": "2.3.0-*",
"configurations": {
"Debug": {
"compilationOptions": {
"define": [ "DEBUG", "TRACE", "ASPNET5" ]
}
},
"Release": {
"compilationOptions": {
"define": [ "RELEASE", "TRACE", "ASPNET5" ],
"optimize": true,
"warningsAsErrors": true
}
}
"version": "2.3.0-*",
"authors": [ "Daniel Lo Nigro" ],
"packOptions": {
"owners": [ "Daniel Lo Nigro" ],
"licenseUrl": "https://github.com/reactjs/React.NET#licence",
"iconUrl": "http://facebook.github.io/react/img/logo_og.png",
"copyright": "Copyright 2014-Present Facebook, Inc",
"title": "ReactJS.NET (MVC Core)",
"description": "ReactJS and Babel tools for ASP.NET Core, including ASP.NET MVC Core. Please refer to project site (http://reactjs.net/) for full installation instructions, usage examples and sample code",
"tags": [ "asp.net", "mvc", "asp", "javascript", "js", "react", "facebook", "reactjs", "vnext" ],
"projectUrl": "http://reactjs.net/"
},
"configurations": {
"Debug": {
"buildOptions": {
"define": [ "DEBUG", "TRACE", "ASPNET5" ]
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should rename the ASPNET5 define too. It's referenced in a few source files via #ifdef ASPNET5

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 looked at the files, but I couldn't find any reference to ASPNET5.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, good point. Setting preprocess directives was actually broken for ASP.NET 5 projects, so all the conditions instead check for LEGACYASPNET and assume a ASP.NET 5 environment if not set (eg.

). I guess you can rename this without changing anything then :)

}
},
"Release": {
"buildOptions": {
"define": [ "RELEASE", "TRACE", "ASPNET5" ],
"optimize": true,
"warningsAsErrors": true
}
}
},
"dependencies": {
"JsPool": "0.4.1",
"Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.FileProviders.Physical": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final",
"React.Core": "2.3.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc1-final",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.Extensions.FileProviders.Physical": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0-rc2-final",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-final",
"JavaScriptEngineSwitcher.Core": "1.5.0",
"JavaScriptEngineSwitcher.Msie": "1.5.0",
"JavaScriptEngineSwitcher.V8": "1.5.2",
"MsieJavaScriptEngine": "1.7.0"
"MsieJavaScriptEngine": "1.7.0",
"React.Core": "2.3.0-*"
},
"frameworks": {
"dnx451": { }
},

"authors": [ "Daniel Lo Nigro" ],
"owners": [ "Daniel Lo Nigro" ],
"licenseUrl": "https://github.com/reactjs/React.NET#licence",
"iconUrl": "http://facebook.github.io/react/img/logo_og.png",
"copyright": "Copyright 2014-Present Facebook, Inc",
"title": "ReactJS.NET (MVC 6)",
"description": "ReactJS and Babel tools for ASP.NET 5, including ASP.NET MVC 6. Please refer to project site (http://reactjs.net/) for full installation instructions, usage examples and sample code",
"tags": [ "asp.net", "mvc", "asp", "javascript", "js", "react", "facebook", "reactjs", "vnext" ],
"projectUrl": "http://reactjs.net/"
"frameworks": {
"net451": {
"bin": {
"assembly": "../../bin/React.AspNet/bin/{configuration}/net451/React.AspNet.dll",
"pdb": "../../bin/React.AspNet/bin/{configuration}/net451/React.AspNet.pdb"
}
}
},
"scripts": {
"postcompile": [ "dotnet pack --output ../../bin/React.AspNet/ --no-build --version-suffix %project:Version% project.json" ]
Copy link
Member

Choose a reason for hiding this comment

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

This is totally fine, I wonder if it should be done in build.proj along with all the other NuGet packages, to keep everything consistent.

Thanks for figuring this out, btw :)

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 thinking exactly the same thing, I'm going to try it on build.proj

}
}
1 change: 1 addition & 0 deletions src/React.MSBuild/React.MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Content\TransformBabel.proj" />
<None Include="packages.config" />
<None Include="tools\install.ps1" />
<None Include="React.MSBuild.nutrans" />
<None Include="tools\uninstall.ps1" />
Expand Down
Loading