Replies: 1 comment
-
I would like this very much! Especially, there's a project agnostic logic that should be imported every time dependent properties change and should be re-validated or evaluated! You could say that's where the targets and tasks come in but no, there are uses of shared logic outside of that. Recent additions include Version and TargetFramework property functions which lead me to... User defined property and item functions: #5171 (comment) For now, some of the requests like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If a project imports the same file multiple times, the warning MSB4011 'DuplicateImport' (or MSB4210 'SelfImport') will be reported and the import will be blocked. This is to prevent circular import references.
However sometimes a file is re-used and is imported into several different projects. If the file has imports of its own, the project itself or another import of the project could have matching and conflicting imports. In MSBuild, About Import Guards I describe an "import guard" technique which is like an old C include header guard. But the C and C++ languages have moved on from needing manual include guards.
I'd like to suggest adding an optional ImportOnce="true|false" attribute to the Project element. For backwards compatibility the default value would be
false
. WhenImportOnce="true"
is set on a project, the file for that project will be imported only once on the firstImport
element that references it. (Effectively, the duplicate import detection would not generate the warning whenImportOnce
istrue
.)If A.targets has
ImportOnce="true"
as an attribute of itsProject
element, then anImport
of A.targets should follow the 'import once' policy. MakingImportOnce
an attribute of the project and an instruction to theImport
means that there can't be conflicting values ofImportOnce
.Files that are intended to be re-useable can declare
ImportOnce="true"
and files that declareImportOnce="true"
are safe to be imported as a dependency regardless of current and future use elsewhere in the same project.Thanks
Beta Was this translation helpful? Give feedback.
All reactions