title: dotnet restore solution is restoring projects like they are .net framework projects when called from GitHub Actions
body: <p>I have a solution with many projects, and we are migrating to .NET SDK style projects, but for now we have a mix of .NET framework style projects and .NET SDK style projects.</p>
  <p>We are also migrating to GitHub actions, and this solution was building without errors previously, but the restore action started failing when dotnet was updated from 6.0.300 to 6.0.400 (update: I tried targeting 6.0.300 specifically in the <code>setup-dotnet</code> action, but it's throwing the same errors, so I'm not sure what changed to cause it to fail like this when it was working before.)</p>
  <p>I updated our local action server to 6.0.400, and when I run the command <code>dotnet restore ./path/to/solution.sln</code> it is restoring the NuGet packages for just the .NET SDK style projects as expected.</p>
  <p>dotnet is installed with this GitHub action</p>
  <pre class="lang-yaml prettyprint-override"><code>    - name: Setup .NET
        uses: actions/setup-dotnet@v2
        with:
          dotnet-version: 6.0.x
  </code></pre>
  <p>and restore is being called with this GitHub action</p>
  <pre class="lang-yaml prettyprint-override"><code>    - name: Restore dependencies
        run: dotnet restore ${{env.SOLUTION_FILE_PATH}}
  </code></pre>
  <p>and when <code>dotnet restore</code> is being run from the GitHub action, I am getting the following error <code>error MSB4057: The target &quot;Restore&quot; does not exist in the project.</code> for all of the .NET SDK style projects. It's as if it's trying to restore NuGet packages using the older .NET Framework style NuGet packages. This is very different than what I've seen before and is unexpected. I have a separate action for calling <code>nuget restore ./path/to/solution.sln</code> for restoring packages for the .NET framework style projects, and I'm expecting <code>dotnet restore</code> to only restore the .NET SDK style projects.</p>
  <p>Has anyone else run into similar problems with dotnet 6.0.400? Are there better options for restoring NuGet packages in GitHub actions?</p>
  <p>I'm not really sure where to look next because running the command line commands locally work exactly how I would expect them to, and it only behaves oddly when getting called from GitHub actions.</p>
  <p><strong>Update:</strong>
  I've been able to reproduce the failure locally by running the dotnet version that is being installed locally as part of <code>actions/setup-dotnet@v2</code></p>
  <p>If I run <code>dotnet restore ...</code> from the global install location C:\Program Files\dotnet\dotnet.exe then I get the following output which is what I expect</p>
  <blockquote>
  <p>Determining projects to restore...<br />
  Restored C:\actions-runner\_work\MySolution\MySolution\src\FirstSdkProject\FirstSdkProject.csproj (in 335 ms).
  Restored C:\actions-runner\_work\MySolution\MySolution\src\SecondSdkProject\SecondSdkProject.csproj (
  in 357 ms).</p>
  </blockquote>
  <p>If I restore from the locally installed dotnet at C:\Users\MyUser\AppData\Local\Microsoft\dotnet then I get the unexpected output that I'm getting in the GitHub action</p>
  <blockquote>
  <p>Determining projects to restore...<br />
  Determining projects to restore...<br />
  C:\actions-runner\_work\MySolution\MySolution\src\FirstSdkProject\FirstSdkProject.csproj : error MSB4057: The target &quot;Restore&quot; does not exist in the project.<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Determining projects to restore...<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Determining projects to restore...<br />
  C:\actions-runner\_work\MySolution\MySolution\src\SecondSdkProject\SecondSdkProject.csproj : error MSB4057: The target &quot;Restore&quot; does not exist in the project.<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Determining projects to restore...<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Nothing to do. None of the projects specified contain packages to restore.<br />
  Nothing to do. None of the projects specified contain packages to restore.</p>
  </blockquote>
  <p>Comparing the information on dotnet.exe, they are the exact same version of dotnet and using a file compare program they are binary the same, and the folders they are in are seemingly the same as well with only a few minor differences. Why would running <code>restore</code> have two very different outcomes just running from different locations?</p>