Support Directory.Build.props for target framework configuration#362
Merged
runesoerensen merged 21 commits intomainfrom Dec 10, 2025
Merged
Support Directory.Build.props for target framework configuration#362runesoerensen merged 21 commits intomainfrom
Directory.Build.props for target framework configuration#362runesoerensen merged 21 commits intomainfrom
Conversation
`.is_file()` already checks for existence, so `.exists()` is redundant
The `is_file()` will simply return false if 'ancestor' is a file (e.g. `.../MyProject.csproj/Directory.Build.props`), or if the `Directory.Build.props` file doesn't exist). While the explicit `.is_dir()` check may be slightly more readable, this approach halves the system calls / IO overhead
Directory.Build.props target framework configurationDirectory.Build.props for target framework configuration
7a1cab8 to
5f2673b
Compare
edmorley
approved these changes
Dec 10, 2025
heroku-linguist Bot
added a commit
that referenced
this pull request
Dec 11, 2025
## heroku/dotnet ### Added - Support for configuring the target framework using `Directory.Build.props`. ([#362](#362)) - Support for configuring the `AssemblyName` property in file-based apps. ([#359](#359)) ### Fixed - Fixed an issue where leading whitespace in file-based app configuration values was incorrectly included. ([#359](#359))
Merged
heroku-linguist Bot
added a commit
that referenced
this pull request
Dec 13, 2025
## heroku/dotnet ### Added - Support for configuring the target framework using `Directory.Build.props`. ([#362](#362)) - Support for configuring the `AssemblyName` property in file-based apps. ([#359](#359)) ### Fixed - Fixed an issue where leading whitespace in file-based app configuration values was incorrectly included. ([#359](#359))
heroku-linguist Bot
added a commit
that referenced
this pull request
Dec 13, 2025
## heroku/dotnet ### Added - Support for configuring the target framework using `Directory.Build.props`. ([#362](#362)) - Support for configuring the `AssemblyName` property in file-based apps. ([#359](#359)) ### Fixed - Fixed an issue where leading whitespace in file-based app configuration values was incorrectly included. ([#359](#359)) Co-authored-by: heroku-linguist[bot] <136119646+heroku-linguist[bot]@users.noreply.github.com>
heroku-linguist Bot
added a commit
to heroku/cnb-builder-images
that referenced
this pull request
Dec 13, 2025
## heroku/dotnet ### Added - Support for configuring the target framework using `Directory.Build.props`. ([#362](heroku/buildpacks-dotnet#362)) - Support for configuring the `AssemblyName` property in file-based apps. ([#359](heroku/buildpacks-dotnet#359)) ### Fixed - Fixed an issue where leading whitespace in file-based app configuration values was incorrectly included. ([#359](heroku/buildpacks-dotnet#359))
heroku-linguist Bot
added a commit
to heroku/cnb-builder-images
that referenced
this pull request
Dec 13, 2025
## heroku/dotnet ### Added - Support for configuring the target framework using `Directory.Build.props`. ([#362](heroku/buildpacks-dotnet#362)) - Support for configuring the `AssemblyName` property in file-based apps. ([#359](heroku/buildpacks-dotnet#359)) ### Fixed - Fixed an issue where leading whitespace in file-based app configuration values was incorrectly included. ([#359](heroku/buildpacks-dotnet#359)) Co-authored-by: heroku-linguist[bot] <136119646+heroku-linguist[bot]@users.noreply.github.com>
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.
This PR adds support for detecting the target framework via
Directory.Build.propsfiles. Previously, the buildpack required theTargetFrameworkto be explicitly defined in project files to determine the .NET SDK version.The buildpack now mimics MSBuild behavior by walking up the directory tree to find the first
Directory.Build.propsfile and inheriting the configuration.As an example, the buildpack will inherit
net8.0as the target framework, unless explicitly defined, in projects or file-based apps located in the same directory and subdirectories of the followingDirectory.Build.propsfile:Changes
TargetFramework, the buildpack now searches the directory tree to find, parse, and extract the property from aDirectory.Build.propsfile.FileLoadErrorenum. This reduces code duplication and ensures consistent error handling across project files, file-based apps, andDirectory.Build.propsfiles.READMEto reflect that the target framework can now be resolved viaDirectory.Build.props.Limitations
This implementation performs a "naive" parse of
Directory.Build.propssolely for SDK version detection.Advanced MSBuild features are not supported during this detection phase:
Conditionattributes)..propsor.targetsfiles).Note: These limitations only affect how the buildpack determines which .NET SDK to install. Once the SDK is installed,
dotnet publishwill processDirectory.Build.propsusing the actual MSBuild engine, fully supporting all features (conditions, imports, etc.).Closes #187
GUS-W-20429520