Purnima Naik
Purnima Naik

Reputation: 2683

Portable library in .net core

I am new to .net core and having doubt about portable libraries.

I have created .net core web application, and framework section of project.json looks as follows:

"frameworks": {
"netcoreapp1.0": {
"imports": [
"portable-net4+netcore45"
],
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
}
}
}
}

Now in above case, what is meaning of "portable-net4+netcore45"?

Does it mean, that I can run my .net core application on machine where only .net framework 4 is installed?

Will it work without .net core installation?

Upvotes: 2

Views: 550

Answers (1)

Tseng
Tseng

Reputation: 64307

No, the above will still require .NET Core to be installed, because you are using "type": "platform", which requires a platform to be installed and the package itself serves only as reference.

If you want to run w/o .NET Core framework/SDK being installed, you have to change it to

"dependencies": {
    "Microsoft.NETCore.App": "1.0.0"
},
"frameworks": {
    "netcoreapp1.0": {}
},
"runtimes": {
    "win10-x64": {},
    "osx.10.11-x64": {}
}

Please note that the "runtimes" section is added, this is required if you want to run w/o installing a .NET Core runtime and you need to add any target OS to this list, like Linux etc.

The "imports": ["portable-net4+netcore45"] section only tells NuGet that it should install portable libraries which match the two targets, even if they do not support netcoreapp1.0/netstandard1.6 yet.

Most libraries which target Win8/8.1/UWP should work, but there is no guarantee. Import just tells nuget "install it anyways".

Check out the MSDN Docs on how to target the different .NET Core App Types.

Upvotes: 3

Related Questions