Closed twenzel closed 5 years ago
Thanks! Would you mind submitting the contents of project.assets.json
located on obj
folder? The error seems to be related to parsing that file.
I'm getting the same issue and it's because there are two targets. So maybe the code needs to be updated to handle multiple targets? I'm providing a top level view of my project.assets.json
because it's 24k lines and I think that the multiple targets probably highlight the issue since Single()
is going to throw an exception with multiple targets. Work around in the code might be First()
or FirstOrDefault()
but that's just my first thought and opinion.
{ "version": 3, "targets": { ".NETCoreApp,Version=v2.2": { // ... whole lot of data! }, ".NETCoreApp,Version=v2.2/win-x64": { // ... whole lot of data! } } }
Thanks, will see if I’m able to reproduce. Multiple targets should not be sn issue, but for some reason the project.assets.json
contains two targets with same TFM. Which is weird.
Multiple targets would always be an issue if you're calling Single()
on a collection with more than one, that's why its usage is seldom. First()
and FirstOrDefault()
tend to be best practice unless you've already explicitly checked that there is a single element before trying to access it.
Hence the predicate inside the Single()
, https://github.com/mholo65/depends/blob/master/src/Depends.Core/DependencyAnalyzer.cs#L205, and an expectation not to find more than one matching elements. In the project.assets.json
files I worked with, when testing I’ve seen multiple targets, but only one target per target framework. I can’t understand why there are more than one target with same target framework, therefore it would be great to have a look at such file.
I'm not sure why this project does that but I do have other projects that target windows and macos but the same framework. That could be another instance.
I'll look over my file and make sure it doesn't have anything sensitive. Should I just post the file contents here or would you like me to send it to you another way? Thanks for the help!
Now I see. <OutputType>Exe</OutputType>
in the .csproj
will create two targets in project.assets.json
for the same target framework. One with the RID (runtime identifier) and one without. Need to dig deeper and decide which one of these to pick.
Fantastic, let me know if you need any other info.
Fixed in https://github.com/mholo65/depends/commit/5549980c646b5e3c7e00a0d0854a0c6d333afa95, I've now pushed 0.3.1 to NuGet. Will be available soon.
This is my csporj: