Fixing ASP.NET Core Feature Folders Causing Resharper Intellisense Issues

I’ve had a handful of people ask me about this, so I figured I’d just blog on it.

The Problem

If you use Feature Folders in ASP.NET Core you may see something like this where Resharper can’t figure out where your Views are.  It will outline your View() calls in red (as well as your partials).

2017-08-24_22-57-12

 

When you run the app it still works, but it leaves a little to be desired with the Developer experience.  Feature Folders are supported in Resharper and plain ASP.NET, but in ASP.NET Core Resharper has not added support for Feature Folders yet.

 

The Fix

Luckily, there’s a workaround, that I was first notified of by Bill Sorensen on my blog post on Feature Folders linked above.

1. Install the JetBrains.Annotations NuGet package

2. Add the following attributes to the top of your IViewLocationExpander file, above the namespace*

3. Re-open your Controller and everything should work

 

  • Note – if you have more custom paths in your IViewLocationExpander than just those, then you’ll have to add those routes as well.

 

So your final output should look something like this:

 

That’s it, now Resharper is happy!

 

2017-08-24_23-11-51

 

Hope this helps.

 

 

Fix for “Package Microsoft.AspNetCore 2.0.0 is not compatible with netcoreapp2.0”

If you’re on your build server and running into the problem like this that fails on the NuGet Restore

Package Microsoft.AspNetCore 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)

 

Double check that you have NuGet 4.3 or higher installed.  

 

To fix this on TeamCity 2017.1.2+:

  1. Go to Administration in the top right
  2. Tools on the left
  3. Click Install Version under NuGet.exe
  4. Choose 4.3 or higher in the dropdown and click Add

 

Hope this helps someone else on the bleeding edge.

.NET Full Framework issue when referencing .NET Standard 1.4 library

If you get an error message when you try to reference your .NET Standard 1.4 library from a .NET full framework app (like .NET 4.6.1) you may see this error message: System.IO.FileLoadException : Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

The issue is there’s a bug with the System.Net.Http 4.3.0 package.  The fix then is to install System.Net.Http 4.3.1 in your .NET Standard library.  So your csproj should look like this:

<ItemGroup>
    <!-- Add 4.3.1 version explicitly. -->
    <PackageReference Include="System.Net.Http" Version="4.3.1" />
    <!-- Any other packages here. -->
</ItemGroup>

Now you should be good.

There are a lot of threads on GitHub about this on many different repos, but this fix is only in one of those threads and so I thought I’d post this to make it easier for the next person.