VS2015 ASP.NET 5 beta7 dependency could not be resolved - asp.net-core

This is a follow-up to this question. I started with an Empty ASP.NET project in VS2015 community, tried to add a couple packages based on a tutorial, and haven't gotten it to actually work yet. The initial problem in the linked question was due to some project dependencies using beta5 and some using beta7. Matching those up solved that, but now I get this error when I try to run the project in IIS Express:
Could not load file or assembly 'Microsoft.Dnx.Host.Clr' or one of its dependencies.
I think the problem is still version related--like the previous web.config assembly reference issues--but I don't know how to deal with it yet. I tried modifying global.json based on a similar issue I found on GitHub, but now it doesn't build. It looks like it can't find the newer version of the CLR I guess. From the Error List in VS2015:
The dependency Microsoft.AspNet.Mvc >= 6.0.0-beta7 could not be resolved.
The dependency Microsoft.AspNet.Server.IIS >= 1.0.0-beta7 could not be resolved.
The dependency Microsoft.AspNet.Server.WebListener >= 1.0.0-beta7 could not be resolved.
global.json:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta7",
"runtime": "clr",
"architecture": "x86"
}
}
My project's References tree has yellow error indicators but looking in the NuGet package manager for my project doesn't show any upgrades (or anything installed at all, as far as I can tell).
dnvm list:
1.0.0-beta5 clr x64
1.0.0-beta5 clr x86
1.0.0-beta5 coreclr x64
1.0.0-beta5 coreclr x86
* 1.0.0-beta7 clr x86 default
1.0.0-beta8-15585 clr x86
dnu list:
Microsoft .NET Development Utility CLR-x86-1.0.0-beta7-15532
I've restart VS but that didn't help. Changing back to beta5 in my global.json makes it compule successfully but then I get the IIS error.
project.json:
{
"webroot": "public",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"public",
"node_modules",
"bower_components"
]
}
package.json:
{
"version": "1.0.0",
"name": "ASP.NET",
"private": true,
"devDependencies": {
"angular2": "2.0.0-alpha.36",
"gulp": "3.9.0"
}
}

"To use ASP.NET 5 beta7 with Visual Studio 2015, you will need to download and install the beta7 version (14.0.60831.0) of ASP.NET and Web Tools 2015."
http://go.microsoft.com/fwlink/?LinkId=623894
https://github.com/aspnet/Home/releases

Related

Need Help Building ASP.NET Core Source Because of Missing .Net Version

I can't seem to find the version of asp.net core that is wanted to build what is at the current asp.net core site. I'm currently getting the error that vs is looking for v 1.0.0-preview2-1-003180 but I can't find that anywhere to install. I'ved looked here:
https://github.com/dotnet/core/blob/master/release-notes/download-archive.md
What is the recommended way to download the source from
https://github.com/aspnet/Mvc
and build it. (I'm on the dev branch).
Update:
There are 13 projects in the solution. There is a global.json in solution and a project.json in each project.
Here is the global.json:
{
"projects": [
"src",
"test/WebSites",
"samples"
],
"sdk": {
"version": "1.0.0-preview2-1-003180"
}
}
Try updating "frameworks" property of project.json to something like:
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"imports": "dnxcore50"
}
},
This should target .NET Core 1.1 rather than the specific SDK version you are receiving an error on.
Hopefully that helps!

AspNetCore namespace doesnt exist

I'm following this course to learn ASP.NET Core.
I did exactly as they did, I can type dotnet new and dotnet restore.
I also installed the dotnetcore 1.0.1 SDK preview.
All seems fine, and I should be able to type
using Microsoft.AspNetCore.Http;
But the only things recognized after Microsoft are cSharp, visualbasic and win32?
Here is my project.json file:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.AspNet.WebApi": "5.2.3",
"Microsoft." **<< i cannt type AspNetCore here**
},
"imports": "dnxcore50"
}
}
There is no Microsoft."AspNetCore". The only things I do have starting with Asp are:
AspNet.Identity.Owin
AspNet.Mvc
AspNet.Providers.Core
AspNet.Razor
AspNet.SignalR
AspNet.Web.Optimization
AspNet.WebApi
AspNet.WebApi.Clients
AspNet.WebApi.Core
AspNet.WebApi.Cors
AspNet.WebPages
The code completion doesn't always work when editing the project.json file, especially if you're using a lighter editor like VS Code. (Sometimes it doesn't work even in full-blown Visual Studio).
If this happens, don't worry! You can still install any packages you need. Find packages by searching on NuGet and then edit the dependencies section like this:
"PackageName": "1.0.0" # Version from package details on NuGet
Then, use the dotnet restore command within the project directory to pull down all the packages in project.json.

ASPNET Core pre-RC2 dependency ambiguity

I am using:
.NET Command Line Tools (1.0.0-rc2-002439)
Product Information:
Version: 1.0.0-rc2-002439
Commit Sha: ef0c3b2cee
Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
and getting:
error CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)' and 'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)'
I suspect there are multiple OptionsModel assemblies (different versions) included on "dotnet restore".
The proof may be here:
The second suggestion with different parameter name:
Project.lock.json file has few interesting lines ("Infrastructure" is a referenced assembly):
"Infrastructure/1.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.6.1",
"dependencies": {
"Domain": "1.0.0",
"Microsoft.Extensions.Caching.Abstractions": "1.0.0",
"Microsoft.Extensions.OptionsModel": "1.0.0",
"Newtonsoft.Json": "8.0.3",
"WindowsAzure.Storage": "6.2.1"
},
"compile": {
"net461/Infrastructure.dll": {}
},
"runtime": {
"net461/Infrastructure.dll": {}
}
}
while the web application uses Microsoft.Extensions.OptionsModel/1.0.0-rc2-15914
Here is the configuration section of Infrastructure assembly:
"dependencies": {
"Domain": "1.0.0-*",
"Microsoft.Extensions.Caching.Abstractions": "1.0.0-*",
"Microsoft.Extensions.OptionsModel": "1.0.0-*",
"Newtonsoft.Json": "8.0.3",
"WindowsAzure.Storage": "6.2.1-*"
}
The question is: why different versions (1.0.0 and 1.0.0-rc2-15914) are chosen while executing "dotnet restore"?
UPDATE: I tried changing project.json of Infrastructure project to "Microsoft.Extensions.OptionsModel": "1.0.0-rc2-15914" but I am still can't compile because of ambiguity displayed in screenshots. Are any assemblies cached somewhere on my computer?
The solution is:
Microsoft.Extensions.Options instead of Microsoft.Extensions.OptionsModel package had to be used in a referenced project.

