AspNetCore namespace doesnt exist - asp.net-core

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.

Related

Reference local build of Microsoft.AspNetCore.Mvc in AspNetCore application

How can I reference a local build of Microsoft.AspNetCore.Mvc in my Asp.Net Core application? I'm trying to debug something in the framework. I've pulled down the source and have it compiled, but I can't get my application to see the location to pick-up the code.
My global.json file:
{
"projects": [
"src",
"test",
"c:/source/repos/mvc/src"
],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
Snippet of my package.json file. The version is the same version as the DLL that is built:
"dependencies": {
"Microsoft.AspNetCore.Mvc": {
"version": "1.2.0-preview1",
"type": "build"
},
If you want to be sure it will use the project reference instead of the nuget reference you can specify the dependency target:
"Microsoft.AspNetCore.Mvc": {
"version": "1.2.0-preview1",
"type": "build",
"target" : "project" //this will make sure it only looks for a project
},
Also make sure you run dotnet restore before you build the project.

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!

Adding Microsoft.EntityFrameworkCore.Tools to a ASP.NET Core project

I am creating a new ASP.NET Core project using dotnet 4.5.2 and am trying to add a reference to Microsoft.EntityFrameworkCore.Tools. In my project.json file I have these listed under dependencies:
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
Looking under References, they appear to be successfully loaded. I then added this under tools in project.json:
"Microsoft.EntityFrameworkCore.Tools": {
"imports": [ "portable-net451+win8" ],
"version": "1.0.0-preview2-final"
}
After I added that, when I build the solution I get this build error:
Could not find a part of the path 'C:\Users\(my user name)\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools'
I get the same error if I remove the imports line. What am I doing wrong here?
Just ran into the same issue.
I fixed the issue by installing the tools package again in the package manager console:
Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
Before reinstalling the package was actually missing in the .nuget\packages.tools folder, after reinstalling it was there.
I followed the https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html tutorial, but I think I installed the package in the wrong order or initially forgot to reference the EF.tools package in the "tools" section of the project json.
I had this same problem and just solved using the examples from the EF Core setup guide from Microsoft, checking their GitHub code as well, I found this to work for the project.json.
I had to remove the imports from the "frameworks" property, which means no Application Insights for now. Once I did this and built, the folder appeared in the tools folder. Sorry I'm not good at posting code here but here are the important parts, ... elipses used to trim the post of my other things:
"dependencies": {
...
"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
} ...},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
}...
I had the same issue and had to add the following to my project.json.
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0-preview1-final"
The only difference is that I'm working with the newly release .NET Core 1.1, ASP.NET 1.1 and Entity Framework 1.1.
I had the same issue and tried many things. I found out that Design and Tools need to be the same version but intellisense was not giving me options common to both packages. Then I found this article and tried its code.
https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet
Using the following code from that article solved the issue for me;
"dependencies": {
"Microsoft.EntityFrameworkCore.Design": {
"type": "build",
"version": "1.0.0-preview2-final"
}
"Microsoft.EntityFrameworkCore.Tools": {
"type": "build",
"version": "1.0.0-preview2-final"
},
},
...
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
My problem was I had Microsoft.EntityFrameWorkCore.Tools instead of Microsoft.EntityFramework.Tools, note the lowercase w.

ASP.NET Core (vNext) project can't find reference to 4.51

I have a asp.net 5 (vNext) project with a project.json that is named FMS.DOMAIN. One of the references is a dotNet 4.51 project named FMS.DAL.
This works on all machine except one. On one machine it can't find this dotNet 4.51 project. I think it is looking for it on a public nuget server.
When I do 'dnu restore' I see this:
C:_Workspaces\MyProject\MyProject\FMS.Domain\project.json
CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='FMS.DAL'
Unable to locate Dependency FMS.DAL >= 1.0.
This is the project.json from FMS.Domain.
{
"version": "1.0.0-*",
"description": "FMS.Domain Class Library",
"authors": [ "ctcrrmcidmc" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"dnx451": {
"dependencies": {
"FMS.DAL": "1.0.0-*"
}
}
},
"dependencies": {
"AutoMapper": "4.1.1",
"FMS.Common": "1.0.0-*"
}
}
How does it know when to search nugget and when to use a local project? The reference to "FMS.Common": "1.0.0-*" is also a local project and it's working (but it's vNext).
We did get it to work if we had a reference to the DLL directly using the 'Add Reference' context menu. That produce an edit the project.json that look the same as the manual edit but it works. It must be doing something else.
More Info:
I blew away my workspace and got the code fresh from TFS. I am getting the problem on my machine. I see this error with 'dnu restore':
CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='FMS.DAL'
nable to locate Dependency FMS.DAL >= 1.0.0
It is looking for FMS.DAL at nuget.org instead of in my project. I removed the dependency from project.json and saved, then I add it back by right-clicking on references and picking a project reference. It's added back to project.json and looks exactly the same as before I removed it. I run 'dnu restore' again and it works.
The only pending change is in project.json and when I do a compare with TFS there are no differences. Then I did an undo pending changes for the entire solution and 'dnu restore' still works.

VS2015 ASP.NET 5 beta7 dependency could not be resolved

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