ionide / proj-info

Parse and evaluate MsBuild project files
MIT License
64 stars 37 forks source link

Report a meaningful error when MSBuild references are missing, or `ExcludeAssets` properties are not set correctly. #178

Open safesparrow opened 1 year ago

safesparrow commented 1 year ago

Is your feature request related to a problem? Please describe. A few times when using ProjInfo I ran into the issue where loadSln yielded 0 project results. Using ProjectLoader.getProjectInfo yielded a cryptic MSBuild-related error. Often the root cause for the error was that MSBuild references were either missing or they didn't have the right ExcludeAssets attributes set.

Describe the solution you'd like I would like ProjInfo APIs to detect the above cases and report a clear error which instructs the user to add appropriate MSBuild references to the project, ideally with a link to some online instructions (eg. a GitHub page).

Describe alternatives you've considered Keeping it as is - can take the user a lot of time to figure out what's happening.

baronfel commented 1 year ago

The two cases can both be detected from reading the deps.json file for the loading application/library. targets.<runtime name>.<dependency name and version> for the Microsoft.Build.* dependencies should A) be present, and B) not have a runtime child property. If they are not present, the message should tell the user to add the required dependency with ExcludeAssets="runtime" set. If the runtime node is present, the message should tell the user to add ExcludeAssets="runtime" to the existing dependency.