Closed max-win-at closed 3 years ago
A quickfix that relies on msbuild's fault tolerance is:
{
"solution": "MySolution.sln",
"mappings": {
"SimpleNuget": [
"../SimpleProject/SimpleProject.csproj",
"../SimpleProject/SimpleProject.csproj"
],
"ComplexNuget": [
"../ComplexProject.PartA/ComplexProject.PartA.csproj",
"../ComplexProject.PartB/ComplexProject.PartB.csproj"
]
}
}
When mixing "single project per package" and "multiple projects per package" in
switcher.json
eg:Calling
dnt switch-to-projects
will produce aSystem.InvalidCastException: Cannot cast Newtonsoft.Json.Linq.JArray to Newtonsoft.Json.Linq.JToken.
I helped myself by refactoring
switcher.json
to the following scheme:Using arrays with one element did the trick.
However, after replacing the package references,
dnt
persisted its restore information back intoswitcher.json
. By doing so it also reverted the JArrays with one elemet back to simple JTokens.Which means, that for the subsequent call
dnt switch-to-packages
, I again have to manually refactor each single project per package inswitcher.json
, or otherwise anotherSystem.InvalidCastException: Cannot cast Newtonsoft.Json.Linq.JArray to Newtonsoft.Json.Linq.JToken.
is produced.The complete exception stack for both cases: