0

I've been developing using the .NET Framework since probably 2007 and I'm curious about .NET Core. I just tried to create a new .NET Core project to see what it's all about. When I tried to add a reference to a common .NET library I couldn't find ANY of the typical .NET libraries. Normally I would just add a reference and I would get the long list of all libraries that where part of .NET. No System.Data, no System.Net.Http(the namespace of HttpClient), no System.Xml, etc. Literally not even a list at all.

I'm new to .NET Core so I'm obviously missing something. What's going on? Are all the standard .NET libraries I've used for the past 10 years now just gone in .NET Core?

EDIT:

enter image description here

enter image description here

James
  • 419
  • 4
  • 25
  • how did you create your .net core project? i just checked and found all these projects you are talking about in my .net core project – Neville Nazerane Sep 19 '17 at 03:27
  • 1
    If you are so new, then why not learn it? Clearly Microsoft has a large site for documentation, with posts such as https://learn.microsoft.com/en-us/dotnet/core/packages. Most classes would come from NuGet packages. – Lex Li Sep 19 '17 at 03:28
  • @LexLi, I'm trying to learn it but I'm still really confused at this point. It seems like sure a MASSIVE change from typical .NET. Everything has to come from NuGet? Even the most basic .NET classes that have been around for over a decade? – James Sep 19 '17 at 03:34
  • yes .net core is mean't to be a clean project on start up. however there is a single nuget that contains all the nugets. Also this way you don't need to wait for a .net version update to get updates on each library. – Neville Nazerane Sep 19 '17 at 03:36
  • @NevilleNazerane I just opened Visual Studio 2017, clicked "Create new project", selected .NET Core under the types of projects and selected "Console App (.NET Core)". After the project is created I don't even have the normal "References" only "Dependencies". When I right click I get "Projects", "Shared Projects" and "Browse". None have the standard .NET namespaces. – James Sep 19 '17 at 03:40
  • "Dependencies" is the new "References" combined with Nugets, SDKs, bower etc. You can still right click on it and add References. They would appear under "Projects" under "Dependencies". – Neville Nazerane Sep 19 '17 at 03:43
  • @NevilleNazerane, I added some screen shots. – James Sep 19 '17 at 03:50
  • yes check nuget packages instead of references. even if it were under references, even when i used classic asp.net I used to prefer nugets over references for including libraries. nugets integrate with more functionalities as compared to references – Neville Nazerane Sep 19 '17 at 03:54
  • @NevilleNazerane So the most common .NET libraries are not longer installed by default? So does that mean when distributing an application built using .NET Core you now have to include all the dependent assemblies too instead of them already being on the target machine as a result of .NET being installed? – James Sep 19 '17 at 03:59
  • they will be installed by default if you start something like a .net core web project. The biggest advantage of nugets is that you DON'T have to manually include anything for distributing. Installing the nuget adds a line of code into your project file. When you distribute, all those who use it will automatically have all projects restored. – Neville Nazerane Sep 19 '17 at 04:02
  • @NevilleNazerane How does that work? Lets say I have a console app like MyApp.exe. I give that to someone. That's it. Just the one file. With the .NET I'm used to as long as the target machine has the correct .NET version installed and I'm not using any 3rd party libraries the EXE will just run. Is that not the case with .NET Core? – James Sep 19 '17 at 04:09
  • well i haven't seen console apps making EXEs. Since it is cross platform I don't think it will create. When you publish the app it generates dlls. You can run the dll from command line using `dotnet myapp.dll parms` – Neville Nazerane Sep 19 '17 at 04:12
  • All very new to me. I'm used to console applications creating EXEs so an end user could easily use the application. – James Sep 19 '17 at 04:15
  • you can always have create a batch file which has the command line. That's what i do. The huge advantage in it is, when I have multiple websites, i have a batch file to run all of them at a time. – Neville Nazerane Sep 19 '17 at 04:22

1 Answers1

0

It seems like you don't have the Microsoft.AspNetCore.All nuget package installed. In the latest version this installs all the nugets. Most .NET Core projects have this added by default. Another great thing about .NET Core is it can work in CLI.

You can even try the following in command prompt after CDing to a folder of your choice:

dotnet new console -o myapp
cd myapp
dotnet add package Microsoft.AspNetCore.All

Now you can try out changes in program.cs add your libraries and use the command dotnet run.

Neville Nazerane
  • 6,622
  • 3
  • 46
  • 79
  • What if I'm not using Asp.net? I was just trying to create a console application. There isn't even a choice for Win Forms. – James Sep 19 '17 at 03:43
  • the above code is for a .net core console application. It would create the same application you created in vs. Only maybe a little faster and you don't need vs open. If you already have the project open just run `Install-Package Microsoft.AspNetCore.All ` on your package manager console – Neville Nazerane Sep 19 '17 at 03:46
  • 1
    And there are no win forms yet. The biggest idea behind .net core is cross platform. There are only web and console apps yet. forms app would need cross platform native guis. Which is a lot of work and even if they do it will take really long to release it – Neville Nazerane Sep 19 '17 at 03:48
  • Yeah, that certainly makes sense for forms. – James Sep 19 '17 at 03:49
  • you can still have cross platform .net core web and console apps and have shared codes with win forms with the help of .net standard libraries – Neville Nazerane Sep 19 '17 at 03:51
  • I just used the "dotnet new console -o myapp" command and it only created the csproj and Program.cs. What about Solution file, AssemblyInfo.cs, etc? This is a HUGE change from what I'm used to. – James Sep 19 '17 at 04:01
  • 1
    yes one of the ideas of .net core is to make the whole project light. There is no solution file because this only creates the project. If you want to run it in vs you will need to import it your solution – Neville Nazerane Sep 19 '17 at 04:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/154738/discussion-between-neville-nazerane-and-james). – Neville Nazerane Sep 19 '17 at 04:12
  • i just found this https://stackoverflow.com/questions/39155571/how-to-run-net-core-console-app-from-the-command-line according to this, you CAN create exe files with core and also creates an executable for linux – Neville Nazerane Sep 19 '17 at 06:24