I have a C # project (ProjectA) that calls another C # project (ProjectB) in a separate process. The structure of the output directory of the assembly:
/ProjectA.exe
/ProjectB/ProjectB.exe
Version versions of ProjectA and ProjectB for the same assembly, in this case Newtonsoft.Json.dll.
The assembly output directory structure is achieved by adding the Nuget package for ProjectB to ProjectA. ProjectA and ProjectB are in separate solutions and are built separately. The nuget package for ProjectB was created with the following .nuspec and .targets.
<?xml version="1.0"?> <package> <metadata> <id>ProjectB</id> <version>$version$</version> <title>ProjectB</title> <authors>me</authors> <owners>me</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>ProjectB</description> <copyright>Copyright 2016</copyright> <tags>ProjectB</tags> </metadata> <files> <file src="x64\Release\*" target="build" /> <file src="ProjectB.targets" target="build/ProjectB.targets" /> </files> </package>
.
<?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <NativeLibs Include="$(MSBuildThisFileDirectory)*" /> <Content Include="@(NativeLibs)"> <Link>ProjectB\%(FileName)%(Extension)</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> </Project>
My problem is that ProjectA refers to the new version of Newtonsoft.Json.dll from the ProjectB package / assembly directory nuget instead of the old version of Newtonsoft.Json.dll, which is part of the ProjectA solution. They are different versions, so this causes problems at runtime. I understand that I can simply update the version of Newtonsoft.Json.dll in ProjectA solution, but I want to be able to solve a more general case when this is not possible. How can I prevent Visual Studio from finding the wrong Newtonsoft.Json.dll file?
c # nuget
Eric Roller Apr 15 '16 at 17:02 2016-04-15 17:02
source share