I have a C# project that references sided assembly. When I try to update the sided assembly, the Version tag stays the same in *.csproj file even if I unload/reload project:
<Reference Include="<myAssembly>, Version=<oldVersion>, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath><myHintPath></HintPath>
</Reference>
So my project tries to reference an old version of assembly, and that causes an exception. It's such a pain to change all those versions in references manually, especially if there are alot of references.
I tried to change some attribute of reference, like SpecificVersion
, to True
and back to False
, and reference refreshed:
<Reference Include="<myAssembly>, Version=<newVersion>, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath><myHintPath></HintPath>
</Reference>
Any ideas, how to automatically update references, if I update an assembly? Note that when I reference any system assembly like System.Configuration.Install
, the reference is very simple:
<Reference Include="System.Configuration.Install" />
I can manually remove everything from that reference to sided assembly, but when I change some attribute, it gets back to the complex version, and I'm not sure if that's safe.
So how to update references normally?
If you always want to get latest version of assembly from specified path just avoid version attribute in csproj file or set SpecificVersion to False. SpecificVersion is an optional attribute that indicates whether to do the complete name matching (including version, culture and PublicKeyToken).
<Reference Include="assemblyNameOnly">
<HintPath>pathToDll</HintPath>
</Reference>
But this is not recommended because new version of assembly can cause compilation errors, e.g. method signature is changed. Instead it is better to use strong named assemblies and redirect assembly versions using config files.
<Reference Include="assemblyName, Version=Version, Culture=neutral, PublicKeyToken=keyToken, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<HintPath>pathToDll</HintPath>
</Reference>
Then Runtime will locate new assemblies using algorithm described here
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