dotnet cli - "detected package downgrade"

I have finally managed to get a project's dependencies downloaded with dotnet restore, after going through the process of clearing all nuget cache, dnx cache, and updating the cli using the beta channel.
But using the project.json below, I get an error;
warn : Detected package downgrade: Microsoft.Dnx.Compilation.CSharp.Abstractions from 1.0.0-rc2-16553 to 1.0.0-rc2-16552
I'm not sure what this means, or how to fix it. The things still download, but this concerns me.
I am using the following;
dotnet/cli
.NET Command Line Tools (1.0.0-beta-001540)
Product Information:
Version: 1.0.0-beta-001540
Commit Sha: 6aeed1f52d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
Runtime Id: win10-x64
dnvm list
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-rc1-update1 clr x64 win
1.0.0-rc1-update1 clr x86 win
1.0.0-rc1-update1 coreclr x64 win
1.0.0-rc1-update1 coreclr x86 win
1.0.0-rc2-16551 clr x86 win
* 1.0.0-rc2-16551 coreclr x64 win default
1.0.0-rc2-16551 coreclr x86 win
nuget.config
<packageSources>
<add key="aspnet-core" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
project.json
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-*",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
"Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
"Microsoft.AspNetCore.Mvc.TagHelpers": "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.Console": "1.0.0-*",
"Microsoft.AspNetCore.Identity": "1.0.0-*",
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*"
}
},
"net451": { },
"dnxcore50": {
"imports": "portable-net451+win7+win8",
"dependencies": {
"NETStandard.Library": "1.0.0-*"
}
}
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
One of the libraries explicitly require 1.0.0-rc2-16552 version, that's why you get the warning. Once the library u[grade to supports higher version warnings will disappear.
This is an old post so not sure which library is doing this at the time of your post, but for people with same warning, go through your libraries and look which one has version dependency.
Basically, remove the library or stay on downgraded version until the library updates and supports the new version.

Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1'

I'm using ASP.NET 5.0 and I wanted to run just on the new Core CLR, so I removed "dnx451": { } from dependencies in my project.json file. I now get the following error when I launch in IIS:
Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1':
Microsoft.AspNet.Mvc 6.0.0-beta4
Microsoft.AspNet.Server.IIS 1.0.0-beta4
Microsoft.AspNet.Server.WebListener 1.0.0-beta4
Microsoft.AspNet.StaticFiles 1.0.0-beta4
My understanding was that AspNet.Mvc 6 would run on Core CLR? Why then do I have to include dnx451 as a dependency?
My project.json file:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
},
"frameworks": {
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
Specifying dnxcore50 as a dependency in project.json is not the same as telling the Solution to target that dnx. To fix this I had to modify the solution global.json file to use a specific version of the dnx (i.e. a specific .Net executable). I also had to change a few using statements to use new Core CLR libraries instead of .Net 4.5 libraries. You will get intellisense and error warnings about these.
The global.json file can be found under the Solution node. I had to add the sdk version part:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta4"
}
}
Note that you can also edit this in a GUI:
Strongly recommend the recently uploaded ASP.NET Introduction and ASP.NET Deep Dive videos from Build 2015 available on Channel 9.
I had this error when publishing my DNX web app. It turned out it was because I had upgraded from Beta5 to Beta6 but neglected to update my publish powershell script which looks like:
$thisFolder = (Get-Item -Path ".\" -Verbose).FullName
$webFolder = "$thisFolder\..\src\Web.UI"
dnu publish $webFolder `
--out \\uatserver\uatshare `
--configuration DEBUG `
--no-source `
--runtime dnx-clr-win-x64.1.0.0-beta5
So in the last parameter my publish was still telling it to target beta5 instead of beta6.