I have a strange issue with Nuget dependencies. I have a project as nuget package, that targets another project also as nuget package. Even when everything says version 1.2.3 it turns into 1.2.2.2.
I made probably mistake to switch between 3 and 4 numbered versions:
1.2.3
1.2.2.2
1.2.2.1
1.2.2
1.2.0
1.1.9
It behaves as if the dependency on 1.2.3 would not be recognized as 1.2.3 but 1.2.3.0 which would not be found(?) and then next lower is 1.2.2.2.
But brace yourself, I thought that OK, there is an issue with 3/4 version format, so I turned to 4 numbered format and pushed two more versions after 1.2.3:
1.2.5.1
1.2.4.1
1.2.3
When I made version 1.2.4.1 it all started to work well, 1.2.4.1 as required by the project was also acquired and built with 1.2.4.1.
But it all went crazy when I pushed version 1.2.5.1, the project was updated to acquire 1.2.5.1, it is installed yet during the build it is overridden for some reason to target 1.2.4.1 and I really have no clue now why?
After build in file xxx.deps.json is this override:
"GreenSuperGreen.Benchmarking.NetStandard/1.2.5.1": {
"dependencies": {
"Concurrent.FastReflection.NetStandard": "1.0.1",
"GreenSuperGreen.NetStandard": "1.2.5.1",
"System.Collections.Immutable": "1.5.0"
},
"runtime": {
"lib/netstandard2.0/GreenSuperGreen.Benchmarking.NetStandard.dll": {
"assemblyVersion": "1.2.4.1",
"fileVersion": "1.2.4.1"
}
}
},
I found a solution, but not the explanation.
If the project, that depends on the nuget package either DotNet or DotNetCore has set in project file:
<PreserveCompilationContext>false</PreserveCompilationContext>
Then version dependency starts working correctly again.