title: How to get Visual Studio to execute MsBuild InitialTargets (or building a project) when loading a project
body: <p><strong>Intro</strong></p>
  
  <p>I'm looking for an extension point "execute when VS is loading a project".
  This should also be incorporatable into a build run from outside of VS. This means it should end up in the msbuild scripts.</p>
  
  <p><strong>MSBuild InitialTargets</strong></p>
  
  <p>Now i have found that MSBuild offers an extension point for executing a target before any other is executed: the <code>&lt;Project InitialTargets="..."/&gt;</code>. This perfectly suits my need for console / build server building. However, with Visual Studio i would prefer if it would also (additionaly) occur when VS loads the solution, too.
  So i've checked whether this is the case: Yes and No.
  When i import the following project into my <code>*.csproj</code>'s:</p>
  
  <p>
    </p>
  
  <pre><code>  &lt;Target Name="TestOnStart"&gt;
        &lt;Warning Text="Hey $(MSBuildProjectName) is being initialised"/&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p></p>
  
  <p>After loading the solution in VS, the warning <em>does</em> pop up for <em>some</em> projects, but not for all.</p>
  
  <p><strong>Questions</strong></p>
  
  <ul>
  <li>How can i get VS to execute the <code>InitialTargets</code> on every load?</li>
  </ul>
  
  <p>Or maybe you can help me answer this, enabling me to find a solution myself ;-):</p>
  
  <ul>
  <li>How does VS determine whether to run a build or execute the <code>InitialTargets</code> when loading a project?
  <ul>
  <li>How can i influence this?</li>
  </ul></li>
  </ul>
  
  <p>Thank you :)</p>
  
  <p><strong>Addendum</strong>:</p>
  
  <p>I've just noticed that if i change one of the solution's project's <code>csproj</code> file externally, VS will ask me whether i want to reload the project. If i choose "reload all projects", it will execute the <code>InitialTargets</code> of all projects.
  So maybe this has to do something with caching or the like. So the solution to my problem might involve making VS believe that something in the project changed (upon/before loading the solution).</p>