This will be the 3rd and last part of our series that volition help you to get up and running to do F# development with .Internet Core on Linux.

  • Part I: Installation
  • Part Ii: Development environment
  • Part 3: "Hello World" and debugging

We've made this far and all nosotros're missing are just the finishing touches.

As promised we'll exist looking at how we tin can link our build, run and debug workflow into vscode.

The editor expects the project's configuration to be located on a folder called .vscode  at the project's root folder, containing to 2 files called launch.json  and tasks.json . Nosotros'll be looking at how we can create and update them both manually and automatically.

Build

Let's start with an piece of cake one, the build chore.

Anywhere in the editor just run the default build command (ctrl+shift+b ) and vscode volition permit you lot know that it couldn't find a build chore for the project and information technology'll offer you to create one.

Nosotros're going to select 'Configure Build Task' and choose '.NET Core'

That's going to create a tasks.json file inside your .vscode folder (which it'll get created automatically if information technology didn't existed). If the .Internet Core choice doesn't evidence up for you, don't worry, manually create the tasks.json file and paste the post-obit.

{     // See https://become.microsoft.com/fwlink/?LinkId=733558     // for the documentation about the tasks.json format     "version": "0.ane.0",     "command": "dotnet",     "isShellCommand": true,     "args": [],     "tasks": [         {             "taskName": "build",             "args": [ ],             "isBuildCommand": truthful,             "showOutput": "silent",             "problemMatcher": "$msCompile"         }     ] }

Now we're ready to build our project! Run the build command once again (ctrl+shift+b ) and this fourth dimension you'll see the following output.

Microsoft (R) Build Engine version 15.1.1012.6693 Copyright (C) Microsoft Corporation. All rights reserved.   fsharp_tutorial -> /home/fsharp_tutorial/bin/Debug/netcoreapp1.i/fsharp_tutorial.dll Build succeeded.     0 Warning(s)     0 Fault(due south) Fourth dimension Elapsed 00:00:01.49

Run

Now that we've set up our build job, calculation one for running our project is trivial. Jump again into the tasks.json file and just add another job to the "tasks" assortment that looks like the following.

{   "taskName": "run",   "args": [     "run"   ],   "isBuildCommand": false,   "showOutput": "always",   "problemMatcher": "$msCompile" }

Save the file and fire upwardly vscode 'Quick Open' (ctrl+shift+p ), select 'Tasks: Run Task' and you'll see your newly created 'run' task. Once you lot've selected it, vscode 'output' console should bear witness something like

Hello Globe from F#!

Debug

This will be the concluding thing nosotros add and it is as like shooting fish in a barrel equally the other two with a small caveat.

Remember how I mentioned there were going to be two configuration files ? We'll make use of the other one now. It order to debug, we will not be creating a task but a launch configuration. Automatically creating the configuration file is as elementary equally pressing F5  and selecting.Internet Core  as our environs. By default this will create the launch.json file with three default configurations, of which we'll exist only focusing on ane for this article.

Right at present, you might exist tempted to re run debug (F5) because you lot created the configuration but you'll quickly be prompted with an error bulletin that reads something like

launch: launch.json must be configured. Change 'program' to the path to the executable file that you would like to debug

Don't worry, nosotros'll sort it out in seconds.

Once you lot open up your launch.json, yous'll realize that while vscode created the configuration information technology hasn't really specified which program it should debug and instead the path for the plan contains two placeholders merely because nosotros've already congenital our project we can see what values it is expecting, so go alee and replace <target-framework>  with netcoreapp1.1  and <project-name.dll>  with fsharp_tutorial.dll .

Your ".NET Core Launch (console)" should at present look similar this

{   "proper name": ".NET Cadre Launch (console)",   "type": "coreclr",   "request": "launch",   "preLaunchTask": "build",   "program": "${workspaceRoot}/bin/Debug/netcoreapp1.one/fsharp_tutorial.dll",   "args": [],   "cwd": "${workspaceRoot}",   "stopAtEntry": false,   "externalConsole": false }

All that is missing at present is giving it a try, so just place a interruption signal and hit debug (F5)

And we're done! Nosotros've covered the basic setup to get your F# on linux journey started.

You can find the finished projection here

This volition be the 2d function of a series of three articles that volition help you to get upward and running to practice F# development with .Net Core on Linux.

  • Part I: Installation
  • Part II: Development environment
  • Part III: "Howdy Earth" and debugging

Ok, for this detail entry nosotros'll be talking about tools that'll improve our evolution experience.

State of the art

Unfortunately, 1 of the downsides of non developing on Windows is not having access to the excellent Visual Studio IDE but fright non, we'll exist roofing a setup that should brand usa feel at home. Today'due south mail service will focus on Visual Studio Lawmaking (vscode), a fantastic open source code editor developed by Microsoft. Sometime in the future nosotros'll be covering culling tools, such every bit the promising Jetbrains Rider IDE and VIM/Emacs.

Now head onto vscode's download page and install the package corresponding to your favorite distro (both deb and rpm besides as 32 and 64 $.25 packages are provided).

If you've been following our previous entry, you should have a folder fsharp_tutorial , go ahead and open up information technology.

Extensions

The vscode extensions ecosystem is huge and worth spending some time looking at what information technology has to offer. For the scope of this serial, we'll but be covering one: ionide-fsharp . This extension comes to the states thank you to the people at ionide and on top of the i that we'll be looking at, they provide two more excellent F# extensions that you should cheque out.

Go alee and install information technology, you'll be prompted to reload the current window to enable it. If you search for it again, you should see something like this

While the out of the box settings should exist enough to get you lot started if you wanted to change something you lot can find the extension settings under 'FSharp configuration' or by searching 'fsharp' in the settings page.

Taking it for a ride

We'll go over a few things now, and so open upward our Program.fs  file.

Beginning thing we want to do is to add together our add together function that we used to test F# interactive on our previous post. Assuming things are working equally intended, the commencement matter you should observe is the automatic office type signature displaying on top of our office.

The second affair now will be to test the integration with F# interactive. We tin do this in several unlike way only for this post we'll apply the default 'send line to fsi' shortcut which is alt+/ .

Now your function is function of the interactive tool context and tin can be run.

You can observe the rest of the options past opening upward quick search (ctrl+shift+p ) and searching for fsi .

On the side by side and final entry for the serial, we'll finish setting vscode for building, running and debugging our program.

This will be the first part of a serial of three articles that will assistance you to get up and running to practice F# evolution with .Net Cadre on Linux.

  • Function I: Installation
  • Role 2: Development environment
  • Office Three: "Hullo Earth" and debugging

Installing .Net Cadre

The start thing we want to do is to install .NET core. Microsoft provides united states with very easy to follow instructions for your favorite distro here.

Once the installation is over you can chop-chop check that it went well by running the following control.

$ dotnet --version 1.0.iv

Installing F#

At this stage nosotros volition be able to create, run and build projects but we yet don't have admission to the language itself.

For that we volition follow the instructions from the F# Foundation located hither. One of the biggest benefits of doing and so is to have access to the F# interactive tool, which we'll use now to verify the installation went well by running the following control.

$ fsharpi F# Interactive for F# 4.0 (Open up Source Edition) Freely distributed under the Apache two.0 Open Source License For assistance type #help;; >

Taking information technology for a ride

F# Interactive

Allow's use it write a very unproblematic function to see it in action.

Remember that in the context of F# interactive you need to finish your instructions with;;

> let add together x y = 10 + y;; val add : x:int -> y:int -> int > add 1 2;; val it : int = three

Dotnet CLI

The first time yous burn down upwardsdotnet it will take a few seconds while it bootstraps and prepares its cache.

We'll create a new console app project which will exist the basis for the series.

This will presume yous're running this command within a folder calledfsharp_tutorial and that will be the name of our project as we won't be specifying one.

$ dotnet new console --linguistic communication F#

You should now have 2 new files calledfsharp_tutorial.fsproj andProgram.fs .

Similar with any other .NET core project type, we'll demand to restore its packages before can effort to do anything useful.

$ dotnet restore

Now we're ready for the moment of truth as we'll run our program for the first time.

$ dotnet run Hello Globe from F#!

If y'all run into the in a higher place it means that your installation went as intended and we're fix for our next step in this series which will be setting up our development environment.

Migrating a project.json .cyberspace cadre project to the latest csproj format can be a bit of a minefield. There are a few gotchas and even best practices that you probable did when using a project.json based projection that will actually make the migration to csproj neglect.

Merely kickoff, why should you not upgrade :

  • Your team is not gear up to employ Visual Studio 2017 (e.g. no licenses). csproj based projects can simply be opened in Visual Studio 2017, they cannot exist opened in Visual Studio 2015
  • Your team is using some other IDE such as Jetbrains Ryder that does not have back up (Or complete support notwithstanding) for csproj based projects.

If those aren't you, then information technology is really a no brainer to upgrade your project to the latest .net core tooling.

One of import affair to notation is that tooling is not the aforementioned as the .net core version. Tooling refers to things like projection.json vs csproj and how the .net cadre CLI works. It does not refer to the version of .net cadre (1.0 or ane.1). Updating the tooling does not modify the version of the actual .net core runtime!

Training

You should get ahead and download the latest .net core SDK. If this is your first fourth dimension doing this you should first read this article on how to run ii versions of the .net core SDK adjacent. This is really important if you intend to work on both project.json and csproj projects on the aforementioned automobile for some fourth dimension every bit you could end up not being able to open up projects without the right global.json setup.

On the project you wish to migrate, check the root of your project/solution for a global.json file. This file is used to determine which SDK to use merely annoyingly can crusade havoc when you are trying to migrate. The reason being when y'all wish to migrate, you desire to exist able to run the migrate command using the latest tooling, merely the global.json may point to an older version. If you try to migrate with this going on you will see the following fault bulletin :

D:\src\MigrateExample>dotnet migrate --help No executable found matching command "dotnet-migrate"

Take a fill-in of the global.json and delete it from the root folder.

Using the Command Line

The command we are going to run from the command line is "dotnet migrate". If we move our control line to the solution directory and run it, it will recursively motion downward into our projects and drift them all to the csproj format.

D:\src\MigrateExample>dotnet migrate Project MigrateExample.Web migration succeeded (D:\src\MigrateExample\MigrateExample.Web). Summary Total Projects: one Succeeded Projects: ane Failed Projects: 0

Information technology really is as simple as that!

Recall to create a global.json file in the root of our directory specifying what tooling version we are now on. This is actually an un-needed step realistically, just if yous upgrade your tooling once again on your machine you will want this project to exist unaffected. Information technology's also handy when setting up a new developers machine to be able to remember which version of the SDK you really need!

Rolling Back

There is no CLI command to "migrate downwardly" a .net cadre project, but you lot tin rollback manually. Inside each project directory you will detect a backup binder with your original project.json file. You tin pull this out and supersede the csproj files with your projection.json files over again. Call back that after moving dorsum to project.json, you volition need to create/update your global.json file with the right SDK versioning so information technology is able to exist opened by Visual Studio 2015 again.

C# every bit a language has always been well respected, but convincing developers who traditionally develop on Macs and Linux machines to swap to a windows box was e'er a tough sell. While there has been Mono, developing on a not windows automobile was pretty much always a non starter. With .net core, not only are yous able to run your apps cross platform, only the tooling has improved to the point where you tin can really develop on a non windows motorcar pretty painlessly.

I such choice is to use VS Lawmaking to develop in. VS Code is a mix of "editor" like simplicity (and so something like Sublime), only besides with the power of Visual Studio. If y'all are in love with Visual Studio, so information technology may seem a bit more "restrictive" (certainly VS Code doesn't carry the bloat of Studio), but it makes upward for information technology in speed and ease of use. What's also bully is that if y'all take a mix of developers who like developing on Windows, Mac and Linux, yous can have a consistent IDE beyond the team.

Getting Started

Get-go upward go alee and install VS Lawmaking

And so you lot will still demand to install the .net Core SDK. The tooling is cross platform, but brand sure you lot download the correct SDK for your motorcar. It's possible (Especially on Windows), that you may need a restart of your machine afterward installing the SDK.

Become alee and open up VS Code now. On the left hand bill of fare hitting the icon labelled extensions or y'all tin can press Ctrl + Shift + Ten. This should open up up the extensions card where you can install additional plugins to VS Code. Call up, VS Lawmaking on it's own is extremely lite and is basically a notepad editor. To be able to utilise intellisense and debugging, we need to install a couple of extras.

On the extensions carte, get ahead and install the C# addon. After hitting the install button y'all need to also click "reload" which reboots the editor.

Creating A .Net Core Project

VS Code itself doesn't deal with project templating. If you are used to Visual Studio where you lot tin can create new projects within the IDE, this may be a chip painful to get used to. Instead you need to create your projects from the command line. Go ahead and create a folder on your machine where you desire to take your work live (In the examples below, I created a folder called "VSCodeExample", use this if you lot want to follow forth at home). Open a command prompt/bash/terminal, and move to this directory.

First we need to create a "solution" which is essentially going to be our container for holding all our projects. A "solution" file is a bit like a .project file if you are coming from Eclipse. It'southward a one terminate shop for opening an entire "solution" and knowing all the projects that are part of it. In truth, when using VS Code you lot actually don't need a solution file at all, you instead are opening the "binder". But there are ii principal reasons for still creating it.

  • If you lot have other developers that are using Visual Studio, then this makes their lives a hell of a lot easier (Infact, you lot will need a solution file to go far work at all).
  • Build commands can point to a solution now instead of a projection which means that you can build a "set" of projects just by pointing your build at the solution file.

We are going to create a solution file and that's that!

In your command prompt type :

dotnet new sln

This creates a new solution file ready to be used. It should also be noted the .sln file is also named the same as it's parent folder.

Become ahead now and create some other folder inside your existing workspace, and call it the name of your desired "projection". In this case, I'k going to go ahead and call mine "VSCodeExample.Web". Your "solution" directory should now look like this :

OK, now have your command prompt and movement into your project folder (VSCodeExample.Web), and type :

dotnet new mvc

This creates a new MVC project that is pretty similar (If not identical), to what Visual Studio would create for you. It basically lays down all the boilerplate code so you can spring right in and commencement working.

It should be noted that typing "dotnet new -all" will listing off all templates that are bachelor to you. In our case we went with an MVC template, but you can exercise things like Web API templates, Console apps and course libraries.

OK, now remember what I said nigh being a great neighbour with the solution file? Move your command prompt up a level to your solution directory and type the following :

dotnet sln add "VSCodeExample.Web/VSCodeExample.Web.csproj"

What this does is add your projection into the solution file so that when someone comes along and opens it in Visual Studio, they are right up to speed. Once again, it's not required for working in VS Lawmaking merely is still a nice addiction to get into.

Finally, we need to go alee and restore some packages that our projects need. In your command prompt from inside the solution binder, run the following :

