title: Create Visual Studio project template with custom targets file import
body: <p>We use external API that can change versions, so we created target file where it is easy to switch which version of the API is included. Import looks like this:</p>
  
  <pre><code>&lt;Import Project="$(ExternalDir)API\Api.References.All.Latest.targets" /&gt;
  </code></pre>
  
  <p>It is a pain to create a new project now because you need to edit it manually to include the targets file, so I am trying to create a project template. I used <code>File-&gt;Export Template</code> to create a new template from existing project. But when I try to create a project using that template I get following error:</p>
  
  <blockquote>
    <p>C:\Users\name\AppData\Local\Temp\yuavfizw.xis\Temp\TestProject.csproj:
    The imported project
    "C:\Users\name\AppData\Local\Temp\yuavfizw.xis\Temp\API\Api.References.All.Latest.targets"
    was not found.</p>
  </blockquote>
  
  <p><code>$(ExternalDir)</code> is defined in another targets file that is imported to the same project. The import is also present in the project template. Import looks like this:</p>
  
  <pre><code>&lt;Import Project="..\constants.*.targets" /&gt;
  </code></pre>
  
  <p>Is there any way to work around this error?</p>