#readwise
# Difference Between Directory.Build.props and .Targets Is Not Clear

## Metadata
- Author: [[github.com]]
- Full Title: Difference Between Directory.Build.props and .Targets Is Not Clear
- URL: https://github.com/MicrosoftDocs/visualstudio-docs/issues/2774
## Highlights
- Alas, yes. The problems generally arise because MSBuild is import-order dependent, and the last definition of a property, UsingTask, or target "wins".
MSBuild doesn't care about the extension--with explicit imports, you can import from any extension at any point. But there's a widely-used convention:
.props files are imported early in the import order.
.targets files are imported late in the build order.
- Choosing between .props and .targets
So what does this mean for a user who's setting a property? It's impossible to provide complete guidance, because there's a lot of MSBuild logic out there and some of it requires special handling. But I'd offer these guidelines:
For many properties, it doesn't matter where they're defined, because they're not overwritten and will be read only at execution time.
Set defaults in .props files for behavior that might be customized in an individual project.
Avoid setting dependent properties in .props files by reading the value of a possibly-customized property, because the customization won't happen until the user project.
Set dependent properties in .targets files, because they'll pick up customizations from individual projects.
If you need to override properties, do it in a .targets file, after all user-project customizations have had a chance to kick in. But be wary of derived properties--they may need to be overridden as well.
Include items in .props files (conditioned on a property). All properties are considered before any item, so user-project property customizations will be picked up, and this gives the user project the opportunity to Remove or Update any item brought in by the import.
Define targets in .targets files. But remember that this makes overriding the target more difficult if the .targets file is imported by an SDK, because the user project doesn't have a place to override it by default.
Prefer customizing properties at evaluation time over changing properties inside a target if possible. This makes it easier to load a project and understand what it's doing.