dotnet restore

This restores nuget packages that are missing from your project. If you aren't certain what the hell nuget is, merely follow along for now and it volition be explained further later!

Let'southward become alee and open our new baby up in VS Lawmaking. In VS Code become File -> Open up Folder and select your "solution" folder. The offset time you open up a new .net core project, You lot will meet the following bar come across the top of your screen.

Pressing yes on this creates a launch.json and a tasks.json file inside your solution. These are used to be able to launch and debug your project from VS Code. You tin can create these manually and edit them, but it'due south easier just to let VS Code handle this for us, so click Yep.

On your tree menu, go into your new web project -> Controllers -> Dwelling house Controller and have a play around. You lot will quickly detect that all the intellisense, syntax highlighting,  and abrasive warnings that yous know and love from Visual Studio are here.

Running Your Project In VS Lawmaking

This is going to exist a pretty brusque section. Just press F5 in VS Code to have your project launch. Any build errors will need to be resolved before launching your projection, but otherwise a new browser window/tab should open up with your project running in it. Breakpoints in VS Lawmaking all work as per normal, and things such as callstack, watches, output console etc are all there too.

There is however one small problems. If you get the following message "Could non observe the prelaunch task build". The kickoff thing yous should do is try and close VS Lawmaking and reopen information technology over again. As stupid as this sounds, this happens on new projects all the time and it's resolved with a quick open and close!

Managing Nuget Packages

Nuget is the package system for .net. If you've used NPM, Bower or Composer before, information technology's all pretty like.

Now if you take used Nuget before, in the latest version in that location are numerous changes similar no more packages.config, no more local cache of packages (In that location is now a global cache per machine), and many other changes. There are too many new things to really put in this article, but information technology is worth going and having a read on what you can expect.

To add a bundle to your project, y'all now have to utilize the control line (Which isn't every bit scary every bit you might think!). If we wanted to add the "Newtonsoft.Json" package to our project, we would run the following in the project folder :

