-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Central Package Management does not work with F# projects #11949
Comments
We have a solution containing a few F# and mainly C# projects. Is there a way to turn off central package management for individual projects? That way we can switch the majority of our solution over. I tried setting
|
@jeffkl |
I tried fixing this a long time ago but the change was rejected: dotnet/fsharp#6730 At this time, F# projects inject packages but don't have metadata that identifies them as implicitly defined. The only workaround is to do this yourself in <PackageReference Update="FSharp.Core" IsImplicitilyDefined="true" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
<PackageReference Update="System.ValueTuple" IsImplicitilyDefined="true" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" /> Example of workaround: |
@jeffkl should we document this on NuGet's docs for CPM? https://docs.microsoft.com/en-us/nuget/consume-packages/central-package-management |
@jeffkl sorry, how can this be "Not A Bug"? |
@knocte Central package management detects package references that should not have versions by looking at a well known metadata value for I worked around this in However, I don't think the built-in NuGet implementation should contain workarounds or knowledge of any particular package reference. In my opinion there is a bug but it is here: dotnet/fsharp#3678 |
Tangentially related but after applying the workaround I am getting this message:
Is there a workaround for this? Thanks! |
The only workaround at the moment is to suppress the warning with |
@jeffkl Thank you! I just wanted to point out a typo in your code snippet above: |
Thanks, I've updated my comment. |
Hey @jeffkl, do you have an estimate of when this fix will be available in Visual Studio? Thanks |
@sherryyshi this change will be available in the next Visual Studio 17.4 Preview and the final version due out in November. |
@jeffkl Apologies, I am not sure I am getting the intended results from following these instructions. I am working on migrating a .NET Framework solution with 94 projects (a mix of C# and F#) to CPM. /Directory.Packages.props <Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- other packages -->
<!-- we have outstanding blocking issues preventing us from upgrading beyond F# 4 right now -->
<PackageReference Update="FSharp.Core" Version="4.7.0" IsImplicitilyDefined="true" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
</ItemGroup>
</Project> /MyProject/MyProject.fsproj <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<WarnOn>3390;$(WarnOn)</WarnOn>
<OutputType>Library</OutputType>
<LangVersion>4.7</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" />
</ItemGroup>
</Project> However,
My environment info:
|
@kyleratti this worked for me: Directory.Build.targets
Directory.Packages.props
|
without a custom |
@jeffkl can you confirm that this should have been resolved in nuget 6.4 and this version is also shipped with the latest .NET SDK? because as mentioned it still gives me the error |
@stefan-schweiger the only fix available from this issue is the one about the package source mapping warning reporting local feeds. That new logic has shipped in Visual Studio 2022 17.4 and .NET SDK 7.0.100.
The original error is about PackageReference items having versions when they shouldn't:
This error is because the FSharp SDK adds packages but does not indicate that they are implicitly defined. I think a recent change might help: dotnet/fsharp#13920 But I'm not sure, that seems to disable the implicit package references so you'll have to add them yourself but at least NuGet's central package management won't give you errors. I am unsure what product version that released in. I would ask on that pull request for the most accurate information. |
It does not appear that this workaround is working in .NET 8 |
Maybe the workaround is not needed anymore? I say this because I know an F# project that is using net8 already and is using Central Package Management in master branch already: https://github.com/fsprojects/fantomas |
Just had a look at how fantomas does it and they've added |
We are actively using CPM with explicit FSharp.Core nuget reference and getting
with .NET 6 Other than that warning everything works fine |
What version of .NET6? Just asking because I know CPM is only supported in .300 or newer. |
@knocte we are just using |
NuGet Product Used
dotnet.exe, NuGet.exe
Product Version
MSBuild version 17.3.0-preview-22322-04+e504ba9f4 for .NET
Worked before?
No response
Impact
It's more difficult to complete my work
Repro Steps & Context
Repro:
Directory.Packages.props
with the following content:Get following error:
error NU1008: Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion item s: FSharp.Core;System.ValueTuple.
Verbose Logs
No response
The text was updated successfully, but these errors were encountered: