You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One solution would be to hard-code checks for Directory.Packages.props and look there for the version, but also respect @VersionOverride etc. However, it seems less brittle to use MSBuild to parse the project file and resolve the version to use.
Here's sample output from msbuild CentrallyManagedTool.csproj /t:Restore,GenerateRestoreGraphFile /p:RestoreGraphOutputPath=X:\Temp\graph.json. Note that it appears that one would need to parse version ranges that look like "NUnit.ConsoleRunner": "[3.15.2, )" in order to find a range of versions that might be installed. I don't know if there's a way to resolve it to the version that actually would get restored?
It's definitely a hack. I'd like to think DotNetClassicTool would be rarely used, given that .NET tools are the new hotness. Adding another hack to support "normal" central package management might be simplest, but I have no objection to something more complex and correct if it's non-breaking.
Switch a project using Faithlife.Build to central package management.
After you do,
DotNetClassicTool.TryCreateFrom
fails, because the<PackageReference>
element no longer has a@Version
attribute. Failing code is:FaithlifeBuild/src/Faithlife.Build/DotNetClassicTool.cs
Lines 53 to 57 in f61b0b0
An example project that repros the bug is https://github.com/bgrainger/CentrallyManagedTool.
One solution would be to hard-code checks for
Directory.Packages.props
and look there for the version, but also respect@VersionOverride
etc. However, it seems less brittle to use MSBuild to parse the project file and resolve the version to use.Based on
dotnet outdated
, one way to do this is to shell out to MSBuild, then parse the JSON it produces: https://github.com/dotnet-outdated/dotnet-outdated/blob/782521a01639e4387dd6b3fa36f8e25cd279f137/src/DotNetOutdated.Core/Services/DependencyGraphService.cs#L28Here's sample output from
msbuild CentrallyManagedTool.csproj /t:Restore,GenerateRestoreGraphFile /p:RestoreGraphOutputPath=X:\Temp\graph.json
. Note that it appears that one would need to parse version ranges that look like"NUnit.ConsoleRunner": "[3.15.2, )"
in order to find a range of versions that might be installed. I don't know if there's a way to resolve it to the version that actually would get restored?The text was updated successfully, but these errors were encountered: