0

I have a web service project in .Net 4.6.1 let's call it Project X, which has 2 project references(both class libs), let's call them Project A and B.

A has this in packages.config:

<package id="NLog" version="4.5.3" targetFramework="net35" />

While X and B has this in their packages.config:

<package id="NLog" version="4.5.3" targetFramework="net461" />

Now when I ran this command in project X's solution:

Update-Package –reinstall nlog -ignoreDependencies

And further, I build X's solution, and then run X. Now i want to know will code flows in project X using project A or B work fine for any nlog based logging they have inside code of A or B?

If answering this will need more explanation then request to please share any reference link which will help me understand this kind of setup and nuget target resolution for client app referring dependencies with a different nuget target for given nuget package.

Thanks

Edit:

IMHO The suggested question as this being duplicate of is not valid as that talks about scenarios when solution has projects with different nuget versions, which is not my case.

As my question is about both projects having same nuget version but different targetFramework.

Like for A it is targetFramework="net35", while for B and X it is targetFramework="net461".

But all 3 projects A,B and X using same version i.e. 4.5.3. Sorry the config i had earlier given showed versions as different but that wasn't my intention to talk about hence have edited to make version same.

So question is again how a project referring 2/more projects dependencies each of those using same version but different targetFramework gets addressed during build/execution of client app i.e. X here.

Is it like X will have nuget dll with highest targetFramework picked up and copied to it's bin? if not what happens then?

LearningNeverEnds
  • 374
  • 1
  • 3
  • 22
  • Possible duplicate of [How to enforce same nuget package version across multiple c# projects?](https://stackoverflow.com/questions/26792624/how-to-enforce-same-nuget-package-version-across-multiple-c-sharp-projects) – mjwills Jun 06 '18 at 06:20
  • http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html may be worth a read. – mjwills Jun 06 '18 at 06:23
  • @mjvills - thank you for prompt response. sure will go through it and let you know if this alone can be marked as answer to what i was looking for... – LearningNeverEnds Jun 06 '18 at 06:37
  • @mjvills - i checked the suggested link as well the duplicate suggested, but both target about scenarios when version of nuget are different and hence were not fitting as in my case version is same but package's targetFramework is different. Do you have any suggestion on that front. – LearningNeverEnds Jun 06 '18 at 09:20

1 Answers1

1

Is it like X will have nuget dll with highest targetFramework picked up and copied to it's bin? if not what happens then?

The project X will have nuget .Net 461 dll picked up and copied to it's bin, but not because of the highest targetFramework. That because the project X reference the nuget package NLog directly with target framework 461.

You can change MSBuild project build output verbosity to Normal or above, Tools->Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity. In the output window, you can notice that the NLog.dll under the net45 copy to the project x bin folder:

enter image description here

And the NLog.dll under the net35 copy to the project A bin folder:

enter image description here

To check more info about this issue, I recommend you can check following thread:

MSBuild doesn't copy references (DLL files) if using project dependencies in solution

Hope this helps.

Community
  • 1
  • 1
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Thank you Leo. It clarifies my main question, with one minor query left. With this explanation, will Project A's Dll which was built with Nlog having targetframework as 3.5, work from with in of Project X. asking this as X will only have 4.6.1 target copy of Nlog, will A's flow using Nlog break when ran from X? – LearningNeverEnds Jun 07 '18 at 10:20