title: .vcxproj File's Import Declaration Causing Error In Visual Studio 2019
body: <p>This line which appears twice in .vcxproj files:
  <code>&lt;Import Project=&quot;$(SolutionDir)\$(SolutionName).props&quot; /&gt;</code></p>
  <p>Seems to be causing this QT error when loading the solution in VS2019:</p>
  <blockquote>
  <p><em>ProjectName</em>.vcxproj: background build ERROR: The imported project &quot;C:\Users\...\ProjectFolder\.props&quot; was not found. Confirm that the expression in the Import declaration &quot;C:\Users\...\ProjectFolder\.props&quot; is correct, and that the file exists on disk. C:\Users\...\ProjectFolder\ProjectName.vcxproj</p>
  </blockquote>
  <p>The first issue: I noticed the error has two backslashes on the second directory. I read on a Microsoft Docs that <code>$(ProjectDir)</code> returns a trailing backslash, so I removed the one in the Import Declaration which left it with only one backslash.</p>
  <p>The main issue: After removing the backslash, it appears that the <code>$(SolutionName)</code> macro is returning an empty/null string, causing QT to try and load &quot;.props&quot;. Whats interesting is that if you type ANY text to the left OR right of the macro (in the import declaration), it instead returns the appropriate solution name as intended, but with the additional text messing up the path. Remove that text and reload VS and it goes back to returning an empty string. For example:</p>
  <p><code>$(SolutionDir)$(SolutionName)asdf.props</code> results in &quot;C:\Users\...\ProjectFolder\ProjectNameasdf.props was not found&quot;</p>
  <p>and</p>
  <p><code>$(SolutionDir)asdf$(SolutionName).props</code> results in &quot;C:\Users\...\ProjectFolder\asdfProjectName.props was not found&quot;</p>
  <p>but</p>
  <p><code>$(SolutionDir)$(SolutionName).props</code> results in &quot;C:\Users\...\ProjectFolder\.props was not found&quot;</p>
  <p>In the Property Pages &gt; Executable Directories &gt; Macros window everything is defined as it should be. I've ran out of ideas</p>
  <p>What I've tried:</p>
  <ul>
  <li>Using <code>$(ProjectDir)\$(ProjectName)</code> (same error)</li>
  <li>Using <code>$(MSBuildProjectDirectory)\$(SolutionName)</code> (same error)</li>
  <li>Using <code>..\..\</code> to point it to the props file (same error)</li>
  <li>Adding <code>Condition=&quot;Exists('$(SolutionDir)\$(SolutionName).props')&quot;</code> into the import tag (changed the error to &quot;<em>ProjectName</em>.vcxproj background build FAILED!&quot;)</li>
  <li>Removing the import declaration completely</li>
  <li>Read and tried every existing StackOverflow post even remotely related</li>
  </ul>
  <p>Other info:</p>
  <ul>
  <li>Project was transferred from VS 2017 to 2019</li>
  <li>This project involves multiple solutions nested into one parent solution</li>
  <li>Each solution under the parent solution throws this error two times, I believe it's once for each Import Declaration which involves <code>$(SolutionDir)$(SolutionName)</code></li>
  <li>As mentioned this project involves QT</li>
  <li>Each child solution points to the one parent solution's .props file</li>
  <li>The project continues after these errors and functions normally without further error. However I am concerned it might cause issues later and want to clear it up for completeness sake.</li>
  </ul>