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
ProjectItem.SetItemMetadata changes ProjectItem.Include to be evaluated #2432
Comments
And this is where the evaluated value is set internal void SplitOwnItemElement()
Microsoft.Build.dll!Microsoft.Build.Evaluation.Project.SplitItemElementIfNecessary(Microsoft.Build.Construction.ProjectItemElement itemElement) Line 2338 C# Symbols loaded. |
This appears to be more of a "feature" rather than a bug. A ProjectItemElement (representing an item xml element) may produce multiple ProjectItem objects (an actual item). For example, the ProjectItemElement This exploding of the ProjectItemElement happens on the following item operations
It is triggered when the unevaluated value of ProjectRootElement contains globs, semicolons, item references, or property references (properties can bring any of the other special characters). To workaround this issue, one has to use the XML editing APIs (e.g. mutate Project*Element objects), or do more weird things like: var items = p.AddItem("CICompile", "placeholder", new Dictionary<string, string> { { "metadata", "value" } });
items.First().Xml.Include = "$(MSBuildThisFileDirectory)Source.cpp"; |
had looked into this problem myself. in my opinion, the split element logic seems to be alright. |
also, I'd like to suggest, on loading a shared items project, check and convert absolute path to be relative to |
Special casing the reserved properties might improve the scenario a bit. Though it is hard to get right, as the reserved properties might get referenced from other properties ($Foo->$Bar->$MSBuildThisFileDirectory). A simplification would be to ignore the variable aliasing problem.
|
I can't find the source code for VCFilterProvider, but from some ILDASM-ed IL code, I could guess the since the IL code is too verbose to understand, I could easily be wrong, but the loading process is roughly like so: XML files for project and filters get parsed, and the |
My bad, all items are relative to |
Adding metadata to an item which has macros in its Include changes the Include to be evaluated. This is causing VS bugs:
https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=295640
https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=376742
The text was updated successfully, but these errors were encountered: