-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GetFileAbove intrinsic function #1277
Comments
IElementLocation is available to Expander at the point it calls the intrinsic function |
I'm working on implementing this. The <Import Project="$([MSBuild]::GetPathOfFileAbove(dir.props)" /> The implementation calls <Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildProjectDirectory)\dir.props')" /> Once it has the absolute path, it would then call @danmosemsft Does that sound like it will meet your requirements? @Microsoft/msbuild-maintainers thoughts? |
Hi @jeffkl. In all the instances in CoreFX, So I don't think |
Gotcha. So is it too much of a burden for them all to be: <Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFileDirectory)dir.props')" /> Another thought is to have an overload which takes a "starting directory" like |
This assumes it's reasonable to assume that This is not a blocking issue or anything - I simply noticed a common pattern that could potentially be simpler. I certainly don't have a strong opinion so your call .. |
I really want this function as well. From what I can tell, the only real design decision here is if you pass a relative path (like just a file name), should it be made absolute to the current working directory or current file directory. Since this function is new, we can go with whatever we want. I'll discuss it with the team and see what we come up with! |
My 2¢: error if someone puts in a relative path. It should be a filename only. |
The evaluator has access to It (hopefully) represents the directory of the project file msbuild was invoked on. So the code that interprets |
The CoreFX repo contains over 1,000 instances of this pattern:
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
it seems to me it ought to be possible to write this more compactly like
<Import Project="$([MSBuild]::GetFileAbove(dir.props)" />
This assumes that an intrinsic function can get passed the current file's location as an implicit parameter. I haven't looked at the code but I assume it can.
Once this is added, it should be fairly easy to search and replace to the new syntax.
The text was updated successfully, but these errors were encountered: