Conditional ItemGroup in .csproj (SDK style)
I'm trying to add this conditional ItemGroup
Basically, want to use the ItemGroup if I have not run dotnet pack OR I have run dotnet build.
Any ideas why this isn't working? Even just using MSBuildProjectBuild check doesn't work for me.
2 Replies
So, PackageReferences can't really be conditionalized successfully on a whole lot.
Kinda depends what those properties do.
But it's important to understand that PackageReferences are processsed during Restore.
ie, if you do a Restore, and set one set of variables, but then do either a Build or Publish with a different set, something is going to break.
And during this Restore pass, since it's job is to resolve PackageReferences themselves, the autogenerated nuget targets and props files which represents the imports from other PackageReferences won't exist yet.
Thank you