You cannot invoke a target before targets are imported, but you can still dynamically generate a path to import from a property group.
Visual Studio does this when you create a Web project, as in this example from one of my projects:
<PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> </PropertyGroup> <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" />
So you could definitely define properties using conditions:
<PropertyGroup> <ImportPath Condition="Exists('path\to\some\thing.targets')">path\to\some\thing.targets</ImportPath> </PropertyGroup> <Import Project="$(ImportPath)" Condition=" '$(ImportPath)' != '' "/>
Microsoft.Bcl.Build does this, so you can too.