title: When you import another msbuild file, what is the order of evaluation?
body: <p>I have a shared properties file <code>shared.properties.proj</code></p>
  
  <pre><code>&lt;Project  xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;SharedAssemblySearch&gt;$(MSBuildProjectDirectory)\..\Shared Assemblies&lt;/SharedAssemblySearch&gt;
      &lt;ParentDir&gt;..&lt;/ParentDir&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblyPath Condition="Exists('$(SharedAssemblySearch)')"&gt;$(SharedAssemblySearch)&lt;/SharedAssemblyPath&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;..\SharedAssemblies&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')"&gt;$(ParentDir)\$(SharedAssemblySearch)&lt;/SharedAssemblySearch&gt;
      &lt;SharedAssemblyPath Condition="Exists('$(SharedAssemblySearch)')"&gt;$(SharedAssemblySearch)&lt;/SharedAssemblyPath&gt;
   &lt;/PropertyGroup&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I am searching for whatever level parent directory contains the directory named <code>Shared Assemblies</code>. or alternatively <code>SharedAssemblies</code></p>
  
  <p>I'd like to put this code in a central location for the sln, so that all the projects can just import it. projects in the sln are not all at the same hierarchy level.</p>
  
  <p>Sample <code>.csproj</code></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
      &lt;Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Shared.Properties.proj))\Shared.Properties.proj"
     Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Shared.Properties.proj))' != '' "/&gt;
      &lt;ItemGroup&gt;
      &lt;Reference Include="EntityFramework"&gt;
        &lt;HintPath&gt;$(SharedAssemblyPath)\NuGet\EntityFramework.4.3.0\lib\net40\EntityFramework.dll&lt;/HintPath&gt;
       &lt;/Reference&gt;
      &lt;/ItemGroup&gt;
    &lt;Target Name="CheckReferencePaths" BeforeTargets="ResolveAssemblyReferences"&gt;
      &lt;Message Importance="high" Text="Doing CheckReferencePaths" /&gt;
      &lt;ItemGroup&gt;
       &lt;SharedAssemblyPathItem Include="$(SharedAssemblyPath)" /&gt;
      &lt;/ItemGroup&gt;
      &lt;Warning Condition="!Exists('@(SharedAssemblyPathItem)')" Text="SharedAssemblyPath not found at '@(SharedAssemblyPathItem)'" /&gt;
      &lt;Warning Condition="!Exists('@(SharedAssemblyPathItem)')" Text="SharedAssemblyPath not found at '@(SharedAssemblyPathItem-&gt;'%(FullPath)')'" /&gt;
      &lt;Message Condition="!Exists('%(Reference.HintPath)')" Text="FullPath=%(Reference.HintPath)" Importance="high" /&gt;
  </code></pre>
  
  <p>
      </p>
  
  <p>I have this working in the main project without pushing the property group out to a satellite file that I import, but now want to make it reusable between other projects that could have shared references.</p>
  
  <p>The  <code>BeforeTargets</code> target shows this on the new attempt that is not working:</p>
  
  <blockquote>
    <p>CheckReferencePaths:
    Doing CheckReferencePaths
    D:\projects\Team\Project\Adapters\DbAdapter\dbadapter.csproj(103,5):
    warning : SharedAssemblyPath not found at ''
    D:\projects\Team\Project\Adapters\DbAdapter\dbadapter.csproj(104,5):
    warning : SharedAssemblyPath not found at ''<br>
    FullPath=\NuGet\EntityFramework.4.3.0\lib\net40\EntityFramework.dll<br>
    FullPath=</p>
  </blockquote>
  
  <p>How can I get the project file that imports the shared to evaluate the imported project's properties before it evaluates the item groups' hintpaths. Or is the evaluation order proper, but something else in my construction is incorrect?</p>