I'm really stumped on this one and could use some advice. I created a new MVC (.NET framework) web application project in Visual Studio 2017 and Visual Studio 2019. Without making any changes I ran the project and receive the following error:
Could not load file or assembly 'WebGrease', Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
I started with deleting all files from Temporary ASP.NET Files, obj and bin folders then cleaned and rebuilt the solution. I then uninstalled WebGrease and its dependencies (Antlr and Microsoft.AspNet.Web.Optimization) from the package manager and reinstalled the latest versions (Antlr v3.5.0.2, Microsoft.AspNet.Web.Optimization v1.1.3, and WebGrease v1.6.0).
packages.config
<packages><package id="WebGrease" version="1.6.0" targetFramework="net461" /></packages>
web.config
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
</dependentAssembly>
Below is the Fusion log. I'm not sure what "Post-policy reference: WebGrease, Version=1.5.1.25624..." means or how to address it.
I'm not sure where else to look but I'm at the end of my wits with this and need help please.
Update: I found a couple more discussions on this topic. One of the discussions noted that this error is because Microsoft.AspNet.Web.Optimization 1.1.3 internally references WebGrease 1.5.1.25624 even though the Nuget package itself has a dependency on WebGrease 1.5.2.14234. I tried all of the answers and suggestions but none worked. I also found this discussion which is the exact problem I'm having but none of the answers or suggestions there work either.