After adding “Microsoft.AspNetCore.Authentication.Facebook” dotnet refuses to restore. Even after removing the package, project.json will still not restore.
My project.json looks like this:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-rc2-final"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-rc2-20507",
"imports": [ "portable-net40+sl5+win8+wp8+wpa81" ]
},
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Restoring
Throws the following error message:
Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.
Edit
I added the package from the Visual Studio "Quick Fix" menu
There's no guarantee the dll is actually compatible with .NETCore, but you should at least be able to force a restore by adding portable-net45+win8+wp8+wpa81
to your imports section.
That dose not help.
The problem is most likely the tool "Microsoft.VisualStudio.Web.CodeGeneration.Tools". Add the imports to the section:
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"type": "build",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
Thanks @lcalabrese, I was having the same issue in RTM and your suggestion resolved it for me.
Glad this got figured out :)
@piotrpMSFT Having same issue when upgraded to .NET Core 1.1 and workaround above did not solve the issue.
@radenkozec can you open a new issue with installed version, etc. ?
@piotrpMSFT I manage to workaround this by adding
"portable-net45+win8"
Sorry for false report.
@radenkozec thanks for following up. We want to get to the bottom of all of these issues so they don't get in folks way in the future. Glad you're unblocked!
I am encountering the same issue with core 1.1. The fix identified by @radenkozec didn't work.
Fixed the problem by modifying project.json
`{
"userSecretsId": "aspnet-IdentityWebServer-236e4356-5023-43bb-b1b5-a99fdcc99833",
"dependencies": {
"IdentityServer4.AspNetIdentity": "1.0.0-rc5",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
},
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.1.0-preview4-final",
"type": "build",
"imports": [ "portable-net45+win8" ]
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.1.0-preview4-final",
"type": "build",
"imports": [ "portable-net45+win8" ]
}
},
"tools": {
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"*/.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
`
The imports
section is necessary for older-style NuGet packages. The string in the imports
section must match the directory name inside of the nuget package you are referencing. Open your NuGet packages folder [usually a .nuget folder in your user directory], find the package in question, and look inside for a directory name that follows the portable-
naming convention.
As called out earlier by @brthor, the failure here is due to the package not advertising itself as compatible with the framework you wish to use. You can try forcing the dependency using imports
but there is no guarantee it is actually compatible.
Just adding this here for others who come across this issue here. I managed to resolve the issue by adding "net451"
to the imports section of my netcoreapp1.1
framework dedendency of my package.json
file.
My particular package.json
file looked like this.
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.1.0-preview4-final",
"type": "build"
},
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-*"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.1.0-preview4-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"imports": [
"netcoreapp1.1",
"net451"
]
}
}
}
After upgrading to VS2017 and therefore downgrading to XML I had to add it to my .csproj
file like this:
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
</PropertyGroup>
@mikebridge please educate me what is this $(PackageTargetFallback) for/do? thanks!
@gitfortee It does the same thing as the old imports
approach did for these packages ...
... the failure here is due to the package not advertising itself as compatible with the framework you wish to use. You can try forcing the dependency using imports but there is no guarantee it is actually compatible.
https://github.com/NuGet/Home/wiki/PackageTargetFallback-(new-design-for-Imports)
@mikebridge sorry for not being clear with my question. $(PackageTargetFallback) - is this a kind of variable substitution? if so where should i set a value for 'PackageTargetFallback' ? thanks!. My question was about the syntax..
@gitfortee Additions to the csproj format for .NET Core
fyi there is a breaking change coming in 2.0 - this is changing to be AssetTargetFallback
(which .NET Core 2.0 apps have by default) and cannot be used together with PackageTargetFallback
@gitfortee The $()
syntax is used to substitute with the value of a property. In this case, the PackageTargetFallback
is extended by a part. (So if it was a
before it will be a;portable-…
)
I don't see an issue for their 2.0 update on that one. It's described in the OPS docs here: https://docs.microsoft.com/nuget/schema/msbuild-targets#packagetargetfallback ... but there is no issue on their repo to update that one: https://github.com/NuGet/docs.microsoft.com-nuget/issues?q=is%3Aissue+packagetargetfallback+is%3Aopen
btw I made a typo: AssetTargetFallback
(singular Asset
)
Most helpful comment
After upgrading to VS2017 and therefore downgrading to XML I had to add it to my
.csproj
file like this: