I've created a asp.net 5 project and am trying to add a reference to an older package from NuGet (Mysql.Data). From what I've read, I should be able to do this to add pre-vnext packages:
{
"version": "1.0.0-*",
"dependencies": {
},
"commands": {
"run": "run"
},
"frameworks": {
"net45": {
"dependencies": {
"MySql.Data": "6.9.4"
}
},
"aspnet50": { },
"aspnetcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-22416"
}
}
}
}
But all that happens is I get a reference to it in the project browser but there is a yellow triangle next to it. I have seen other similar questions on here but they all suggest the above, but I'm not sure why this doesn't work?
That means that the MySQL library is not supported in aspnetcore5, you can remove the aspnetcore50 JSON node and that will get rid of the warning. Not all libraries are supported in core. See this Question
In addition to what Son_of_Sam said, you need to put this in the dependencies section at the top.
Related
Hi how can I change Target Framework Version in ASP.NET Core app in Visual Studio 2015 ?
I would like to target only "NETStandard.Library": "1.6.1".
My project.json frameworks section looks like:
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
}
}
}
and my xproj file target .NET 4.5.2
TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
It might be helpful for you to offer a little more color on what it is you're trying to do, but with what you've given here, some thoughts.
First, NETStandard.Library 1.6.1 is a library/package that is installed via NuGet, not a target framework you can run on. The closest framework you can target is "netstandard1.6", which would imply you're building a class library and not a console or other stand-alone application. To run that combination, your project.json should look like this (minimally):
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.1"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}
Based on what you've shown in your snippet though, it looks more like your intention was to create a console application, in which case, getting NETStandard.Library 1.6.1 would be done like this (framework section only):
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.1"
},
"NETStandard.Library": "1.6.1"
}
}
}
Update for VS2017 is that you can edit your .csproj file and manually change <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> to <TargetFrameworkVersion>netstandard1.6</TargetFrameworkVersion>.
More information about specifying different target frameworks and switching between them can be found here.
In a dnxCore project you can run the commands in you project.json file using "dnx command-name" How do you do that for a net461 project? If you try and run it with dnx it says the framework version in wrong. It Seems super simple but I can't figure it out or see any documentation about it.
Thanks,
Dan
You can create a dotnet console application and use it as a dotnet command. You need to set the outputName in project.json. You find more details in this link - https://learn.microsoft.com/en-us/dotnet/articles/core/tools/extensibility
Here is the sample project.json
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"outputName": "dotnet-helloworld"
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
}
}
And here is the code
using System;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
You can execute dotnet pack and create nuget package, create a nuget.config file, mention the location of nuget package in the nuget.config and can be used in the tools section also directly from command line.
Here is two links which might help you.
http://dotnetthoughts.net/building-a-custom-dotnet-cli-tool/
http://dotnetthoughts.net/using-nuget-packages-in-aspnet-core/
I have a project that compiles that I want to test using xUnit. However although the project lets me add the references and builds, as soon as I add a using statement to the test class I get the red squiggly lines and the error "type or namespace could not be found."
Even though the xproj of the project I want to test has been added to references, and the namespaces do exist. It has to be something I have done, but I can't see what. Using earlier versions of .net, I have added references to test projects hundreds of times without an issue.
So what is different in the way .NET works, and why does it not recognize my namespaces in my referenced assemblies?
Update: I have removed xUnit and got MSTest working, but I have the same issue. So this may be a feature of the way I have dotnetcore set up, and the references in my json files more than anything else.
This structure works for me in .NET Core 1.0:
global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
src/MyLibrary/project.json
{
"dependencies": { },
"frameworks": {
"netstandard1.3": {
"dependencies": {
"NETStandard.Library": "1.6.0"
}
}
},
"version": "1.0.0"
}
test/MyLibrary.Test/project.json
{
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"MyLibrary": {
"target": "project",
"version": "1.0.0"
},
"xunit": "2.1.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
},
"testRunner": "xunit",
"version": "1.0.0"
}
Using this directory and project structure, both the Visual Studio Test Explorer and dotnet test work and can run xUnit tests.
The documentation for using project.json for ASP.NET 5 applications includes a sample project.json file (abbreviated version below).
What is the difference between frameworkAssemblies and dependencies?
And why does dnx451 use one and dnxcore50 use the other?
{
"version": "0.1-alpha-*",
...
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
...
}
},
"dnxcore50": {
"dependencies": {
...
}
}
}
frameworkAssemblies refers to assemblies present in GAC (global assembly cache).
Consider the following example:
I want to use ADO.NET apis(SqlConnection, SqlCommand) to work with a SQL Server database. I know that these apis are part of System.Data.dll and so want to reference it. Now when the full version of .NET Framework is installed, it installs some assemblies in the GAC (which has this System.Data.dll too) and hence you see a reference to frameworkassemblies in the below example. Coming to CoreClr, I need to find out in which package these types exist. For this you could use the website called PackageSearch(built by an ASP.NET team member) where you can search for a type and find the package name. Based on this you will find System.Data.SqlClient to be the package. Since this package is built for CoreClr, it is part of dependencies section within the dnxcore50 section.
{
"version": "1.0.0-*",
"description": "Test App",
"dependencies": {
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0"
}
},
"dnxcore50": {
"dependencies": {
"System.Data.SqlClient": "4.0.0-beta-*"
}
}
}
}
Now let's say you want to even add support for json serialization and deserialization in your app and want to reference Json.Net nuget package. Json.Net nuget package supports both the desktop and core clr and hence you would put it in the dependencies section common to both frameworks.
{
"version": "1.0.0-*",
"description": "Test App",
"dependencies": {
"Newtonsoft.Json": "6.0.6"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0"
}
},
"dnxcore50": {
"dependencies": {
"System.Data.SqlClient": "4.0.0-beta-*"
}
}
}
}
Has anybody ever used Symfony in conjunction with payone(payone.de)?
I got the SDK and it has the folders js, locale and php.
My problem: I don't really know how to include/use them in my project(inexperienced in Symfony) because I don't know where I should place it and how to include it. I read about the auto loader but since the SDK doesn't follow the standards needed(concerning folder structure) I guess it's not the way to go.
You can autoload all classes with the psr-0 too if the classes are following the PEAR-style non-namespaced convention.
To manage the vendor download via composer, you can define a package in your composer.json directly.
{
"repositories": [
{
"type": "package",
"package": {
"name": "payone/php-sdk",
"version": "1.0.0",
"dist": {
"url": "http://github.com/PAYONE/PHP-SDK/archive/master.zip",
"type": "zip"
},
"autoload": {
"psr-0": { "Payone_": "php/" }
}
}
}
],
"require": {
"payone/php-sdk": "1.0.*"
}
}
Note: This repository type has a few limitations and should be avoided whenever possible:
Composer will not update the package unless you change the version field.