none
How to add binding redirects in web config through NuGet packages installation RRS feed

  • Question

  • Hi Everyone, 

    I have prepared the sample MVC4 NuGet package for my dll with the dependent of the following NuGet packages compression.base, officeChart.base. I have installed my custom MVC4 NuGet pacakge in ASP.NET MVC project with framework version 4.5.2. After installation completed all dependent assembly entries are placed under the binding redirect tag of the webconfig file. But, I didn't add this entry in my NuGet packages and I don't aware regarding how this entries are added after install my NuGet packages. 

    <dependentAssembly>
            <assemblyIdentity name="Compression.Base" publicKeyToken="3d67ed1f87d44c89" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.4451.0.4" newVersion="1.4451.0.4" />
    </dependentAssembly>
    <dependentAssembly>
            <assemblyIdentity name="OfficeChart.Base" publicKeyToken="3d67ed1f87d44c89" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.4451.0.4" newVersion="1.4451.0.4" />
     </dependentAssembly>


    Could you please update the details regarding how this entries are placed in the web config file while install the NuGet packages. 

    Also, Could you please suggest me how can I overwrite this entries from my side through NuGet packages installation like below 

    <dependentAssembly>
            <assemblyIdentity name="Compression.Base" publicKeyToken="3d67ed1f87d44c89" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.4451.0.4" newVersion="1.4400.0.4" />
    </dependentAssembly>
    <dependentAssembly>
            <assemblyIdentity name="OfficeChart.Base" publicKeyToken="3d67ed1f87d44c89" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.4451.0.4" newVersion="1.4400.0.4" />
     </dependentAssembly>

    Could you please suggest me regarding this?

    Thanks,

    Ganesan R.


    Wednesday, January 30, 2019 10:23 AM

All replies

  • Hi All,

    Could you please suggest me regarding this?

    Thanks,

    Ganesan R.

    Thursday, January 31, 2019 4:58 AM
  • Hi agrothe,

    Welcome to the MSDN forum.

    >> Could you please update the details regarding how this entries are placed in the web config file while install the NuGet packages. 

    When installing package, the command is run automatically to add binding redirects to the web configuration file, please check this doc.

    If you do not want the binding redirects, please go to Tools-Options-NuGet Package Manager and check the option “Skip applying binding redirects” like the following, then those entry will not be automated added into the web config file after the Nuget Package installation.

    >> Also, Could you please suggest me how can I overwrite this entries from my side through NuGet packages installation like below

    Do you want to change the value of “newVersion”? If your custom NuGet package have some different versions, you can try to uninstall the package firstly, then re-install it with a lower version "1.4400.0.4". After that, the newVersion will become a lower version that you installed now, but the oldVersion will also change the scope as the following example:

    Best Regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, January 31, 2019 8:18 AM
    Moderator
  • Hi Sara, 

    Thanks for your detailed response

    I have tried to add the binding redirect entries using the web transform file. But, when I installed my NuGet package the required binding redirect entries are not added in web config file as I expected.

    My sample transform file entry as below,

    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    	<system.web xdt:Transform="InsertIfMissing">
    		<httpHandlers xdt:Transform="InsertIfMissing">
    			<add verb="*" path="captimage.axd" type="JavaScript.ImageHandler, EJ, Version=1.4400.0.4, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" xdt:Transform="InsertIfMissing" xdt:Locator="Match(type)"/>
    		</httpHandlers>
    		<compilation xdt:Transform="InsertIfMissing"> 
    			<assemblies xdt:Transform="InsertIfMissing">
    			</assemblies>
    		</compilation>
    		<pages xdt:Transform="InsertIfMissing">
    			<namespaces xdt:Transform="InsertIfMissing">
    				
    </namespaces>
    		</pages>
    	</system.web>
    <runtime xdt:Transform="InsertIfMissing" >
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" >
          <dependentAssembly xdt:Transform="Insert">
            <assemblyIdentity name="Compression.Base" publicKeyToken="3d67ed1f87d44c89" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.4451.0.4" newVersion="1.4400.0.4" />
          </dependentAssembly>
          <dependentAssembly xdt:Transform="Insert">
            <assemblyIdentity name="OfficeChart.Base" publicKeyToken="3d67ed1f87d44c89" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.4451.0.4" newVersion="1.4400.0.4" />
          </dependentAssembly>
          <dependentAssembly xdt:Transform="Insert">
            <assemblyIdentity name="Licensing" publicKeyToken="632609b4d040f6b4" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.4451.0.4" newVersion="1.4400.0.4" />
          </dependentAssembly>
      </assemblyBinding>
    </runtime>
    	<system.webServer xdt:Transform="InsertIfMissing">
    		<validation validateIntegratedModeConfiguration="false" xdt:Transform="InsertIfMissing"/>
    		<modules runAllManagedModulesForAllRequests="true" xdt:Transform="InsertIfMissing" />
    		<handlers xdt:Transform="InsertIfMissing">
    			
    		</handlers>
    	</system.webServer>
    </configuration>

    Please suggest me regarding how can I add this entries when install my package.

    Thanks,

    Ganesan R.


    Thursday, January 31, 2019 10:42 AM
  • Hi Ganesan,

    Thank you for your update. It seems your issue is about the NuGet Package development and our forum is to discuss the VS Installation issues.

    Please have a look at this doc: Redirecting Assembly Versions and hope it helpful for your issue.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, February 1, 2019 6:14 AM
    Moderator