Repository: godot
Issue: 2 SDK style C# projects referencing Godot.NET.Sdk/3.3.0 in same solution sporadically fail to build
Labels: bug,topic:dotnet

**Godot version:**
Godot Engine v3.3.2.stable.mono.official  
But seems to happen with 3.3 and 3.2.3 as well, I haven't checked older versions.


**OS/device including version:**
Windows 10 Version 20H2
Microsoft Visual Studio Community 2019 Version 16.10.0 (also happened with version 16.9.4)


**Issue description:**
When you have 2 SDK style C# projects (both having `<Project Sdk="Godot.NET.Sdk/3.3.0">` in the csproj) in the same solution and one has a Nuget package installed, they will sporadically fail to build.  
When looking at the logs it seems like MSBuild tries to restore packages from the project that doesn't have any, instead of the one that does. Which causes builds to fail because of an missing assembly reference.  
Changing the build tool in Godot from `MSBuild (VS Build Tools)` to `dotnet CLI` doesn't seem to help

A log of a failed build:
```
Running: "C:\Program Files\dotnet\dotnet.EXE" msbuild "D:/Workspaces/build/Build.sln" /restore /t:Build "/p:Configuration=Debug" /v:normal "/l:GodotTools.BuildLogger.GodotBuildLogger,C:\Users\gunth\AppData\Roaming\hourglass\versions\3.3.2-mono\GodotSharp\Tools\GodotTools.BuildLogger.dll;C:\Users\gunth\AppData\Roaming/Godot/mono/build_logs\4c45137cac5518dc9679aa4e9866cce0_Debug" /p:GodotTargetPlatform=windows
Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 06/06/2021 15:37:41.
     1>Project "D:\Workspaces\build\Build.sln" on node 1 (Restore target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Debug|Any CPU".
       _GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         Committing restore...
         Assets file has not changed. Skipping assets file writing. Path: D:\Workspaces\build\.mono\temp\obj\project.assets.json
         Restored D:\Workspaces\build\ClassLibrary1\ClassLibrary1.csproj (in 36 ms).
         
         NuGet Config files used:
             C:\Users\gunth\AppData\Roaming\NuGet\NuGet.Config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
         
         Feeds used:
             https://api.nuget.org/v3/index.json
             C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
         All projects are up-to-date for restore.
     1>Done Building Project "D:\Workspaces\build\Build.sln" (Restore target(s)).
   1:2>Project "D:\Workspaces\build\Build.sln" on node 1 (Build target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Debug|Any CPU".
   1:2>Project "D:\Workspaces\build\Build.sln" (1:2) is building "D:\Workspaces\build\ClassLibrary1\ClassLibrary1.csproj" (3:6) on node 2 (default targets).
     3>GenerateTargetFrameworkMonikerAttribute:
       Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
       CoreGenerateAssemblyInfo:
       Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
       CoreCompile:
       Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
       CopyFilesToOutputDirectory:
         ClassLibrary1 -> D:\Workspaces\build\.mono\temp\bin\Debug\ClassLibrary1.dll
     3>Done Building Project "D:\Workspaces\build\ClassLibrary1\ClassLibrary1.csproj" (default targets).
   1:2>Project "D:\Workspaces\build\Build.sln" (1:2) is building "D:\Workspaces\build\Build.csproj" (2:6) on node 1 (default targets).
     2>GenerateTargetFrameworkMonikerAttribute:
       Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
       CoreGenerateAssemblyInfo:
       Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
       CoreCompile:
         C:\Program Files\dotnet\dotnet.EXE exec "C:\Program Files\dotnet\sdk\5.0.300\Roslyn\bincore\csc.dll" /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:GODOT;GODOT_WINDOWS;GODOT_PC;TRACE;TOOLS;DEBUG;NETFRAMEWORK;NET472;NET20_OR_GREATER;NET30_OR_GREATER;NET35_OR_GREATER;NET40_OR_GREATER;NET45_OR_GREATER;NET451_OR_GREATER;NET452_OR_GREATER;NET46_OR_GREATER;NET461_OR_GREATER;NET462_OR_GREATER;NET47_OR_GREATER;NET471_OR_GREATER;NET472_OR_GREATER /highentropyva+ /reference:D:\Workspaces\build\.mono\assemblies\Debug\GodotSharp.dll /reference:D:\Workspaces\build\.mono\assemblies\Debug\GodotSharpEditor.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\netstandard.dll" /debug+ /debug:portable /filealign:512 /optimize- /out:D:\Workspaces\build\.mono\temp\obj\Debug\Build.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output /deterministic+ /langversion:7.3 Class1.cs "D:\Workspaces\build\.mono\temp\obj\Debug\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" D:\Workspaces\build\.mono\temp\obj\Debug\Build.AssemblyInfo.cs /warnaserror+:NU1605
     2>D:\Workspaces\build\Class1.cs(2,19): error CS0234: The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [D:\Workspaces\build\Build.csproj]
         CompilerServer: server - server processed compilation - a4f6afd3-3376-41a3-90b2-aca12d5d1e24
     2>Done Building Project "D:\Workspaces\build\Build.csproj" (default targets) -- FAILED.
     1>Done Building Project "D:\Workspaces\build\Build.sln" (Build target(s)) -- FAILED.

Build FAILED.

       "D:\Workspaces\build\Build.sln" (Build target) (1:2) ->
       "D:\Workspaces\build\Build.csproj" (default target) (2:6) ->
       (CoreCompile target) -> 
         D:\Workspaces\build\Class1.cs(2,19): error CS0234: The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [D:\Workspaces\build\Build.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.83
```

