Skip to content

Bump framework version to netcoreapp3.1 #14

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions samples/WebApp/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace WebApp
{
Expand All @@ -12,7 +13,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddWebpack();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -26,7 +27,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}

app.UseStaticFiles();
app.UseMvc();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
}
6 changes: 4 additions & 2 deletions samples/WebApp/StartupWithPublicPath.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace WebApp
{
Expand Down Expand Up @@ -28,7 +29,7 @@ public void ConfigureServices(IServiceCollection services)
.AddStaticOptions(options => options.RequestPath = "/assets/");
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UsePathBase("/public/");

Expand All @@ -44,7 +45,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}

app.UseStaticFiles();
app.UseMvc();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
}
6 changes: 4 additions & 2 deletions samples/WebApp/StartupWithStaticFileOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace WebApp
{
Expand All @@ -22,7 +23,7 @@ public void ConfigureServices(IServiceCollection services)
});
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -36,7 +37,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}

app.UseStaticFiles();
app.UseMvc();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
}
2 changes: 1 addition & 1 deletion samples/WebApp/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="~/images/banner1.svg")" alt="ASP.NET" class="img-responsive" />
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
Learn how to build ASP.NET apps that can run anywhere.
Expand Down
10 changes: 1 addition & 9 deletions samples/WebApp/WebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Webpack.AspNetCore\Webpack.AspNetCore.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;
using Webpack.AspNetCore.Internal;

Expand Down Expand Up @@ -54,7 +54,7 @@ public async ValueTask<IDictionary<string, string>> ReadAsync()
}

var manifestJson = await response.Content.ReadAsStringAsync();
manifest = JsonConvert.DeserializeObject<Dictionary<string, string>>(manifestJson);
manifest = JsonSerializer.Deserialize<Dictionary<string, string>>(manifestJson);

CacheManifest(etag, manifest);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using Webpack.AspNetCore.Internal;

Expand Down Expand Up @@ -43,7 +43,7 @@ public async ValueTask<IDictionary<string, string>> ReadAsync()
{
var manifestJson = await manifestReader.ReadToEndAsync();

return JsonConvert.DeserializeObject<Dictionary<string, string>>(
return JsonSerializer.Deserialize<Dictionary<string, string>>(
manifestJson
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Webpack.AspNetCore/Static/Internal/StaticContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class StaticContext
private readonly IFileProvider fileProvider;
private readonly StaticOptions options;

public StaticContext(IOptions<StaticOptions> optionsAccessor, IHostingEnvironment env)
public StaticContext(IOptions<StaticOptions> optionsAccessor, IWebHostEnvironment env)
{
if (optionsAccessor == null)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Webpack.AspNetCore/Webpack.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
<RepositoryUrl>https://github.com/sergeysolovev/webpack-aspnetcore</RepositoryUrl>
<PackageReleaseNotes>Release notes are at https://github.com/sergeysolovev/webpack-aspnetcore/releases</PackageReleaseNotes>
<PackageLicenseUrl>https://github.com/sergeysolovev/webpack-aspnetcore/blob/master/LICENSE</PackageLicenseUrl>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

</Project>
10 changes: 3 additions & 7 deletions test/WebSites/BasicWebSite/BasicWebSite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Webpack.AspNetCore\Webpack.AspNetCore.csproj" />
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions test/WebSites/BasicWebSite/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace BasicWebSite
{
public class Startup
{
private static readonly string publicPath = "/public/";

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();

services.AddWebpack().AddDevServerOptions(opts =>
{
opts.PublicPath = publicPath;
opts.Port = 8081;
opts.ManifestFileName = "webpack-assets.json";
});
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UsePathBase(publicPath);
app.UseWebpackDevServer();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute());
}
}
}
33 changes: 33 additions & 0 deletions test/WebSites/BasicWebSite/StartupWithStaticFileOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace BasicWebSite
{
public class StartupWithStaticFileOption
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddWebpack().AddStaticOptions(opts =>
{
opts.RequestPath = "/public/";
opts.ManifestDirectoryPath = "/dist/";
opts.OnPrepareResponse = respContext =>
respContext.Context.Response.Headers.Add(
key: "Cache-control",
value: "public,max-age=31536000"
);
opts.UseStaticFileMiddleware = true;
});
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseWebpackStatic();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Net.Http;
using BasicWebSite;

namespace Webpack.AspNetCore.Tests.Integration.DevServer
{
Expand All @@ -19,28 +19,13 @@ public class DevServerTestContext : IDisposable
public DevServerTestContext()
{
var builder = new WebHostBuilder()
.UseContentRoot(WebSite.GetContentRoot())
.ConfigureServices(services =>
{
services.AddMvc();

services.AddWebpack().AddDevServerOptions(opts =>
{
opts.PublicPath = publicPath;
opts.Port = 8081;
opts.ManifestFileName = "webpack-assets.json";
});

services.AddSingleton<IHttpContextAccessor>(
new CustomHttpContextAccessor(publicPath)
);
})
.Configure(app =>
{
app.UsePathBase(publicPath);
app.UseWebpackDevServer();
app.UseMvcWithDefaultRoute();
});
)
)
.UseStartup<Startup>()
.UseContentRoot(WebSite.GetContentRoot());

server = new TestServer(builder);
client = server.CreateClient();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using BasicWebSite;
using Webpack.AspNetCore.Static.Internal;

namespace Webpack.AspNetCore.Tests.Integration.Static
Expand Down Expand Up @@ -48,28 +48,11 @@ void startServer()
.UseContentRoot(WebSite.GetContentRoot())
.UseWebRoot(webRoot)
.ConfigureServices(services =>
{
services.AddMvc();
services.AddWebpack().AddStaticOptions(opts =>
{
opts.RequestPath = "/public/";
opts.ManifestDirectoryPath = "/dist/";
opts.OnPrepareResponse = respContext =>
respContext.Context.Response.Headers.Add(
key: "Cache-control",
value: "public,max-age=31536000"
);
opts.UseStaticFileMiddleware = true;
});

services.AddSingleton<IHttpContextAccessor>(
new CustomHttpContextAccessor()
);
})
.Configure(app => {
app.UseWebpackStatic();
app.UseMvcWithDefaultRoute();
});
)
)
.UseStartup<StartupWithStaticFileOption>();

server = new TestServer(builder);
setupWaitingForStorageUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="assets\**">
Expand All @@ -18,11 +18,14 @@
<ProjectReference Include="..\WebSites\BasicWebSite\BasicWebSite.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0-beta.1.build3958" />
<PackageReference Include="xunit" Version="2.4.0-beta.1.build3958" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<Target Name="CopyDepsFiles" AfterTargets="Build" Condition="'$(TargetFramework)'!=''">
<ItemGroup>
Expand Down