Skip to content

Building and debugging old builds

Igor Velikorossov edited this page Nov 2, 2021 · 1 revision

In event (e.g., during a bisect) you need to build and debug an old build (circa .NET 5.0 Preview1 or earlier) then it is possible that .\restore.cmd or .\build.cmd will fail with cryptic errors, e.g.:

C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(130,5): error : Invalid restore input. Invalid target framework 'unsupported'.
Input files: C:\Users\<user>\.nuget\packages\microsoft.dotnet.arcade.sdk\5.0.0-beta.19570.6\tools\Tools.proj.
[C:\Users\<user>\.nuget\packages\microsoft.dotnet.arcade.sdk\5.0.0-beta.19570.6\tools\Tools.proj]
    0 Warning(s)
    1 Error(s)

To solve the issue apply the following patch:

diff --git a/global.json b/global.json
index f526f53bb..d5f568c3b 100644
--- a/global.json
+++ b/global.json
@@ -1,10 +1,6 @@
 {
   "tools": {
     "dotnet": "5.0.100-alpha1-015536",
-    "vs": {
-      "version": "16.0"
-    },
-    "xcopy-msbuild": "16.0.0-rc1-alpha",
     "runtimes": {
       "dotnet": [
         "$(MicrosoftNETCoreAppPackageVersion)"

. . .

You also may encounter random errors like this:

C:\Users\<user>\.nuget\packages\microsoft.dotnet.genfacades\5.0.0-beta.19570.6\build\Microsoft.DotNet.GenPartialFacadeSource.targets(30,5): error MSB4062: The "GenPartialFacadeSource" task could not be loaded from the assembly C:\Users\<user>\.nuget\packages\microsoft.dotnet.genfacades\5.0.0-beta.19570.6\build\../tools/netcoreapp2.1/Microsoft.DotNet.GenFacades.dll.
Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
[D:\Development\dotnet-winforms.5x\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.Facade.csproj]
    0 Warning(s)
    1 Error(s)

To solve this, remove the offending package and run .\restore.cmd or .\build.cmd again.

. . .

It is likely that VS will refuse to build these old solutions, complaining about inability to resolve dependencies. And you will need to build and run test projects from the command line. To run your debugging sessions in VS you can use Debugger.Launch(); statement.