fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
1.99k stars 520 forks source link

Implement group conditions for SDK-style projects #4247

Open vgeronimos opened 4 months ago

vgeronimos commented 4 months ago

This is to fix #2394 - the condition values in paket.dependencies are now included in the obj/<project>.paket.props files after running dotnet restore.

vgeronimos commented 4 months ago

This ended up being a bit deeper than I expected. The changes here have a few steps:

I needed this to be able to produce packages that use different sets of dependencies based on the configuration being built. The build then sets properties based on which configuration is selected. With these changes to Paket, the assemblies are all built with the expected set of dependencies, and the resulting .nupkg files reflect that.

To be able to switch the values of the properties, I have to restore the project with msbuild -t restore -c <configuration> instead of dotnet restore because the dotnet command doesn't have a way to provide properties or configurations to the restore on the command line.

I haven't got any new tests for the majority of these changes - I had a look and got a bit lost on how to structure them and where to add them. I think these would go in the integration tests, with some cut down .csproj files, but I'm not sure.