I have a Visual Studio project that relies on several DLL references. Here is a sample of those references in my csproj:
<ItemGroup>
<Reference Include="Class1.Project1">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\Class1.Project1.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Class1.Project2">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\Class1.Project2.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
However, when I include this class as a project dependency in a web site project, Visual Studio is finding dependencies of the dependencies shown above. During build Visual Studio is then defaulting the "Copy Local" property to "True" and copying these dependencies into my web site's ~/bin directory.
This, in turn, is overwriting the versions of the DLL files that already exist in this directory. This causes the following error:
Could not load file or assembly 'Class5.Project5, Version=3.6.1861.2, Culture=neutral, PublicKeyToken=dfeaee0e3978ac79' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
How do I make Visual Studio default the "Copy Local" setting to "False" for everything? I do not want Visual Studio to copy DLL files automatically during build. Nor do I want to tie my build to very specific versions of a DLL.
It sounds to me as though you have multiple projects configured to output into the same directory - is this true?
If so, you'll need to review your configuration as Visual Studio assumes (nay, requires) that each project has a unique output directory.
Also, you wrote:
This, in turn, is overwriting the versions of the DLL files that already exist in this directory.
Where did these existing files come from?
Visual Studio assumes that it has full rights to make whatever changes it sees fit in the build output directories - trying to argue with it is a fine route to a whole new world of pain.
(Unfortunately, I speak from experience. Sigh.)