Add item-based AggregateConfigInput support, XML handler, and .NET 10 - #99
Open
richardsondev wants to merge 7 commits into
Open
richardsondev wants to merge 7 commits into
richardsondev wants to merge 7 commits into
Conversation
Bump global.json to the 10.0.100 SDK, target net10.0 in the unit test project, and install the 8.0, 9.0 and 10.0 SDKs in the build and integration workflows so multi-targeting test projects can build. The Pages workflow no longer requests a preview SDK.
IFileSystem now exposes WriteAllTextAsync and drops the unused read helpers; every file handler returns a Task from WriteOutput. A new XmlFileHandler maps XML to the JSON intermediate form: root children become properties, attributes become @name, text next to attributes becomes #text, and repeated elements become arrays. JSON arrays are written back as a wrapper element with one child per item. Output is written with a UTF-8 declaration and platform newlines. FileType gains Xml, and Yml with Yaml kept as an alias. The unit test data source for format round trips now deduplicates enum aliases and only uses XML as a starting format, since XML carries no types.
Ship build/ and buildMultiTargeting/ props and targets in the package. The props file registers the task and the AggregateConfigInput build action; the targets file adds an AggregateConfigCompile target that runs before PrepareForBuild by default, batches items by OutputFile, and supports incremental builds through Inputs and Outputs. Missing OutputType and OutputFile metadata default to Json and $(AggregateConfigOutputPath)%(Filename).json. The target is skipped in the outer build of multi-targeting projects.
The integration project now declares AggregateConfigInput items that are embedded as resources and verified by EmbeddedResourceTests. PackageStructureTests builds two standalone projects, one single-target and one multi-target, against the freshly packed package to verify the build/ and buildMultiTargeting/ layouts, item-based aggregation, and the legacy direct task invocation. The package version reaches those projects through assembly metadata set when UseLocalPackageVersion is enabled. The explicit System.Text.Json reference is dropped because the .NET 10 SDK prunes it, and the TestProjects folder is excluded from the integration project's default items.
Describe the AggregateConfigInput item approach, its properties and metadata defaults, the PrepareForBuild default timing, and the XML mapping in the README. Add a migration guide to the docs site and an example project with sample configuration files.
The example is a standalone project with its own PackageReference version, so it must not inherit the repository's Directory.Packages.props or restore fails with NU1008.
The Ubuntu and Windows integration jobs hung after the test host started. The child dotnet build now disables MSBuild node reuse and the shared compiler server so it cannot attach to processes owned by the outer test run, reads stdout and stderr asynchronously so neither pipe can block, and is killed with its output after four minutes instead of stalling the job until the workflow timeout.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an item-based way to use the package, modelled on
Azure.Bicep.MSBuild: declare<AggregateConfigInput>items and the package's ownAggregateConfigCompiletarget aggregates them during the build, with no custom target required. The legacy direct task invocation keeps working unchanged.Alongside that, this PR adds an XML file handler, moves file writes to async, and brings the repository to the .NET 10 SDK.
Item-based configuration
build/andbuildMultiTargeting/props and targets are shipped in the package. The props file registers the task and theAggregateConfigInputbuild action.AggregateConfigCompileruns beforePrepareForBuildby default so generated files exist before resources are embedded.AggregateConfigCompileBeforeTargets,AggregateConfigCompileAfterTargetsandAggregateConfigCompileDependsOncontrol the timing.OutputFileand usesInputs/Outputsfor incremental builds. MissingOutputTypedefaults toJson; missingOutputFiledefaults to$(AggregateConfigOutputPath)%(Filename).json.XML support
FileType.Xmlreads and writes.xml. Root children become properties, attributes become@name, text next to attributes becomes#text, and repeated elements become arrays. JSON arrays are written as a wrapper element with one child per item.FileType.Ymlis added withYamlkept as an alias.Other changes
IFileSystem.WriteAllTextAsyncreplaces the synchronous write and the unused read helpers; every handler returns aTaskfromWriteOutput.PackageStructureTestsbuild a single-target and a multi-target project against the freshly packed package, verifying both package layouts, item-based aggregation and the legacy invocation. The integration project also embeds three item-based outputs and checks them.examples/.Notes for reviewers
InputDirectorysemantics are unchanged: for item-based inputs the task merges every file ofInputTypein the directory that contains the items. Items sharing anOutputFileshould live in the same directory.PackageStructureTestsneed the freshly packed package. Locally:dotnet build src/Task -c Release -p:Version=0.0.1-local, then rundotnet test test/dirs.proj -c Release -p:Version=0.0.1-local -p:UseLocalPackageVersion=truewithRestoreAdditionalProjectSourcespointing atsrc/Task/bin/Release.Relates to #17 (sample projects), #21 (incremental output for the item-based path) and #33 (XML is a first step toward app.config support).
Test plan
dotnet test src/dirs.proj -c Release -warnaserror: 70 unit tests passdotnet test test/dirs.proj -c Release -warnaserror -p:UseLocalPackageVersion=trueagainst a freshly packed package: 15 integration tests pass, including the single-target and multi-target package builds