Upgrading WebGrease to version 1.3.0 gets me error

后端 未结 14 2105
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 14:05

While upgrading WebGrease to version 1.3.0 gets me error:

Could not load file or assembly \'WebGrease, Version=1.0.0.0, Cult

相关标签:
14条回答
  • 2020-12-23 14:14

    This is what my runtime section looks like and it works

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.3.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    
    0 讨论(0)
  • 2020-12-23 14:20

    Here is the answer that has worked for me, and it is a combination of some of the above answers. First install / uninstall / reinstall the following packages:

    Install-Package Microsoft.AspNet.Web.Optimization 
    Update-Package WebGrease
    Uninstall-Package Microsoft.AspNet.Web.Optimization
    Uninstall-Package WebGrease
    Install-Package Microsoft.AspNet.Web.Optimization 
    Update-Package WebGrease
    

    Then make a copy of the contents of ~/Views/Shared/_Layout.cshtml delete the _Layout.cshtml file, recreate it and paste the contents back in.

    this is the final fix that has worked for me.

    0 讨论(0)
  • 2020-12-23 14:20

    I had the same issue. Another developer upgraded the WebGrease package (as well as others), but something didn't sync or get checked in. I edited the package file to remove the references to the existing package. Then I reinstalled via Package Manager. Finally, I updated the packages.

    It seems as though packages won't install or update if the packages.config file does not match the files (including proper versions) in your project. No error is given in the Package Manager though, it just fails to update or install packages.

    0 讨论(0)
  • 2020-12-23 14:26

    I had a similar issue except it wasn't an error but a warning. After updating WebGrease to 1.3.0, a build put the warning source on the declaration. After ensuring that I had the appropriate assembly redirect in my web.config file, I eventually created a new _Layout.cshtml view and saved over the old file with the exact same razor markup as was in the previous (copy/paste). After that, the warning went away.

    I'm not exactly sure what the warning was all about but try copying your code in your file, pasting it into a new file and overwriting the original.

    If anyone has any insight as to why this works, I'm all ears.

    0 讨论(0)
  • 2020-12-23 14:28

    It's a problem with Microsoft.AspNet.Web.Optimization (Optimise moving forward).

    You need to downgrade WebGrease by uninstalling Optimise and removing any WebGrease assembly redirects from web.config.

    Then reinstall Optimise and make sure you don't upgrade WebGrease.

    It's a quick fix but it got my build working!

    0 讨论(0)
  • 2020-12-23 14:30

    To fix this, all i did was to Update the package.config file (WEBMATRIX)

    <packages>
      <package id="Microsoft.AspNet.Web.Optimization" version="1.0.0" targetFramework="net40" />
      <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
      <package id="WebGrease" version="1.3.0" targetFramework="net40" />
    </packages>
    

    Cheers!!!

    0 讨论(0)
提交回复
热议问题