title: In PowerShell script, how can I restore packages to resolve error: This project references NuGet package(s) that are missing on this computer
body: <p>I am tasked with writing a PowerShell script to download the latest source code for a given branch, rebuild it and deploy it. The script I've written, is able to download projects, and in most cases has been able to rebuild them. But with one web project I get this error: </p>
  
  <pre><code>error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.Net.Compilers.2.0.1\build\Microsoft.Net.Compilers.props.
  </code></pre>
  
  <p>I've researched if PowerShell has a Update-Package command like the one available in the VS command prompt but have been unable to find the equivalent.  </p>
  
  <p>I know there's a cmdlet for Packages but from what I've seen they're used to update a specific package...what I need is to be able to have it download/update all packages referenced in the project.</p>
  
  <p>Some points that might be of interest...</p>
  
  <p>When I get latest on the solution to a new empty folder, the only thing in the packages folder is Modernizr.2.6.2. This is the same whether I'm getting latest in VS or in my PowerShell script. </p>
  
  <p>If I open the solution within VS 2017, I am able to rebuild the solution with no problems. It downloads/installs over a dozen other packages...one of which is the Microsoft.Net.Compilers.props package referred to in the error message. </p>
  
  <p>But if I delete everything and re-download the source code and then through my PowerShell script I call MSBuild to rebuild the solution I get the error mentioned above.  It never seems to download/install the missing packages.</p>
  
  <p>Anyone have any ideas how I can use MSBuild within my PowerShell script to rebuild the project and have it automatically update/install any packages it needs?</p>
  
  <p>Thanks</p>