novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
345 stars 43 forks source link

Per-RID project is only built once when referenced from another (non-Extras) project #258

Closed alexrp closed 3 years ago

alexrp commented 3 years ago

I have a setup where a library project A is using Extras and is set up to do per-RID builds (for a single net5.0 TFM). This works fine on its own when I type dotnet build in that project. However, when I run dotnet build from inside another library project B, which is just using the regular .NET SDK and which has a ProjectReference to A (with ReferenceOutputAssembly=false), A is only built once (RID-less).

This is problematic for 2 reasons:

  1. Project A is not actually expecting to be built RID-less. This can result in nonsensical combinations of #if paths being taken, possibly leading to compilation errors.
  2. I need to embed the compiled (RID-specific) assemblies from project B as resources in project A, but only the RID-less assembly is available.

(I don't actually know if this behavior is expected/intended and whether it's fixable.)

alexrp commented 3 years ago

OK, ignore this. Turns out all I had to do was set SkipGetTargetFrameworkProperties=true on the ProjectReference in addition to ReferenceOutputAssembly=false. Now it builds all RIDs as expected.