Multiple assemblies with equivalent identity - System.Runtime.dll - asp.net-core-mvc

I have a MVC6 project with beta-8, when I add the System.Security.Claims nuget package, I’ll get the following compile error:
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Users\username.dnx\packages\System.Runtime\4.0.20\ref\dotnet\System.Runtime.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\System.Runtime.dll'. Remove one of the duplicate references.
Any guidance on fixing this issue will be greatly appreciated!
I was able to replicate from just a simple new project, Beta8Class is just a common class library in the solution, here is the project.json:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Beta8Class": "1.0.0-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"Microsoft.Framework.Logging": "1.0.0-beta8",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
"Microsoft.Framework.Logging.Debug": "1.0.0-beta8",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta8",
"System.Security.Claims": "4.0.1-beta-23409"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
Thanks

You get conflicting reference because this is a beta version and mixing two different version will lead to reference conflicts. You should use all beta8 versions.
If you want something with security you can use these packages
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta8",

System.Security.Clamis package version 4.0.1-beta-23409 supports only dnxcore5. Try removing dnx451 target framework.
You may confirm this on NuGet gallery:
https://www.nuget.org/packages/System.Security.Claims/4.0.1-beta-23409
another clue is that your error message says that it searches dotnet folder. I am not yet fully sure how those generator works but this a moniker for core target framework only.

Related

dotnet new generates a .csproj file instead of project.json

I am following this documentation https://www.microsoft.com/net/core#macos on how to run .NET Core on mac. I have successfully installed the dotnet command and all but when I try to create a new project using dotnet new, it generates a .csproj file as opposed to project.json as described. This doesn't allow me to go on to run dotnet restore or dotnet run to run this new project. I don't know what I'm missing out here. Kindly assist.
I found a way around this. I created a project.json file and put the necessary parameters in it. In this case,
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
},
"imports": "dnxcore50"
}
}
}
Then dotnet restore works there on.
Cheers!

Upgrading Asp.Net Web API from RC1

