You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exception!!!
Microsoft.Build.Exceptions.InvalidProjectFileException: The expression "[MSBuild]::GetDirectoryNameOfFileAbove('', Directory.Build.props)" cannot be evaluated. The path is not of a legal form.
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1,T2](IElementLocation elementLocation, String resourceName, T1 arg0, T2 arg1)
at Microsoft.Build.Evaluation.Expander`2.Function`1.Execute(Object objectInstance, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation)
at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(XmlReader xmlReader)
at EmptyReservedProperties.Program.Main(String[] args) in C:\Users\David\Code\msbuild\src\Samples\EmptyReservedProperties\Program.cs:line 40
Environment data
Using the latest version of Microsoft.Build.Runtime (15.5.180.1)
Thoughts/Opinion
This is very likely because when loading from xml directly, there's no "this file". There is a FullPath property on Project which might do the trick if set and re-evaluated (haven't tested), but that assumed you've already loaded the project in the first place, which you can't do.
Perhaps when providing an xml reader directly there can be an overload which provides a file name which MsBuild pretends "this" file is.
I also tried setting MSBuildThisFileDirectory as a global property, but as expected got this:
System.ArgumentException: The "MSBuildThisFileDirectory" property name is reserved.
This seems to apply to any property that depends on a filename/location, including MSBuildProjectName, MSBuildThisFileDirectory, MSBuildThisFile, etc.
The text was updated successfully, but these errors were encountered:
Steps to reproduce
Minimal repro here:
https://github.com/dfederm/msbuild/tree/xml-load-missing-reserved-props/src/Samples/EmptyReservedProperties
Expected behavior
Console output:
Actual behavior
Console output:
Environment data
Using the latest version of Microsoft.Build.Runtime (15.5.180.1)
Thoughts/Opinion
This is very likely because when loading from xml directly, there's no "this file". There is a
FullPath
property onProject
which might do the trick if set and re-evaluated (haven't tested), but that assumed you've already loaded the project in the first place, which you can't do.Perhaps when providing an xml reader directly there can be an overload which provides a file name which MsBuild pretends "this" file is.
I also tried setting
MSBuildThisFileDirectory
as a global property, but as expected got this:This seems to apply to any property that depends on a filename/location, including
MSBuildProjectName
,MSBuildThisFileDirectory
,MSBuildThisFile
, etc.The text was updated successfully, but these errors were encountered: