Search code examples
c#msbuildnugetexpression-trees

Nuget secondary file depends on current project build


I've written a library of expression-tree-related test objects (for the types in System.Linq.Expressions), which I use in tests for ExpressionTreeToString.

The library is in two .NET Standard class library projects within the solution:

  1. ExpressionTreeTestObjects -- expressions generated via the C# compiler and by calling the expression tree factory methods
  2. ExpressionTreeTestObjects.VB -- expressions generated by the VB.NET compiler

ExpressionTreeTestObjects also exposes the main entry point for getting the list of objects (via reflection over the assemblies in the current domain).

I want to publish both DLLs as a single NuGet package.

Where should I put the NuGet package information?

The obvious choice (to my mind) is in ExpressionTreeTestObjects. But how can there be a reference there to ExpressionTreeTestObjects.VB, when ExpressionTreeTestObjects.VB also depends on ExpressionTreeTestObjects? Isn't this a cyclical build dependency?


I suppose an alternative would be to separate code which generates the expression tree objects, from the main entry point code; and put the entry code in a third project (ExpressionTreeTestObjects.Loader) which would reference both original projects. The package information would then go on that third project.

But adding a separate project feels like it should be unnecessary.


Solution

  • I've included the package information in the ExpressionTreeTestObjects.VB project, as can be seen here.