We are in process of building a new WebApi. We started out with using .Net Core Rc1 before summer holidays - and now, with .Net Core being 1.0 I would like to update.
But I run into some issues - which I can't figure out if I can solve?
The challenge is that I need to reference some .Net 4.5.1 x86 assemblies.
This means I need to use a moniker that allows use of .Net 4.5.1 - and if I need both worlds, as I understand it - only netstandard16 is available. (https://learn.microsoft.com/da-dk/dotnet/articles/standard/library)
But then I run into the issue that .Net 4.6.3 (or vNext in the above link) is not available yet.
If I reference netstandard15 - then AspNetCore libraries won't work.
If I reference netstandard16 - then I get the following errors
error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win10-x64, win81-x64, win8-x64, win7-x64'. Possible causes:
error : 1. The project has not been restored or restore failed - run `dotnet restore`
error : 2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.
error : 3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.
Is it at all possible with current available bits to do the following
Have a business layer in .Net 4.5 compiled for x86 (need to reuse this - legacy is great)
Create a Asp.Net Core site
Reference the business Layer in site - and just carry on coding
Is anyone able to help me out here?
EDIT: The project.json (in two versions)
From RC1
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"AutoMapper": "4.2.1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final",
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"BaseClasses": "1.0.0-*",
"DatabaseAccessCS": "1.0.0-*",
"BusinessLogic": "1.0.0-*",
"StandardFunctionsCS": "1.0.0-*"
},
"frameworkAssemblies": {
"System.configuration": "4.0.0.0"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
The attempt on final 1.0 that came closest to working
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {
"AutoMapper": "5.1.1",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Swashbuckle.SwaggerGen": "6.0.0-beta902",
"Swashbuckle.SwaggerUi": "6.0.0-beta902"
},
"frameworks": {
"netstandard16": {
"dependencies": {
"BaseClasses": {
"target": "project"
},
"DatabaseAccessCS": {
"target": "project"
},
"BusinessLogic": {
"target": "project"
},
"StandardFunctionsCS": {
"target": "project"
}
}
}
}
}
Final json that works
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"platform": "x86"
},
"runtimes": {
"win": ["win7-x86", "win8-x86", "win10-x86"]
},
"dependencies": {
"AutoMapper": "5.1.1",
"LogiholdBusinessObjects": "5.5.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Swashbuckle.SwaggerGen": "6.0.0-beta902",
"Swashbuckle.SwaggerUi": "6.0.0-beta902"
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Configuration": "4.0.0.0"
}
}
}
}
If you want a .NET Core appliction, you should use the netcoreapp1.0 target framework. You probably won't be able to reference the .NET 4.5.1 library in the .NET Core app.
You could also target a desktop (full) .NET Framework like this:
"frameworks": {
"net451": { }
}
Now you can use .NET 4.5.1 library but your application won't run on the .NET Core runtime anymore.
You could also target a higher version of .NET, just like `net461 for example.

Some packages are not compatible with .NETPlatform,Version=v5.4

I have an ASP.NET Core application that compiles and runs locally. When I try to restore the nuget packages on Visual Studio Team Services (hosted agent) the following errors occurs:
Ix-Async 1.2.5 is not compatible with .NETPlatform,Version=v5.4.
Remotion.Linq 2.0.1 is not compatible with .NETPlatform,Version=v5.4.
System.Collections.Immutable 1.1.36 is not compatible with
.NETPlatform,Version=v5.4.
Some packages are not compatible with .NETPlatform,Version=v5.4.
Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0.
Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0.
Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01 is not compatible
with DNXCore,Version=v5.0.
Microsoft.CodeAnalysis.Common 1.1.0-rc1-20151109-01 is not compatible
with DNXCore,Version=v5.0.
Some packages are not compatible with DNXCore,Version=v5.0.
System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
at
Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeToolCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
The VSTS task that is failing is configured like this:
global.json file is as follows:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update1"
}
}
And the project.json file from the web project:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"AutoMapper": "4.2.1",
"Cubic.Site.Data": "1.0.0-*",
"Cubic.Site.Data.Storage": "1.0.0-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.Abstractions": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Newtonsoft.Json": "8.0.3",
"StyleCop.Error.MSBuild": "1.0.0",
"StyleCop.MSBuild": "4.7.54"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
The solution contains the web app and 2 other class libraries. Site.Data project.son file:
{
"version": "1.0.0-*",
"description": "Site.Data Class Library",
"authors": [ "foo" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": { },
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
And the other class library project.json file content is:
{
"version": "1.0.0-*",
"description": "Site.Data.Storage Class Library",
"authors": [ "foo" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": ""
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"dependencies": {
"Cubic.Site.Data": "1.0.0-*",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.InMemory": "7.0.0-rc1-final"
}
}
Any idea on what's going on? The strange thing is that the first time this error occurred there were absolutely no changes to config files, project files or the solution - only ASP.NET MVC views were modified. Since that moment I wasn't able to restore the nuget packages on VSTS.
I was wondering if something was installed on the hosted agent that is causing this error?
EDIT 2016-06-21
This issue is now fixed, these errors no longer occur!!! I suspect that there were some changes on the hosted agent that would fix this issue, maybe someone from the VSTS can confirm that??
Since you didn't see this issue anymore, it should be caused by the nuget version in Hosted Build Agent. Refer to this link for details: Issues with Hosted Build in Visual Studio Team Services – 6/20 – Resolved.
Final Update: Tuesday, 21 June 2016 16:07 UTC
Our hotfix deployment to restore nuget 3.3 on the Build Agents has
completed by 21 June 2016 ~03:00 UTC. Customers should no longer see
any issues with running Hosted Builds due to nuget package restore.
We understand that customers rely on VS Team Services as a critical
service and apologize for any impact this incident caused.
Sincerely, Manohar
Update: Monday, 20 June 2016 22:10 UTC
The update to nuget.exe from 3.3 to 3.4.3 has been identified as the
root cause of the active restore problems. We are working on a hotfix
to restore the previous nuget version on the build agents.
We will update this post as the hotfix progresses.
Sincerely, Sri Harsha
Initial Update: Monday, 20 June 2016 19:40 UTC We are actively
investigating issues with the build agents of Visual Studio Team
services related to nuget package restore. Some customers may
experience Build failures due to nuget packages being restored
incorrectly in the Build Agents.
Next Update: Before 22:00 UTC We are actively working to resolve this
issue and apologize for any inconvenience.
Sincerely, Manohar

Dependency issue with System.Net.Http and ASP.NET 5 on OS X

I am trying to create first sample application running with ASP.NET 5 on OS X. However I just can't figure out how project.json dependencies work.
I generated Web Api Application with yeoman and everything had worked fine until I've tried to use WebClient.
According to dnvm list I'm running:
* 1.0.0-rc1-update2 mono linux/osx
And while restore packages goes well the project fails at build step.
Here is my project.json file:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "LocationService"
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"System.Web.Http": "4.0.0"
}
},
"dnxcore50": {
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
And project fails on build with unresolved reference:
LocationService/Controllers/ValuesController.cs(32,40):
DNXCore,Version=v5.0 error CS0246: The type or namespace name
'WebClient' could not be found (are you missing a using directive or an
assembly reference?)
I've tried add dependency both under dnxcore50 and dnx451.
Dmvm tells me that I can use coreclr x64 but it seems just not works in my case - ends up with numerous unresolved references during build.
WebClient is not available (yet?) for dnxcore.
Try removing dnxcore50 framework or use HttpClient or HttpWebRequest instead of WebClient.

How to add reference to other project in ASP.NET 5 Preview?

In a Visual Studio 2015 solution I have a folder structure as follows:
-src
-Project.Models
(...)
-MyModel.cs
-Project.Web
(...)
-Controllers
-MyControllers.cs
-Dependencies
-project.json
Where Project.Web is a ASP.NET 5 Web API project and Project.Models a ASP.NET 5 Class Library.
Now I want to use MyModel of Project.Models in MyController of Project.Web. To do this I need to reference the Models project from the Web project. I cannot get this to work here. The using Project.Models statement keeps highlighting the Models part in red because the assembly reference cannot be found.
What I tried:
The usual "Add reference" in combination with using statement
Creating a NuGet package of Project.Models (by specifying "Compile on built" in properties), adding the NuGet package to a local repository and referencing it in project.json.
Both things do not seem to work also after restarting Visual Studio.
Can someone explain to me how to accomplish referencing the Project.Models from Project.Web?
/Edit Include project.json:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Loader.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Loader.IIS.Interop": "1.0.0-beta5",
"Microsoft.Framework.Runtime": "1.0.0-beta5",
"Microsoft.AspNet.Mvc.Xml": "6.0.0-beta5",
"MongoDB.Driver": "2.0.1"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
},
"frameworks": {
"dnx451": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
And global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta5",
"runtime": "coreclr",
"architecture": "x86"
}
}
The problem was that I was using .NET Core. When I changed my frameworks entry in the project.json file to use
"dnx451": { }
instead of
"dnxcore50": { }
the references were included again (the red of the image became black). Seems like .NET core does not (yet?) support all packages.

Resources