In the logs above you see `Restored D:\Workspaces\build\ClassLibrary1\ClassLibrary1.csproj` which is the project without the Nuget package.  
While in a successful build it restores the correct project:

```
Running: "C:\Program Files\dotnet\dotnet.EXE" msbuild "D:/Workspaces/build/Build.sln" /restore /t:Build "/p:Configuration=Debug" /v:normal "/l:GodotTools.BuildLogger.GodotBuildLogger,C:\Users\gunth\AppData\Roaming\hourglass\versions\3.3.2-mono\GodotSharp\Tools\GodotTools.BuildLogger.dll;C:\Users\gunth\AppData\Roaming/Godot/mono/build_logs\4c45137cac5518dc9679aa4e9866cce0_Debug" /p:GodotTargetPlatform=windows
Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 06/06/2021 15:40:46.
     1>Project "D:\Workspaces\build\Build.sln" on node 1 (Restore target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Debug|Any CPU".
       _GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         Restoring packages for D:\Workspaces\build\Build.csproj...
         Committing restore...
         Writing assets file to disk. Path: D:\Workspaces\build\.mono\temp\obj\project.assets.json
         Restored D:\Workspaces\build\Build.csproj (in 192 ms).
         
         NuGet Config files used:
             C:\Users\gunth\AppData\Roaming\NuGet\NuGet.Config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
         
         Feeds used:
             https://api.nuget.org/v3/index.json
             C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
     1>Done Building Project "D:\Workspaces\build\Build.sln" (Restore target(s)).
   1:2>Project "D:\Workspaces\build\Build.sln" on node 1 (Build target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Debug|Any CPU".
   1:2>Project "D:\Workspaces\build\Build.sln" (1:2) is building "D:\Workspaces\build\ClassLibrary1\ClassLibrary1.csproj" (2:6) on node 2 (default targets).
     2>GenerateTargetFrameworkMonikerAttribute:
       Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
       CoreGenerateAssemblyInfo:
       Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
       CoreCompile:
         C:\Program Files\dotnet\dotnet.EXE exec "C:\Program Files\dotnet\sdk\5.0.300\Roslyn\bincore\csc.dll" /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:GODOT;GODOT_WINDOWS;GODOT_PC;TRACE;TOOLS;DEBUG;NETFRAMEWORK;NET472;NET20_OR_GREATER;NET30_OR_GREATER;NET35_OR_GREATER;NET40_OR_GREATER;NET45_OR_GREATER;NET451_OR_GREATER;NET452_OR_GREATER;NET46_OR_GREATER;NET461_OR_GREATER;NET462_OR_GREATER;NET47_OR_GREATER;NET471_OR_GREATER;NET472_OR_GREATER /highentropyva+ /reference:D:\Workspaces\build\.mono\assemblies\Debug\GodotSharp.dll /reference:D:\Workspaces\build\.mono\assemblies\Debug\GodotSharpEditor.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /reference:C:\Users\gunth\.nuget\packages\stub.system.data.sqlite.core.netframework\1.0.114\lib\net46\System.Data.SQLite.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\netstandard.dll" /debug+ /debug:portable /filealign:512 /optimize- /out:D:\Workspaces\build\.mono\temp\obj\Debug\ClassLibrary1.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output /deterministic+ /langversion:7.3 D:\Workspaces\build\.mono\temp\obj\Debug\ClassLibrary1.AssemblyInfo.cs /warnaserror+:NU1605
         CompilerServer: server - server processed compilation - 326a9fa6-54ca-4866-bc97-165759c1e1f9
       _CopyFilesMarkedCopyLocal:
         Creating "D:\Workspaces\build\.mono\temp\obj\Debug\ClassLibrary1.csproj.CopyComplete" because "AlwaysCreate" was specified.
       CopyFilesToOutputDirectory:
         Copying file from "D:\Workspaces\build\.mono\temp\obj\Debug\ClassLibrary1.dll" to "D:\Workspaces\build\.mono\temp\bin\Debug\ClassLibrary1.dll".
   1:2>Project "D:\Workspaces\build\Build.sln" (1:2) is building "D:\Workspaces\build\Build.csproj" (3:6) on node 1 (default targets).
     3>GenerateTargetFrameworkMonikerAttribute:
       Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
       CoreGenerateAssemblyInfo:
       Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
     2>CopyFilesToOutputDirectory:
         ClassLibrary1 -> D:\Workspaces\build\.mono\temp\bin\Debug\ClassLibrary1.dll
         Copying file from "D:\Workspaces\build\.mono\temp\obj\Debug\ClassLibrary1.pdb" to "D:\Workspaces\build\.mono\temp\bin\Debug\ClassLibrary1.pdb".
     2>Done Building Project "D:\Workspaces\build\ClassLibrary1\ClassLibrary1.csproj" (default targets).
     3>CoreCompile:
         C:\Program Files\dotnet\dotnet.EXE exec "C:\Program Files\dotnet\sdk\5.0.300\Roslyn\bincore\csc.dll" /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:GODOT;GODOT_WINDOWS;GODOT_PC;TRACE;TOOLS;DEBUG;NETFRAMEWORK;NET472;NET20_OR_GREATER;NET30_OR_GREATER;NET35_OR_GREATER;NET40_OR_GREATER;NET45_OR_GREATER;NET451_OR_GREATER;NET452_OR_GREATER;NET46_OR_GREATER;NET461_OR_GREATER;NET462_OR_GREATER;NET47_OR_GREATER;NET471_OR_GREATER;NET472_OR_GREATER /highentropyva+ /reference:D:\Workspaces\build\.mono\assemblies\Debug\GodotSharp.dll /reference:D:\Workspaces\build\.mono\assemblies\Debug\GodotSharpEditor.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /reference:C:\Users\gunth\.nuget\packages\stub.system.data.sqlite.core.netframework\1.0.114\lib\net46\System.Data.SQLite.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\netstandard.dll" /debug+ /debug:portable /filealign:512 /optimize- /out:D:\Workspaces\build\.mono\temp\obj\Debug\Build.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output /deterministic+ /langversion:7.3 Class1.cs "D:\Workspaces\build\.mono\temp\obj\Debug\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" D:\Workspaces\build\.mono\temp\obj\Debug\Build.AssemblyInfo.cs /warnaserror+:NU1605
         CompilerServer: server - server processed compilation - 80a39096-2416-4269-bbbf-0592c6fd936d
       _CopyFilesMarkedCopyLocal:
         Touching "D:\Workspaces\build\.mono\temp\obj\Debug\Build.csproj.CopyComplete".
       CopyFilesToOutputDirectory:
         Copying file from "D:\Workspaces\build\.mono\temp\obj\Debug\Build.dll" to "D:\Workspaces\build\.mono\temp\bin\Debug\Build.dll".
         Build -> D:\Workspaces\build\.mono\temp\bin\Debug\Build.dll
         Copying file from "D:\Workspaces\build\.mono\temp\obj\Debug\Build.pdb" to "D:\Workspaces\build\.mono\temp\bin\Debug\Build.pdb".
       CopySQLiteInteropFiles:
       Skipping target "CopySQLiteInteropFiles" because it has no outputs.
     3>Done Building Project "D:\Workspaces\build\Build.csproj" (default targets).
     1>Done Building Project "D:\Workspaces\build\Build.sln" (Build target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.26
```
Changing the SDK from `Godot.NET.Sdk/3.3.0` to `Microsoft.Net.Sdk` fixes the problem but i won't be able to reference Godot related classes in one of the projects.

**Steps to reproduce:**


**Minimal reproduction project:**
<!-- A small Godot project which reproduces the issue. Drag and drop a zip archive to upload it. -->
[build.zip](https://github.com/godotengine/godot/files/6604293/build.zip)