Closed dazinator closed 8 years ago
The top-level dependencies
property should not be empty. Place the bits you have under the .NET 4.5.2 framework there:
"dependencies": {
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Http.Extensions": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.Razor": "1.0.0-rc2-final",
"Newtonsoft.Json": "4.0.1"
}
Thanks @dougbu - I moved the 4.5.2
dependencies to top level, but as I also target framework net40
I quickly realised I can't do that as it reports those top level dependencies cannot be resolved for net40
which is correct.
So I moved the .net40
dependencies to top level instead, and i'm working through that at the moment, as some of those dependencies are not compatible with netStandard.
Why must there be top level dependencies and is this being fixed - because surely it's legitimate that you may not have any dependencies that are common to all the frameworks you choose target?
I now have a top level dependency in my project.json and am able to successfully do a dotnet restore
but I still have the same issue. Here is my revised project.json
{
"version": "2.17.4",
"frameworks": {
"net452": {
"dependencies": {
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Http.Extensions": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.Razor": "1.0.0-rc2-final",
"Newtonsoft.Json": "4.0.1"
}
},
"net40": {
"dependencies": {
"Common.Logging": "3.0.0",
"Microsoft.Owin": "2.1.0",
"WebActivatorEx": "2.0.0",
"Newtonsoft.Json": "4.0.1"
},
"frameworkAssemblies": {
"System.Web": "4.0.0.0",
"System.Xml": "4.0.0.0"
}
},
"netstandard1.5": {
"imports": [
"netcore50",
"dnxcore50",
"portable-net45+win8"
],
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027"
}
}
},
"dependencies": {
"Microsoft.Bcl.Async": "1.0.168"
},
"buildOptions": {
"preserveCompilationContext": true,
"copyToOutput": {
"include": [ ]
}
},
"publishOptions": {
"include": [ ]
},
"tools": { }
}
And error:
It is indeed legitimate to leave the top-level dependencies
property out or set it to an empty object. However you were attempting to use MVC packages in frameworks where MVC dependencies weren't referenced.
Remove your net40
framework to use MVC packages. Those packages require .NET Core (netstandard1.5
) or .NET 4.5.1 or later.
However you were attempting to use MVC packages in frameworks where MVC dependencies weren't referenced.
Doh! This led me to the answer. Removing net40
isn't an option for me as I need to support that at present. So I just needed to add the MVC packages to the netstandard
framework also! ;)
Silly me!
Thanks for you help pointing me to the answer.
Final project.json:
{
"version": "2.17.4",
"frameworks": {
"net452": {
"dependencies": {
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Http.Extensions": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.Razor": "1.0.0-rc2-final",
"Newtonsoft.Json": "4.0.1"
}
},
"net40": {
"dependencies": {
"Common.Logging": "3.0.0",
"Microsoft.Owin": "2.1.0",
"WebActivatorEx": "2.0.0",
"Newtonsoft.Json": "4.0.1"
},
"frameworkAssemblies": {
"System.Web": "4.0.0.0",
"System.Xml": "4.0.0.0"
}
},
"netstandard1.5": {
"imports": [
"netcore50",
"dnxcore50",
"portable-net45+win8"
],
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Http.Extensions": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.Razor": "1.0.0-rc2-final",
}
}
},
"dependencies": {
"Microsoft.Bcl.Async": "1.0.168"
},
"buildOptions": {
"preserveCompilationContext": true,
"copyToOutput": {
"include": [ ]
}
},
"publishOptions": {
"include": [ ]
},
"tools": { }
}
I am having difficulty getting a custom
TagHelper
to compile (upgrading from dnxcore50) because it can't resolve the TagHelper library when targetingnetstandard1.5
- here is the message:SideNote: "you can use the navigation bar to switch context" - can someone explain to me where that nav bar is as that would be handy!
This is odd because the NuGet packages I am referencing both say they support netstandard1.5 on the NuGet page:
Here is my project.json file:
And here is the full code for the class file:
Would really appreciate any guidance here.