dotnet add package Newtonsoft.Json

This will add together the reference in your csproj, then run a "restore" on your project to ensure you have the package in your global cache. If y'all bank check inside your csproj file for your project, you should see something similar to the following :

<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />

You lot can really add and remove references to nuget packages directly in the csproj file if you lot think it's going to be easier, simply remember from the command line you need to run "dotnet restore" to ensure that you take all the packages required. It can be easier when you are trying to consolidate multiple projects to the same nuget packet version to simply go ahead and edit the project file straight rather than hand typing the dotnet add together command in your console.

Adding Project References

In whatever project larger than a "Hi World", y'all are going to be building class libraries that need to be referenced from other projects in your solution Over again, another Visual Studio carbohydrate that you are going to miss when moving to VS Code. Luckily there is a dotnet control for that!

The exact command is

dotnet add together "MainProject" reference "LibraryProject"

Or in our instance app. I have added a new project called "VSCodeExample.Library", and I'chiliad going to add together it to my web project. I run the following from my solution directory.

dotnet add "VSCodeExample.Spider web/VSCodeExample.Web.csproj" reference "VSCodeExample.Library/VSCodeExample.Library.csproj"

When I open up my VSCodeExample.Web.csproj I now run across the following :

<ItemGroup>   <ProjectReference Include="..\VSCodeExample.Library\VSCodeExample.Library.csproj" /> </ItemGroup>

And once again, y'all can add together this project reference direct in your csproj if y'all prefer it that mode. There is no magic going on behind the scenes when you run the dotnet command, it literally but adds that XML.

Anything Else?

No doubtfulness I've missed a couple of things that are specific to your project. The best advice I can give is to practice a quick scan on the dotnet command list here. Y'all don't need to read in depth on every single command, but when you get into a jam it usually gives you a lightbulb moment of "Yeah… I think I remember in that location was a dotnet command for that…". And as always, driblet a comment below if you get stuck with anything else!

