sdk icon indicating copy to clipboard operation
sdk copied to clipboard

dotnet restore fails if NETStandardLibrary is missing in the dependency list

Open schellap opened this issue 10 years ago • 9 comments

mkdir temp
cd temp
dotnet new
:: replace project.json contents with below json.
dotnet restore
{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

  "dependencies": {
    "System.Reflection": "4.0.0"
  },
  "frameworks": {
    "dnxcore50": {}
  }
}

@anurse @piotrpMSFT

  • If you add this line to the dependencies, then the error turns to a warning

"NETStandard.Library": "1.0.0-rc2-23704"

info : Running restore with 16 concurrent jobs.
info : Restoring packages for e:\clr\git\corert\temp\project.json...
info : All packages are compatible with DNXCore,Version=v5.0.
error: System.Reflection 4.0.0 provides a compile-time reference assembly for System.Reflection on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.IO 4.0.0 provides a compile-time reference assembly for System.IO on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Runtime 4.0.0 provides a compile-time reference assembly for System.Runtime on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Text.Encoding 4.0.0 provides a compile-time reference assembly for System.Text.Encoding on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Threading.Tasks 4.0.0 provides a compile-time reference assembly for System.Threading.Tasks on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64).
error: System.Reflection 4.0.0 provides a compile-time reference assembly for System.Reflection on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.IO 4.0.0 provides a compile-time reference assembly for System.IO on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Runtime 4.0.0 provides a compile-time reference assembly for System.Runtime on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Text.Encoding 4.0.0 provides a compile-time reference assembly for System.Text.Encoding on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Threading.Tasks 4.0.0 provides a compile-time reference assembly for System.Threading.Tasks on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: Some packages are not compatible with DNXCore,Version=v5.0 (win7-x86).
info : Committing restore...
info : Restore failed in 516ms.

schellap avatar Jan 20 '16 07:01 schellap

That's by design. You need to use either the Standard Library or Microsoft.NETCore.Platforms to bring in the correct runtime dependencies.

davidfowl avatar Jan 20 '16 07:01 davidfowl

@davidfowl, is there anyway this error can be turned into a warning and still be restored like what DNU did?

error: Microsoft.DiaSymReader 1.0.6 is not compatible with DNXCore,Version=v5.0.
error: Some packages are not compatible with DNXCore,Version=v5.0.
{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

  "dependencies": {
    "NETStandard.Library": "1.0.0-rc2-23704",
    "Microsoft.DiaSymReader": "1.0.6"
  },


    "frameworks": {
        "dnxcore50": { }
    }
}

schellap avatar Jan 20 '16 09:01 schellap

No. Why are you referencing packages that aren't compatible? What does Microsoft.DiaSymReader work on?

davidfowl avatar Jan 20 '16 10:01 davidfowl

You are right that it is not compatible and we should use one for dnxcore, but I am requesting a workaround. DiasymReader is for net45. DNU was silent about it.

schellap avatar Jan 20 '16 11:01 schellap

DNU may have been silent but would not have provided a reference to the compiler so it still wouldn't have worked. Your project doesn't even have net45 in it's list of supported frameworks. If you want your project to support net45 by cross-compiling and use DiaSymReader in that version, you need to do something like this:

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

  "dependencies": {
    "NETStandard.Library": "1.0.0-rc2-23704"
  },


    "frameworks": {
        "dnxcore50": { },
        "net45": {
            "dependencies": {
                "Microsoft.DiaSymReader": "1.0.6"
            }
        }
    }
}

analogrelay avatar Jan 20 '16 17:01 analogrelay

@schellap I took a look at the diasymreader package in my local cache and it looks like it uses the old portable style lib folder.

@anurse did DNX have some logic to make this compatible with dnxcore50?

I see the same issue in xunit packages (which were definitely used before) and am able to work around with this in the project.json. You may need net45 instead of net451 there.

 "frameworks": {
        "dnxcore50": { 
            "imports": "portable-net451+win8"
        }
    }

brthor avatar Jan 21 '16 03:01 brthor

@anurse did DNX have some logic to make this compatible with dnxcore50?

Yes, and the magic was hacky and is now dead. Now the magic must be put in project files :smile:

davidfowl avatar Jan 21 '16 07:01 davidfowl

@davidfowl @schellap should we close this? Seems like the solution is to be explicit about the StdLib and its version in the project.json.

thesmithee avatar Feb 23 '16 15:02 thesmithee

Closing...

schellap avatar Feb 23 '16 16:02 schellap