Open vgeronimos opened 4 months ago
This ended up being a bit deeper than I expected. The changes here have a few steps:
*.paket.props
, add the group's ReferenceCondition
to the condition grouping, and include it in the generated <ItemGroup>
's condition.*.paket.resolved
, add the group's ReferenceCondition
as the 10th item on each line.GetConditions
, to get a list of all of the conditions defined on groupsFixNuspecs
public API method to allow specifying which conditions to use when re-associating the nuspec package names with dependency groupsshow-conditions
subcommand and a --conditions
parameter to fix-nuspecs
to use the above changesPaket.Restore.targets
to make use of all of the above:
PaketRestore
now reads the conditions for the lines in *.paket.resolved
, and if specified will check if the corresponding property is defined before adding a <PackageReference>
PaketOverrideNuspec
uses the show-conditions
subcommand to get a list of properties that are relevant, and then constructs a list of the ones that evaluate to 'true'. If there are any, they are passed to fix-nuspecs
.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.
This is to fix #2394 - the
condition
values inpaket.dependencies
are now included in theobj/<project>.paket.props
files after runningdotnet restore
.