title: Could not load System.IdentityModel.Tokens.Jwt
body: <p>I have an asp.net MVC app that utilizes owin json web tokens. I have been deploying this app via the Kudu github integration, and the app works fine.</p>
  
  <p>However, I would like to move to deploy via octopus. I am able to create the nuget package needed to deploy and the package is showing as successfully deployed by my octopus server.</p>
  
  <p>Here is where things get weird:</p>
  
  <p>After I deploy via octopus, I am getting the following exception:</p>
  
  <p>Could not load file or assembly 'System.IdentityModel.Tokens.Jwt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)</p>
  
  <blockquote>
    <p>Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.IO.FileLoadException: Could not load file or
    assembly 'System.IdentityModel.Tokens.Jwt, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
    dependencies. The located assembly's manifest definition does not
    match the assembly reference. (Exception from HRESULT: 0x80131040)</p>
  </blockquote>
  
  <p><strong>TL;DR:</strong> why is it that I can run the program fine when deploying via Kudu, but not from a nuget package?</p>
  
  <p>below are some additional details:</p>
  
  <p><strong>MyApp.nuspec:</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt; &lt;package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"&gt;
      &lt;metadata&gt;
      &lt;id&gt;MyApp&lt;/id&gt;
      &lt;version&gt;1.0.0.0&lt;/version&gt;
      &lt;authors&gt;John Smith&lt;/authors&gt;
      &lt;owners&gt;MyCompany&lt;/owners&gt;
      &lt;projectUrl&gt;https://github.com/myCompany/MyApp&lt;/projectUrl&gt;
      &lt;iconUrl&gt;https://image.flaticon.com/icons/svg/297/297568.svg&lt;/iconUrl&gt;
      &lt;requireLicenseAcceptance&gt;false&lt;/requireLicenseAcceptance&gt;
      &lt;releaseNotes&gt;Intital Release&lt;/releaseNotes&gt;
      &lt;description&gt;MyApp deployment package&lt;/description&gt;
      &lt;tags&gt;web app myapp&lt;/tags&gt;
      &lt;/metadata&gt; &lt;/package&gt;
  </code></pre>
  
  <p><strong>packages.config</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;packages&gt;
    &lt;package id="Antlr" version="3.5.0.2" targetFramework="net45" /&gt;
    &lt;package id="bootstrap" version="3.3.7" targetFramework="net461" /&gt;
    &lt;package id="EntityFramework" version="6.1.3" targetFramework="net45" /&gt;
    &lt;package id="FontAwesome" version="4.7.0" targetFramework="net461" /&gt;
    &lt;package id="jQuery" version="3.1.1" targetFramework="net461" /&gt;
    &lt;package id="jQuery.Validation" version="1.16.0" targetFramework="net461" /&gt;
    &lt;package id="log4net" version="2.0.8" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights" version="2.3.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.0.7" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.3.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights.Log4NetAppender" version="2.2.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.3.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights.Web" version="2.3.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights.WindowsServer" version="2.3.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.3.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" /&gt;
    &lt;package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" /&gt;
    &lt;package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" /&gt;
    &lt;package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" /&gt;
    &lt;package id="Microsoft.Azure.KeyVault.Core" version="2.0.4" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.4" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.4.403061554" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net45" /&gt;
    &lt;package id="Microsoft.Net.Compilers" version="2.1.0" targetFramework="net461" developmentDependency="true" /&gt;
    &lt;package id="Microsoft.Owin" version="3.1.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.Owin.Security" version="3.1.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.Owin.Security.Cookies" version="3.1.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.Owin.Security.OpenIdConnect" version="3.0.1" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" /&gt;
    &lt;package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net461" /&gt;
    &lt;package id="Newtonsoft.Json" version="10.0.2" targetFramework="net461" /&gt;
    &lt;package id="Owin" version="1.0" targetFramework="net45" /&gt;
    &lt;package id="Respond" version="1.4.2" targetFramework="net45" /&gt;
    &lt;package id="System.Collections" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Diagnostics.DiagnosticSource" version="4.3.1" targetFramework="net461" /&gt;
    &lt;package id="System.Globalization" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.IdentityModel.Tokens.Jwt" version="4.0.4.403061554" targetFramework="net461" /&gt;
    &lt;package id="System.IO" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Linq" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Net.Http" version="4.3.2" targetFramework="net461" /&gt;
    &lt;package id="System.Net.Primitives" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Reflection" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Runtime" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Runtime.Serialization.Json" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Spatial" version="5.8.2" targetFramework="net461" /&gt;
    &lt;package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Threading" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" /&gt;
    &lt;package id="WebActivatorEx" version="2.2.0" targetFramework="net461" /&gt;
    &lt;package id="WebGrease" version="1.6.0" targetFramework="net45" /&gt;
  &lt;/packages&gt;
  </code></pre>
  
  <p>dependentAssembly section of my web.config:</p>
  
  <pre><code>  &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.3.0.0" newVersion="2.3.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.0.40306.1554" newVersion="4.0.40306.1554" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.IdentityModel.Protocol.Extensions" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-1.0.40306.1554" newVersion="1.0.40306.1554" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.1.1.1" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
  </code></pre>