At my work there is a core assembly in the GAC that many applications reference. I do not want to change the web configs of all my production sites each time a new core version is published. Is there a way to specify a range or a wildcard for assembly versions?
Something like:
<compilation debug="false">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="MyCore,Version=*, Culture=neutral, PublicKeyToken=55b47eca7ec17c50"/> <!-- Does not work -->
<add assembly="*"/>
</assemblies>
</compilation>
Web. Config is used for asp.net web projects / web services. App. Config is used for Windows Forms, Windows Services, Console Apps and WPF applications.
The path attribute defines the site or virtual directory that the configuration settings cover. To specify that the settings in the <location> element apply to the default Web site, set the path attribute to Default Web Site .
A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).
There isn't any method in .NET to directly specify a range of versions, but the "version" component of the assembly name is optional. You should be able to remove it to search for all versions of the assembly.
add Element for assemblies for compilation (ASP.NET Settings Schema)
What I've done in the past is use the short name of the assembly, in other words:
<add assembly="MyCore" />
That said, sometimes keeping the assembly name (with version) is useful since it prevents old code from being executed if the site is deployed incorrectly. MSBuild can be used to rewrite the web.config files inside of a structured build lab, but it requires a bit of manual configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With