I started a new ASP.NET Core WebApi project from Visual Studio. Project initialized and started without problem.
Now I want to add a .NET Core class library to contain logic separated from the app. So I right-clicked the src folder, chose Add -> New Project and chose Class LOibrary (.NET Core).
In my class library I created a new middleware:
namespace MyClassLib
{
public class MyMiddleware
{
private readonly RequestDelegate _next;
public MyMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
await _next.Invoke(context);
}
}
}
And created extension method for it:
namespace MyClassLib
{
public static class MyMiddlewareExtensions
{
public static IApplicationBuilder UseMyMiddleware(this IApplicationBuilder builder)
{
return builder.UseMiddleware<MyMiddleware>();
}
}
}
So far nothing fancy.
In my web API I added a reference to that project:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"MyClassLib": "1.0.0-*"
}
But when I try to use my new class library in my WebApi startup class it doesn't seem to recognize it - showing the using MyClassLib in red (error) and not allowing me to use any of the classes inside it.
What am I missing here? previous to .NET Core this is something I used to do all the time...
EDIT
Strange, but if I disable ReSharper than everything works. If I re-enable ReSharper than it shows errors again but still compiles. I've seen posts on GitHub from people who encountered this problem on RC1 - but it was mentioned that it was fixed. Anyone knows how I can continue working with ReSharper and .NET Core?