Yeoman is a code scaffolding tool that generates boilerplate project code for you. If y'all've been developing on Windows for some time, you're probably using Visual Studio to create your projects, and letting it generate your "base" code. For the most role, if you lot're nevertheless on Windows and nonetheless use Visual Studio, Yeoman may not be for you lot (But it's still non totally out of the question!). If yous're on Linux, or prefer building in a minimalistic scenario using something like VS Code, and so Yeoman can exercise a lot of the legwork for y'all.

Getting Started

The template we are going to use in this tutorial utilizes the bower package manager. If yous don't have this, or ff you lot don't know what this is, y'all are going to have to install it. Run the post-obit from a command prompt/terminal to install Bower.

npm install -g bower

Yeoman is actually an NPM module and so if you oasis't already, you volition need to install NodeJS from here. Once you lot've got Node up and running, you need to run the following command from a command prompt (Or terminal on non Windows), to install Yeoman globally.

npm install -grand yo

Now while Yeoman is a scaffolding tool, the templates information technology uses to really generate the code are mostly community driven. You tin can notice all possible generators on this folio here. While this tutorial focussesd on using Yeoman with .cyberspace core, it tin can be used to scaffold any codebase in whatsoever language. The generator nosotros will be using is called "generator-aspnet". For this, nosotros need to install the template using NPM. So run the following in a terminal/command prompt.

npm install -g generator-aspnet

Great, now nosotros are set up to go!

Get create a binder for your project now. Open a command prompt/concluding within this binder and run

yo aspnet

All going well, you should exist presented with a screen that is similar to this (Annotation it tin can take a while for things to kick into gear, just be patient!)

Select "Web Application" (Not Empty). On the next screen select the Bootstrap framework, type your project proper noun in and let rip. Y'all will see Yeoman go ahead and create your project similar to how Visual Studio would do it, you tin can then open up your project binder and see this :

As yous probably saw, there are a tonne of templates built in to do near of the legwork of projection creation for yous. Have a play effectually creating different project types and see what is generated for you. Again, if you are using Visual Studio as your IDE, then well-nigh of this won't be that amazing, merely if you are going without, and so having something to generate all this code for you is a godsend.

Using Other Templates

As quickly discussed above, this aspnet generator isn't the only template for .cyberspace core in Yeoman. If yous had over here, and type in .net core you will find several generators that tin can be used. Many of which are the basic template but with slight additions such as using Angular 2 instead of one.6.

One template that is very pop is one by Microsoft called "aspnetcore-spa". You can observe out more info over on the Github page, but in short it'southward a code template for creating single page apps.

Creating Your Own Templates

If you are a vendor and discover yourself creating (for lack of a better term), "cookie cutter" blazon websites where there are many similarities, y'all might actually want to create your own custom template to create consistency. It's not quite as directly forrad as throwing something in a directory and having Yeoman copy/paste information technology, just information technology's definitely worth investigating if you detect yourself creating average code time and fourth dimension once again. Yous can read more than in the official Yeoman docs.

Y'all've just installed Visual Studio 2017 (Or the very latest .internet cadre SDK), and now when you try to compile an old .net core project you had laying effectually, y'all are getting an mistake similar to the following :

.vs\restore.dg(1,1): fault MSB4025: The project file could non be loaded. Data at the root level is invalid. Line 1, position 1.

The issue is actually very very like to a previous error you would have occured when you installed Visual Studio 2017 RC over the top of Visual Studio 2015. You tin read nearly that issue here.

The set is very similar, get-go go to "C:\Programme Files\dotnet\sdk" on your machine. You should see a list of SDK versions. The version you are likely looking for is "1.0.0-preview2-003131" if y'all were previously opening this project in Visual Studio 2015. If you accept 2 versions only, and then the version you are looking for is the one that is *not* labelled 1.0.0. If you take but 1.0.0, then you probably got this project from someone else so will have to liase with them what version of the SDK yous should be installing. Install that SDK and and then come back to read on!

In the root of your solution for your project, create a file named "global.json". Inside that file, place the following contents :

{   "sdk": { "version": "1.0.0-preview2-003131" } }

Where the version is the SDK version from our previous step.

Ensure Visual Studio is closed and at present open a command prompt in your solution directory of your project. Run the command "dotnet restore". You should see a few packages whiz past. After this open your solution once again (In Visual Studio 2015), and y'all should now be able to build successfully!

Direct into the of import links.

Download hither
Release Notes here

In that location are a tonne of blogs out at that place talking virtually the release, so let'due south merely jump straight into the five features that I think developers will be most excited near. There is a tonne of new stuff coming out, merely I think these are the features that volition impact developers lives on an almost daily basis.

Inbuilt Unit Testing On The Wing

There has been addons for years that run unit tests as you type and permit you know if your unit tests are falling apart, well at present Microsoft has added the support to Visual Studio natively! Once again Microsoft have outdone themselves past supporting not only MSTest, but XUnit and NUnit are also supported.

Run To Click

A new feature in the debugger, when stopped at a breakpoint in your code, you can now go along execution to a "point" where your mouse clicks rather than having to place a breakpoint every few lines and pace through.

Redgate SQL Search

Congenital into every version of Visual Studio (Including the free Community version), is Redgate'southward SQL Search product. How many times accept you lot wanted to know whether a cavalcade is referenced anywhere, and you lot are faced with the daunting task of searching through a massive lump of Stored Procedures? Redgate SQL search takes care of this by allowing you to do a text search across every database object. Information technology really is an awesome production and it's great that it's at present part of Visual Studio.

Intellisense Filter

Intellisense now has a tray that allows you to filter the member listing by type. This ways that when you are working with an unfamiliar library (Or a new lawmaking base), and you know that "there should be a method that does XYZ", y'all tin now filter to only methods and ignore all properties. This feature alone makes upgrading to Visual Studio 2017 worth it. Notation that the feature is not enabled past default, to do and then : go to Tools > Options > Text Editor > [C# / Basic] > IntelliSense and bank check the options for filtering and highlighting.

Utilize Of Git.exe

Upwards until Visual Studio 2017, the Git implementation in VS was built using Github's libgit2. For almost people this was fine, but in that location were a few features available to yous on the command line that weren't available to you inside Visual Studio. Nigh notably, the use of SSH keys. While virtually people who already utilize Visual Studio's GIT tools are probably happy with existing functionality, it'south always good to have the tools on parity with what's already out there.

What Else?

Something else you are excited about? Drop a annotate below and allow u.s. know!

Are you getting the error as seen in the title when creating a new project in Visual Studio 2015?

The following error occured attempting to run the project model server procedure (i.0.0-rc4-004771).

Unable to beginning the process. No executable found matching command "dotnet-projectmodel-server"

And in image class :

Chances are this scenario has played out in the past day or then.

  • You have previously used .internet core tooling using project.json in Visual Studio 2015
  • You installed the latest .net core tooling (RC4 or higher) that uses csproj files
  • OR yous installed Visual Studio 2017
  • Yous are now using Visual Studio 2015 to create a new project

There are two ways to "fix" this.

The "I Don't Really Care" Method

If the deviation between .csproj and project.json tooling is beyond you and you lot really don't intendance. But apply Visual Studio 2017 from at present on to create .net core projects. Yes that seems very silly, simply information technology is the much easier approach and for many it'due south not going to make too much of a departure. You can still open existing project.json .net core projects in Visual Studio 2015 (Provided they have a global.json. see below), just not create new ones.

The "I Want To Actually Set up This" Method

So the reason this error occurs is that Visual Studio 2015 is not able to utilise the very latest .cyberspace core tooling (Currently RC4). When you lot create a new project *or* when you open an existing projection without a global.json file specifying an older tooling version, .internet core tries to use the latest tooling SDK installed on your machine.

I highly recommend reading this article on running two versions of the .net cadre tooling SDK next to go a better idea of how this works. It will let yous to fix these issues in the future.

The ready to actually getting your project to open is past creating a global.json file in the root of your solution with the following contents.

{ 	"sdk": { 		"version": "ane.0.0-preview2-003131" 	} }

Where the SDK version is your previous SDK version yous were running. Again, if you are unsure about this delight read this article on running two versions of the .net core SDK tooling. It'south actually super surprising how many issues tin be resolved by knowing how the SDK versioning works.

There are two types of people when information technology comes to Database Migrations. Those that want a completely automated process in their CI pipeline and have very potent opinions on what tool to use information technology, and and so there are those who couldn't care less and just want to run things past hand (Seriously, those still exist).

This article volition try and focus on the former, on what tools best fit into the >Cyberspace Cadre ecosystem. I think most of it isn't specific to .Cyberspace Core, but there are a few extra considerations to take into account.

Showtime let'southward take a look at what I remember are the 4 main principles of a database migration suite (Or any pace in a CI pipeline).

Repeatable

You should exist able to standup a database from scratch and have information technology function exactly as the existing production database does. This may include pre-seeding data (such every bit admin users) right from the get become. Repeatable likewise means that if for some reason the migration runs once again, it should exist "aware" of what it's already done and not blow upward trying to run the same scripts over and over.

Automated

Every bit much every bit possible, a practiced database migration strategy should be automated. When trying to reduce the element of homo error, you should just remove the humans all together.

Scalable

There are actually 2 parts to this. Scalable means that equally the database gets bigger, your migration doesn't start falling over. This besides means that the tooling you might be using to generate diffs or really run the migrations doesn't start dying likewise. But scalable as well has a second pregnant, and that is scalable with your team. That ways equally your squad reaches large proportions on a single project (Say shut to a dozen developers), does managing migrations and potential code conflicts get out of control.

Flexible

For database migrations, flexible is all almost is the tooling adept enough to handle all sorts of database changes, not just a schema change. If you ever divide a field, you will have to migrate that data somehow. Other times you may desire to mass update information to fix a previous bug, and you want this to be automated along with your database rollout, non run manually and forgotten most.

Database Project/SQL Project in Visual Studio

I remember the first few times I used a database project to update a database schema, information technology felt like magical. At present it feels like it has it'south place for showing a database state, but it'southward migration ability is severely defective. In terms of how a dbproj actually processes an update, information technology compares the existing database schema to the the desired state, and then generates scripts to get it there and runs them. But permit's call up about that for a 2nd, at that place may be many "steps" that nosotros desire to do to get us to the desired schema, not a huge leap forward. It's less of a pace by step migration and more of a blunt tool to get you to the end upshot the fastest.

Because of the mode a dbproj processes migrations, it also makes updating actual data very difficult to exercise. You may take a multi step process in which you want to split up a column slowly by creating a temporary field, filling the data into in that location, and and then doing a slow migration through code. It doesn't really work because a dbproj is more of a "desired state" migration.

That being said, database projects are very good at seeing how a database has evolved over fourth dimension. Because your database objects go "code" in your source control, you can see how over columns/views/stored procedures have been added/remove, and with the associated check in annotate besides.

Information technology should likewise exist noted that DB Projects are not multi platform (Both in OS and database). If y'all are building your existing .NET Core projection on Linux then database projects are out. And if you are running anything merely Microsoft SQL Server, database projects are also out.

Repeatable : No (Migration from A -> B -> C will ever work the same, but going straight from A -> C may give y'all weird side furnishings in information management).
Automated : Aye
Scalable : Yeah
Flexible : No – Data migrations are very hard to pull off in a repeatable mode

Entity Framework Migrations

EF Migrations are normally the go to when you are using Entity Framework as your data layer. They are a true migration tool that can be started from whatsoever "country" and run in lodge to bring you to the desired state. Dissimilar a dbproj, they always run in order so you are never "skipping" data migrations past going from state A -> C. It will all the same run A -> B -> C in gild.

EF Migrations are created using their own fluent API in C# lawmaking. For some this feels natural, but others feel limited in what they tin achieve trying to command a complex database with a subset of SQL commands that have been converted to the DSL. If you think about circuitous covering indexes where you have multiple columns along with include columns etc, at that place is probably some very circuitous style to do it via C# code, but for virtually people information technology becomes a hassle. Add to the fact that ORM's in general "hide" what queries they are actually running, then now you lot are besides hiding how your database is really tuned and created,  it does make some people squirm.

But the biggest outcome with EF Migrations is the actual migration running itself. Entity Framework is actually "enlightened" of the state of the database and really throws its toys out of its cot if things aren't up to date. It knows what migrations "should" have run, so if there are awaiting migrations, EF actually does have a hissy fit. When you are running blue/green deployments, or you have a rolling set up of web servers that need to be compatible with your sometime and new database schema, EF Migrations simply do non work.

Repeatable : Yes
Automated : Yes
Scalable : No
Flexible : Sort Of – Y'all can migrate data and fifty-fifty write custom SQL in a EF Migration, but for the most part y'all are limited to the EF fluent API

DB Upwardly

Total disclosure, I love DB Up. And I love it even more now that it has announced .NET Cadre support is coming (Or already here depending on when you read this).

DB Up is a migration framework that uses a collection of SQL files, and runs them in guild from start to end. From any existing state to any desired country. Because they are but plain old SQL files, every SQL command is available to you, making DB Up easily the near powerful migration tool in your armory for dealing with extremely complex databases. Information migrations also go less of a pain considering you merely accept every single SQL tool bachelor.

In a CI scenario, DB Up is able to build a database from scratch to any point in time, meaning that testing your "new" C# lawmaking on your "old" database is now a breeze. I can't tell yous how many times this has saved my ass in a large squad environment. People are forever removing columns in a SQL database before removing them from lawmaking, causing the old code to error out and crash. In large spider web deployment scenarios where at that place are cross over periods with a new database schema existence in play, but old web code running on top of information technology, it'due south a god send.

The other great thing about DB Up is that it'due south database agnostic (To a caste). Information technology supports Postgres, MYSQL, Firebird, SQL Azure and of course SQL Server. This is great news if yous are running your .NET Core code on something like Postgres.

But, there is a big flaw when using something with DB Up. Information technology becomes hard to see how a item table has changed over time. Using DB Up all you have is a collection of scripts that when run in society, give y'all the desired upshot, simply using source command it becomes hard to run across how something has evolved. In terms of migrations, this isn't a big deal. Merely in terms of being able to meet an overall film of your database, not so keen.

Repeatable : Yes
Automatic : Yeah
Scalable : Yep
Flexible :Yes

Hybrid Arroyo

I tend to take a hybrid approach for most projects. DB Up is far and away the all-time database migration tool, but it is limited in seeing the overall state of the database. That'due south where a database project comes in. It's cracking for seeing the overall movie, and you can check back through source command to run into how things have inverse over fourth dimension. Merely information technology'due south migration facilities are severely express. With that, information technology becomes a not bad fit to apply both.

And Y'all?

How do you lot do your migrations? Exercise you apply one of the in a higher place? Or maybe something like Fluent Migrator? Driblet a annotate below!