Skip to content

Add .NETCore 3 preview support #791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 4, 2019
Merged
13 changes: 0 additions & 13 deletions appveyor.yml

This file was deleted.

7 changes: 6 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ trigger:
- master

pool:
vmImage: 'VS2017-Win2016'
vmImage: 'windows-2019'

variables:
buildPlatform: 'Any CPU'
Expand All @@ -15,6 +15,11 @@ steps:

- script: npm install --global npm

- task: DotNetCoreInstaller@0
inputs:
packageType: 'sdk'
version: '3.0.100-preview5-011568'

- task: VSBuild@1
inputs:
solution: 'build.proj'
Expand Down
5 changes: 4 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"projects": [ "src", "test" ]
"projects": [ "src", "test" ],
"sdk": {
"version": "3.0.100-preview"
}
}
7 changes: 4 additions & 3 deletions runs-msbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ set BUILDTYPE="%~1"
set ACTION="%~2"

for %%s in (
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\MSBuild.exe"
) do (
if exist %%s (
echo %%s build.proj %ACTION% %BUILDTYPE%
Expand Down
10 changes: 7 additions & 3 deletions src/React.AspNet.Middleware/AspNetFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;

#if NETCOREAPP2_0 || NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#endif

namespace React.AspNet
{
/// <summary>
Expand All @@ -16,13 +20,13 @@ namespace React.AspNet
/// </summary>
public class AspNetFileSystem : FileSystemBase
{
private readonly IHostingEnvironment _hostingEnv;
private readonly IWebHostEnvironment _hostingEnv;

/// <summary>
/// Initializes a new instance of the <see cref="AspNetFileSystem"/> class.
/// </summary>
/// <param name="hostingEnv">The ASP.NET 5 hosting environment</param>
public AspNetFileSystem(IHostingEnvironment hostingEnv)
/// <param name="hostingEnv">The .NET Core hosting environment</param>
public AspNetFileSystem(IWebHostEnvironment hostingEnv)
{
_hostingEnv = hostingEnv;
}
Expand Down
9 changes: 6 additions & 3 deletions src/React.AspNet.Middleware/BabelFileMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

#if NETCOREAPP2_0 || NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#endif

namespace React.AspNet
{
/// <summary>
Expand All @@ -23,7 +27,7 @@ namespace React.AspNet
public class BabelFileMiddleware
{
private readonly RequestDelegate _next;
private readonly IHostingEnvironment _hostingEnv;
private readonly IWebHostEnvironment _hostingEnv;
private readonly ILoggerFactory _loggerFactory;
private readonly BabelFileOptions _options;

Expand All @@ -34,7 +38,7 @@ public class BabelFileMiddleware
/// <param name="options">The configuration options.</param>
/// <param name="hostingEnv">The hosting environment.</param>
/// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param>
public BabelFileMiddleware(RequestDelegate next, BabelFileOptions options, IHostingEnvironment hostingEnv, ILoggerFactory loggerFactory)
public BabelFileMiddleware(RequestDelegate next, BabelFileOptions options, IWebHostEnvironment hostingEnv, ILoggerFactory loggerFactory)
{
if (next == null)
throw new ArgumentNullException("next");
Expand Down Expand Up @@ -93,4 +97,3 @@ private StaticFileMiddleware CreateFileMiddleware(IBabel babel)
}
}
}

10 changes: 7 additions & 3 deletions src/React.AspNet.Middleware/MemoryFileCacheCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.FileProviders;

#if NETCOREAPP2_0 || NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#endif

namespace React.AspNet
{
/// <summary>
Expand All @@ -19,14 +23,14 @@ namespace React.AspNet
public class MemoryFileCacheCore : ICache
{
private readonly IMemoryCache _cache;
private readonly IHostingEnvironment _hostingEnv;
private readonly IWebHostEnvironment _hostingEnv;

/// <summary>
/// Initializes a new instance of the <see cref="MemoryFileCacheCore" /> class.
/// </summary>
/// <param name="cache">The cache to use</param>
/// <param name="hostingEnv">The ASP.NET hosting environment.</param>
public MemoryFileCacheCore(IMemoryCache cache, IHostingEnvironment hostingEnv)
public MemoryFileCacheCore(IMemoryCache cache, IWebHostEnvironment hostingEnv)
{
_cache = cache;
_hostingEnv = hostingEnv;
Expand All @@ -52,7 +56,7 @@ public MemoryFileCacheCore(IMemoryCache cache, IHostingEnvironment hostingEnv)
/// <param name="key">The cache key</param>
/// <param name="data">Data to cache</param>
/// <param name="slidingExpiration">
/// Sliding expiration, if cache key is not accessed in this time period it will
/// Sliding expiration, if cache key is not accessed in this time period it will
/// automatically be removed from the cache
/// </param>
/// <param name="cacheDependencyFiles">
Expand Down
8 changes: 6 additions & 2 deletions src/React.AspNet.Middleware/React.AspNet.Middleware.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Copyright>Copyright 2014-Present Facebook, Inc</Copyright>
<AssemblyTitle>ReactJS.NET - Babel middleware for ASP.NET Core</AssemblyTitle>
<Authors>Daniel Lo Nigro</Authors>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>React.AspNet.Middleware</AssemblyName>
<AssemblyOriginatorKeyFile>../key.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -33,7 +33,7 @@
<ProjectReference Include="..\React.Core\React.Core.csproj" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
Expand All @@ -42,6 +42,10 @@
<PackageReference Include="Microsoft.Sourcelink.Github" Version="1.0.0-beta2-19270-01" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview3-19153-02" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/React.AspNet.Middleware/ReactBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
using Microsoft.Extensions.Caching.Memory;
#endif

#if NETCOREAPP2_0 || NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#endif

namespace React.AspNet
{
/// <summary>
Expand Down Expand Up @@ -83,7 +87,7 @@ TinyIoCContainer.RegisterOptions registerOptions
/// <param name="services">ASP.NET dependency injection container</param>
private static void RegisterAspNetServices(TinyIoCContainer container, IServiceProvider services)
{
container.Register(services.GetRequiredService<IHostingEnvironment>());
container.Register(services.GetRequiredService<IWebHostEnvironment>());
#if !NET451
container.Register(services.GetRequiredService<IMemoryCache>());
#endif
Expand Down
8 changes: 6 additions & 2 deletions src/React.AspNet/React.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Copyright>Copyright 2014-Present Facebook, Inc</Copyright>
<AssemblyTitle>ReactJS.NET (ASP.NET Core MVC)</AssemblyTitle>
<Authors>Daniel Lo Nigro</Authors>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>React.AspNet</AssemblyName>
<AssemblyOriginatorKeyFile>../key.snk</AssemblyOriginatorKeyFile>
Expand All @@ -30,10 +30,14 @@
<ProjectReference Include="..\React.Core\React.Core.csproj" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview3-19153-02" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Expand Down
8 changes: 6 additions & 2 deletions src/React.Router/React.Router.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Copyright>Copyright 2014-Present Facebook, Inc</Copyright>
<AssemblyTitle>ReactJS.NET Router</AssemblyTitle>
<Authors>Daniel Lo Nigro, Gunnar Már Óttarsson</Authors>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>React.Router</AssemblyName>
<AssemblyOriginatorKeyFile>../key.snk</AssemblyOriginatorKeyFile>
Expand All @@ -27,12 +27,16 @@
<Compile Include="..\SharedAssemblyVersionInfo.cs" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.0" />
<PackageReference Include="Microsoft.Sourcelink.Github" Version="1.0.0-beta2-19270-01" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview3-19153-02" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\React.AspNet\React.AspNet.csproj" />
<ProjectReference Include="..\React.Core\React.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworks>netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.2' ">
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x86" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x64" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.Extensions.MsDependencyInjection" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
Expand Down
19 changes: 13 additions & 6 deletions src/React.Sample.Webpack.CoreMvc/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@ public void ConfigureServices(IServiceCollection services)
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

// Initialise ReactJS.NET. Must be before static files.
app.UseReact(config =>
{
Expand All @@ -57,11 +52,23 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseStaticFiles();

#if NETCOREAPP3_0
app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("default", "{path?}", new { controller = "Home", action = "Index" });
endpoints.MapControllerRoute("comments-root", "comments", new { controller = "Home", action = "Index" });
endpoints.MapControllerRoute("comments", "comments/page-{page}", new { controller = "Home", action = "Comments" });
});
#else
app.UseMvc(routes =>
{
routes.MapRoute("default", "{path?}", new { controller = "Home", action = "Index" });
routes.MapRoute("comments-root", "comments", new { controller = "Home", action = "Index" });
routes.MapRoute("comments", "comments/page-{page}", new { controller = "Home", action = "Comments" });
});
#endif
}
}
}
Binary file modified tools/NuGet/nuget.exe
Binary file not shown.
25 changes: 7 additions & 18 deletions tutorial-code/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace ReactDemo
{
public class Startup
{
public Startup(IHostingEnvironment env)
public Startup(IWebHostEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
Expand All @@ -43,20 +43,9 @@ public void ConfigureServices(IServiceCollection services)
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseDeveloperExceptionPage();

// Initialise ReactJS.NET. Must be before static files.
app.UseReact(config =>
Expand Down Expand Up @@ -85,11 +74,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF

app.UseStaticFiles();

app.UseMvc(routes =>
app.UseRouting();

app.UseEndpoints(endpoints =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
}
}
Expand Down
Loading