I would like to create a nuget package to import a library of MVC-ish stuff into an MVC project. For example:
- models
- enums
- attributes
But I am confused as to how I should be including their namespaces.
After creating a new Class Library, I try to use the namespace System.ComponentModels.DataAnnotations
, but it is not recognised.
I have tried using the References
section in Solution Explorer. But there appears to be no option there - only the message:
No recent framework assemblies were found on your machine or in your project.json
.
Ok, so I go to the project.json
file.
But I am unsure how I should be adding these references here.
{
"version": "1.0.0-*",
"description": "ClassLibrary1 Class Library",
"authors": [ "MHL" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"System.Collections": "4.0.0.0",
"System.Linq": "4.0.0.0",
"System.Threading": "4.0.0.0",
"System.Runtime": "4.0.0.0",
"Microsoft.CSharp": "4.0.0.0",
"System.ComponentModel.DataAnotations": "4.0.0.0"
},
"frameworks": {
"dotnet": { }
}
}
If I add "System.ComponentModel.DataAnotations": "4.0.0.0"
to the dependencies
section, I get the build error Dependency could not be resolved
.
So I think I should be changing something in the frameworks
section.
But I am unsure what to add, not least because there are so many options (e.g. "dotnet", "net40", "net50", "dnx", etc)!
My understanding is that the frameworks
section enables a single nuget package to target different framework versions. But really, all I want is a general purpose MVC package. I don't want to unnecessarily limit the package to a specific version of the framework.