Repository navigation
Don't warn about FSharp.Core redirects for projects that inherit their framework - #4487
Merged
Merged
Conversation
getDeclaredTargetProfiles returns the profiles of the project file without the net40 fallback of getTargetProfiles, so that a caller can tell a project that declares .NET Framework 4.0 from one whose framework Paket can't read, as when it comes from Directory.Build.props.
Paket doesn't read Directory.Build.props, so a TargetFramework set to a property defined there, as $(DefaultTargetFramework), expands to an empty string, which FrameworkDetection reads as net10. The project file then declares no framework, and getTargetProfiles falls back to net40 as for a project without TargetFramework. The same goes for an empty entry of TargetFrameworks, as the space after the last separator of `net8.0; `, which survives the split and becomes "" once trimmed.
… its framework Paket doesn't read Directory.Build.props, so a project that takes its framework from there declares none in its file, and the net40 fallback of getTargetProfiles took it for a .NET Framework project. The warning now checks the profiles that the project file declares, and stays silent when there is none. Fixes #4485
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4485
Since #4457,
paket installno longer warns about missingredirects: forcefor FSharp.Core in a project that declaresnet10.0, but it still warned for an SDK project that takes its framework fromDirectory.Build.props, a common way to set the framework of every project in one place. Binding redirects don't apply to such a project, so the warning was a false positive.Cause
Paket only reads the properties of the project file: it doesn't read
Directory.Build.props.ProjectFile.getTargetProfilesfalls back tonet40, whichshouldWarnAboutFSharpCoreRedirects(InstallProcess.fs) takes for .NET Framework.TargetFrameworkset to a property defined there, as$(DefaultTargetFramework), expands to an empty string, whichFrameworkDetectionreads asnet10, .NET Framework 1.0. The same goes for an empty entry ofTargetFrameworks, as innet8.0;.Fix
ProjectFile.getDeclaredTargetProfiles(GetDeclaredTargetProfiles()) returns the profiles that the project file declares, without thenet40fallback.getTargetProfilesis defined on top of it and keeps the fallback.framework: auto-detect,paket packor binding redirects, it falls back tonet40like for a project without framework, instead ofnet10.As suggested in the issue, Paket keeps reading the XML of the project only, since evaluating each project with MSBuild costs about 0.8 s. A project that inherits
net48fromDirectory.Build.propsis therefore no longer warned, and one withnet$(Version)still is, as before.Tests
TargetFrameworkSpecs: the declared profiles of an SDK project without framework (none, whileGetTargetProfileskeepsnet40), with$(DefaultTargetFramework), withnet8.0;and withnet48.BindingRedirect: thei004485-fsharp-core-warning-inherited-frameworkscenario has a project that inherits its framework fromDirectory.Build.props, one that sets it through a property defined there, and one that declaresnet48.paket installwarns about thenet48project only; without the fix, it warned about all three.