Added support for skipping bicep build in MSBuild targets #11916
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Incremental build logic in our MSBuild targets currently doesn't track references to modules, which means that we do not rebuild parent modules if only the child is modified.
The correct fix would be to allow the MSBuild targets to run the
SourceFileGroupingBuilder
to figure out the dependencies of each file. However, there are challenges with making Bicep.Core a dependency of our MSBuild task due to various issues with how MSBuild itself handles transitive task dependencies. Another option would be to call the Bicep CLI and have it return the list of dependencies for a file (could be a new verb). This would mean a process would need to be invoked every time the MSBuild project build is attempted, which defeats the point of incremental build. The startup overhead could be optimized away by wrapping it in a shared service instantiated by any concurrently running Bicep MSBuild tasks (Roslyn does it this way), but the solution is very expensive and not currently planned.There is a much simpler option that will allow the users of our MSBuild task to unblock themselves by simply declaring the child modules in the Bicep project just like they do the parent modules. If building child modules is not desired, I've introduced a new
NoBuild
metadata to theBicep
item type that will cause us to skip bicep build for that file however we will still count the file as an input as far as MSBuild is concerned. This will allow MSBuild to build the parent modules even if only the child module changes. The credit for this idea goes to @abatishchev ❤️.Microsoft Reviewers: Open in CodeFlow