Skip to content

Add PaketReference MSBuild item in projects instead of paket.references #2606

@0x53A

Description

@0x53A

Instead of having the references in a second file paket.references, I would like to include them into the project file.

This could look like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>    
  </PropertyGroup>

  <ItemGroup>
    <PaketReference Include="FSharp.Core" />
    <PaketReference Include="xunit" Group="Test" />
  </ItemGroup>
  
  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>

  
  <Import Project="..\.paket\Paket.Restore.targets" />
  
</Project>

Advantages:

  • Similar to the Nuget PackageReference, so maybe easier to explain to someone coming from nuget (just replace all PackageReferences with PaketReferences, and remove the explicit versions, because the versions are handled by paket)
  • It can be dynamically programmed. For example let's say I want to include some Analyzer in all my C# projects.
    ** Currently I need to explicitly add it to all paket.reference files. The most I could do is to then write a unit test that verifies that yes, all projects really import it. If I create a new project, and forget it, the UT fails.
    ** With this feature, I could solve this via MSBuild programming and e.g. a Directory.props
  • The new project format is nice and pretty (well, relative for xml) readable. So why split it up into two files?
  • You could do a conditional reference (this would solve NewSdk and MultiTargeting and Conditions #2596) via <PaketReference Include="FSharp.Core" Group="netcore" Condition=" '$(TargetFramework)' != 'net35' " />

Edit:

I just saw that this was already proposed at #2019.

I guess it was unlikely that I would be the only one to think of this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions