How do I add a reference to a mono assembly in asp.net vNext - mono

So I've installed Asp.net vNext onto my Linux box and have been playing around with it. I have everything set up and can build and run mvc applications. I'm building a console application and need to reference an assembly that doesn't exist in NuGet. I want to add a reference to Mono.Data.SqliteClient to my project.json. I know the path to the assembly /usr/local/lib/mono/4.5/Mono.Data.Sqlite.dll.
How do I add the reference to the dll? My project.json file currently looks like this:
{
"dependencies": {
"System.Console": "4.0.0.0",
"Dapper":"1.27",
"Mono.Data.Sqlite":""
},
"configurations": {
"net45": {},
"k10": {}
}
}

I found the answer on a forum...
In a nutshell, you can only reference your dlls if they are inside a nuget package... ( I hope this will be improved. It is a hassle IMO. )
The long story :
Ok, after a lot of fannying about, it seems that the way to do this is to create a nuget package using the DLL (i'll use Quartz version 2.2.4.400 as an example).
use http://docs.nuget.org/docs/creating-packages/using-a-gui-to-build-packages to build it. Drag and drop Quartz.dll into the right hand side (nb. it does need to be placed in the lib directory). File -> save as... save it in the following location:
projectRoot\packages\Quartz.2.2.4.400\Quartz.2.2.4.400.nupkg
With the dll in the following:
projectRoot\packages\Quartz.2.2.4.400\lib\Quartz.dll
nb. placing the DLL outside of the lib directory will compile alright, but won't work with intellisense. If you are compiling with a specific version, then i'd put it in a net45, net451 or k10 folder; as i'm not, I didn't bother. my project.json then looks like:
{
"dependencies": {
"Quartz" : "2.2.4.400"
},
"configurations" : {
"k10" : {
"dependencies": {
"System.Console": "4.0.0.0"
}
}
}
}

Related

Nunit.framework dll from the package doesnt get copied to bin folder

I'm currently running .net framework 4.6 and added the NUnit, NUnit3TestAdapter nuget package to the test project that i am working on and I see that the test's are not being discovered.
Upon some investigtion, I see that nunit.framework.dll is not being copied to the bin folder. Did some more research and I see the following in the assets.json file, and Nunit's build/NUnit.props file which is supposed to have the MSBuild settings is empty and does not have any.
"NUnit/3.13.3": {
"type": "package",
"compile": {
"lib/net45/nunit.framework.dll": {}
},
"runtime": {
"lib/net45/nunit.framework.dll": {}
},
"build": {
"build/NUnit.props": {}
}
},
However Nbuild/Unit3TestAdapter.props file which is installed from the official Nunit has the MSBuild settings. Is there a reason why build/NUnit.props does not have the build setting where as build/Unit3TestAdapter.props has these?
Also, Is there a work-around to get these copied to local or should I add the reference's manually than getting these from the package?

System.InvalidOperationException : Migration failed

My solution have 3 projects :
Web (i added the connection string in the appsetting file)
Business (contains models class)
Infrastructure (contains DbContext)
I tried to make a migration :
dnx ef migration add firstMigration -s Web
I had this error :
System.InvalidOperationException: The current runtime target framework is not compatible with 'Infrastructure'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
Version: 1.0.0-rc1-16202
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 10.0
Runtime Id: win10-x86
Please make sure the runtime matches a framework specified in project.json
When i put dnvm list, i have 1.0.0-rc1-final like a default runtime and i don't find 1.0.0*rc1-16202 in the list ?
The projet.json file of Infrastuture project is :
"frameworks": {
"dotnet5.4": {
},
"net451": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"frameworkAssemblies": { "System.Runtime": "4.0.10.0" }
}
}
I had the same problem and I solved it by changing "net451" to "dnx451" in the project.json file under the "frameworks" object.
It's ok now, it was my mistake : i executed the command (dnx ef migrations add) in Infrasturtucre folder instead of web folder.

How do you make an ASP.Net 5 Application be able to consume class libraries?

Step 1: Open VS 2015 RC and create a new "ASP.Net Web Application"
Step 2: Right-click the solution, add a new windows "Class Library" (a normal one, not the "Class Library (Package)"
Step 3: Put a method in Class1.cs in the class library. Doesn't matter what.
Step 4: Right-click "References" in the Web Project and add a reference to your class library.
Step 5: From a code file in the web project, call the method you made in Class1.cs
So for me, Class1.cs looks like this:
public class Class1
{
public void X()
{
}
}
And I added code in the web application like this:
var x = new ClassLibrary1.Class1();
x.X();
Step 6: Try to compile, you will get this error:
Error CS0246 The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)
What magic must be done to make normal class libraries (of which I have a lot) work with ASP.Net 5 apps?
When downloading your project and building, I got the following error in the output:
C:\REDACTED\AspNet5Test\src\AspNet5Test\Startup.cs(26,25,26,38): DNX Core 5.0 error CS0246: The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)
Note, especially the DNX Core 5.0 portion - .Net 4.5 libraries (such as your ClassLibrary1) are not compatible with .Net Core.
The easiest solution is to remove the dependency on dnxcore50 from your project.json file.
Current:
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibrary1": "1.0.0-*"
}
},
"dnxcore50": { }
},
Change to:
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibrary1": "1.0.0-*"
}
}
},

How to add a non-Amber library with bower? (for example processing js)

I have started a project with amber init and then bower install processing --save to get processing.js added.
I do the initialisation with
firstProcessingInstance
<return Processing.instances[0]>
This method is called by the instance method initializeand it worked a pre-Amber v0.13 version.
How do I initialize Processing.js in Amber 0.13 and 0.14?
The code of the example is here
Addition after answer by Herby
In version 0.13 and 0.14 a configuration file processing.amd.json has to be added manually to the root directory. Files libraryname.amd.json in the root directory of the project are needed if the library does not have a local.amd.json file in the library directory.
Examples for libraryname.amd.json files from Amber Smalltalk and Helios are
project amber; file jquery.amd.json
{
"paths": {
"jquery": ["dist/jquery", "jquery"]
}
}
project amber; file es5-shim.amd.json
{
"paths": {
"amber_lib/es5-shim": "."
}
}
project helios; file showdown.amd.json
{
"paths": {
"helios/showdown": "src/showdown"
}
}
project: https://github.com/hhzl/Amber-snapsvg-demo
file: snap.svg.amd.json
{
"paths": {
"snap.svg" : "dist/snap.svg"
}
}
References
Amber may be a project and a library
Lego bricks illustration
Question
What is wrong with this processing.amd.json library mapping file?
{
"paths": {
"processing" : "processing"
}
}
Note After a change in processing.amd.json run grunt devel
Adding external non-Amber library to the project involves more steps than just bower install. You must create libdir.amd.json in root of the project with mapping the library file to the symbolic name. Then, you should add the symbolic name into either deploy.js or devel.js (depending on the context in which it is used), outside the place intended for amber packages (that is, not between the two delimiter comments).
EDIT: There is nothing wrong with the cited processing.amd.json, it's right and correct. With this, "processing" module name is mapped to .../processing/processing (.js is omitted from AMD mapping by design). After all, see your config.js to check the mapping is correct. If you have problems loading processing.js, it is outside this domain (.amd.json and Amber's mappings).

ASP.NET vNext Project Reference

Does anybody know how to add project reference in ASP.NET vNext?
project.json
{
"dependencies": {
"myProject": ""
},
"configurations" : {
"net45" : { },
"k10" : { }
}
}
It doesn't work :(
I've found the solution.
You can use only ASP.NET vNext projects (I tried to use "Class library", but it works only with "ASP.NET vNext Classs Library"
You should use global.json to declare your folders.
when you save the project.json file,the References node in Solution Explorer shows the class library project and identifies it as a project in the properties window (other references such as Helios show up as NuGet package references).
if can not,you can try restart the vs