Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.17k stars 729 forks source link

MSBuild - copy Bicep compilation results to referenced projects #5048

Open aelij opened 2 years ago

aelij commented 2 years ago

Is your feature request related to a problem? Please describe. When we reference projects with MSBuild <Bicep/> items, the resulting JSON files are not copied to the referenced project's output directory. This is essential to run tests and to properly componentize libraries containing Bicep files.

Describe the solution you'd like I suggest that instead of writing the compilation result directly to the output directory, the Bicep targets will compile to the intermediate directory (e.g. obj/bicep), then add the resulting files as <Content CopyToOutputDirectory="PreserveNewest" /> items, which would take care of copying them to all outputs, including references. Note you may need to change the order of the targets.

majastrz commented 2 years ago

This will be a behavior change (potentially even a breaking change for some users), so I think we'll have to be careful about enabling it by default.

We do support the NoTarget SDK today. I'm not sure if Content items are supported in there. If they're not, then we'd definitely need to keep the current behavior either for that SDK alone or make the new behavior opt-in.

That said, this feature would make it easier to flow compiled Bicep files through project references in complex builds, so I think we should implement it.