Dotnet Restore Command Not Found – Exploring The New DotNet CLI

Aspnetcore 1

It has been a year since I posted Taking Visual Studio Code and ASP.Net 5 For A Spin on which I tried to create a simple ASP.Net 5 web application using the then just released free Visual Studio Code. Microsoft also released in Beta that time the new .net framework based which called DNX which is now known as .Net Core. In this post, I will try again to create simple web application using the new .Net Core.

Trying from Yo

I will use Yeoman to help me with the scaffolding of a new web application.

 yo aspnet 

Yeoman

After yeoman generated a web application for me, a confirmation message is displayed that the new project is now created and I can do now a “dotnet restore”.

Dotnetrestore yeoman

Going to the new web application directory I issued a command “dotnet restore” but I got a command not found error. I updated my Visual Studio Code just hoping to get an updated version of the framework along with it but to no avail.

Hello “Dotnet” .Net Core 1.0

Microsoft released last June of .Net Core 1.0 and along with it the new Dotnet CLI.

The DotNet CLI is included if you install the .Net Core SDK Installer. There is also a separate installer for .Net Core only.

You can get the installers straight from Github https://github.com/dotnet/cli/ (for the latest builds) or from https://www.microsoft.com/net/core

See all the flavours from the table below I got from the .Net Core Github repo:

Cli flavours

Sidenote:
Some hiccups along the way of updating my openSSL and brew. Need to execute “xcode-select —install” command to update. This is somewhat related to the El Capitan macOS that I have on my mac.

Sidenote

After installing the .Net Core with SDK, “dotnet” command is now available. As of today here’s my “dotnet —info”

Noels-MacBook-Pro:~ noelarlante$ dotnet --info
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 RID:         osx.10.11-x64

Sidenote: “dotnet restore” still does not work. I’m getting an error related to this question posted on Stackoverflow . I’ll post an update once this has been resolved.

Sidenote2

Until next time!

Taking Visual Studio Code and ASP.Net 5 For A Spin

Visual Studio Code Setup

Visual Studio Code Download

https://code.visualstudio.com/Download

Visual Studio Code (VSCode) is the latest free cross platform lightweight IDE from Microsoft. Visual Studio Code and ASP.Net 5 are being released as free and open source.

Initial Impressions for Visual Studio Code

Pros:

  • Lightweight IDE
  • Support for many Languages with IntelliSense
  • Git Integration
  • Open Folder
  • Easy Split Window Navigation
  • User and Workspace settings in JSON

Cons:

  • Does not support regions for C#
  • Keeps hanging when you use on large .Net solutions (Open Folder)

ASP.Net 5 Setup

According to Microsoft, DNX was built entirely from the ground up. The ASP.Net 5 was also created from the ground up, meaning all ASP.Net 5 projects are DNX projects. Good thing to note is that ASP.Net 5 is not anymore based from System.Web.dll. Things are built around the concept of packages and on demand references.

Windows

In order to install and run ASP.Net 5 from Windows, you will need to install the DNVM (Version Manager), DNU (Utility) and DNX (Execution Engine). The steps to install them can be found from this link.

OSX

A very cool new feature of ASP.Net 5 is that it can run and be developed in other platforms. I was very excited to try and develop ASP.Net on a non-Windows machine. It gave me enough reason to buy and upgrade my MacBook Pro 2008 to MacBook Pro 2015 ;).

Just like in Windows, you will need to install the DNX, DNVM and DNU. But this time, since its on OSX, everything will be dependent on Mono (.Net Open Source Project). You can get Mono by installing through Homebrew (package manager) in OSX. Actually, it works backwards, in Homebrew when you install the latest ASP.Net and DNX it installs Mono automatically since its a required package of ASP.Net.

Linux soon!

I do not have now a Linux machine to try and install ASP.Net 5 so next time I will post my ASP.Net 5 adventures with Linux!

Sample Project ASP.NET 5

Omnisharp log – Error logged on opening the sample project

When opening the sample ASP.Net 5 DNX project with VS Code without first installing DNX, you will encounter an error logged under the Omnisharp log. This is a good way to know the sequence where it looks for the DNX framework.

Omnisharp log

The DNX framework can be installed on your system like what I did when I followed the steps to initially setup DNVM, DNU, DNX amongst others. But you can also, make available the different DNX versions in your local by getting and compiling them from the Github repository. This way, you can test different versions of DNX from your system. Running DNVM list will show you different versions installed in your machine.

Two versions of DNX

Running the sample apps

There are sample projects up in the ASP.NET repository. You can download or clone them from Github.

I tried to open and run the web application under the HelloMVC sample folder. This is a sample MVC ASP.NET 5 project which you can open in VSCODE.

Inside the project folder, you can execute

dnu restore

to make download the dependencies of the sample project. Visual Studio Code will also prompt you to do the restore.

DNU Restore VSCode Window

DNU Restore Complete

To execute and start the hosting of the project run the command

 dnx . web 

DNX WEB

Open a browser and go to http://localhost:5001/ and you will see the sample MVC ASP.NET 5 project running.

Sample ASP NET 5 Website running

You can do the same steps to setup, compile and run the web project in OSX. As long as you have DNX installed you can start and run ASP.NET 5 projects. I’m trying to follow the latest in DNX and ASP.NET as a whole in Github – http://www.github.com/aspnet and try to contribute if possible 🙂 Thanks and until my next post!

Comparing using CompareTo C# Method

 

A colleague asked me for a suggestion on the program module he is doing that involves determining if one value is “>” greater than, “=” equal or “<” less than another value. I first thought of a solution involving a stack but its too low level and involves much longer code. After some suggestions and trying to think of another way, he came across of a solution to use CompareTo C# method.

What is CompareTo C# Method?

First, MSDN defines IComparable as an interface that “Defines a generalized type-specific comparison method that a value type or class implements to order or sort its instances.” It has a method called CompareTo which as defined by MSDN “Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.”

The CompareTo method is available on all objects as long as the objects has the same type. See the sample code below for comparing value types integer and a string type.

CsharpCompareTo

 

The Return Value of CompareTo

The CompareTo method has a return value of int. The integer value return will be one of the values less than 0, 0 or greater than zero as what is shown below.

CompareToReturnValues

 

Nullable Types Does Not Implement CompareTo

Take note that Nullable types like int? short for Nullable<int> does not implement the CompareTo method. It will not even compile since the method is not implemented.

CompareToNullable

This blog post will serve as a quick reference for me whenever there is a need for me to use sorting or comparison of data when programming. I hope it will serve the same for you.

 

 

Visual Studio 2012 Custom Installation Option Missing

 

TopImageMemeInstaller

I have installed Visual Studio 2012 several times in the past, its just now that I want do custom installation. Thank you to the limited space of an SSD drive, I need to keep the Visual Studio 2012 installation to a bare minimum. Just like past versions of  Visual Studio I can always just install what I want, right? Not with Visual Studio 2012.

Visual Studio Installer Feature Options

In Visual Studio 2012 installation, no option will let you pick only C# as the programming language, uncheck SQL Express or just proceed with complete installation. Every time it is complete installation.

Well not options were removed, you can choose if you want to install Blend for Visual Studio, Lightswitch and other features included in the installer.

Visual Studio Installation Size

My installation of Visual Studio 2012 took 5.24GB of space with Microsoft Office Developer Tools and Microsoft Web Developer Tools features selected.

This post of the Visual Studio team from Microsoft mentioned that they included the option for customisation but its not present with the installer I used. The installer was downloaded directly from the MSDN download site so I guess they remove the option again.

I’m happy with the improvement of Visual Studio 2012’s performance and features but giving me an option to just install what I want would not hurt. Not at all.

 

How to Install Hyper-V in Windows 8 Pro and Lenovo W530

Hero hyperv

One of the features included in Windows 8 is the Hyper-V client. In the past, the Hyper-V client is only available from Windows 2008 Server OS now you can have the same feature in Windows 8 Pro. Hyper-V, the machine virtualization technology, lets you run multiple operating systems at the same time on the same machine.

I’ve recently purchased a Lenovo W530 laptop which they called “The Beast”. It has Intel 3rd Gen Core i7 and 16Gigs of RAM(up to 32GB) perfect for Windows 8 Pro and Hyper-V. As a developer, I will need all the resources I can get from this machine.

Enabling Hyper-V Feature

Enabling Hyper-V is simple, just go to Windows 8 features panel to enable. But as you can see below the option for the Hyper-V option is greyed out. Message says “Hyper-V cannot be installed. Virtualization support is disabled in the firmware.

Windows8 Feature  HyperV Disabled withMessage

BIOS Configuration

To fix the issue, you need to go to your BIOS and enable the virtualisation option. For Lenovo W530, below is where you can set Virtualization to “Enabled”.

Lenovo W530 Virtualization BIOS rs

Activating Hyper-V

Go back to Windows 8 features and you now can see that the Hyper-V option is enabled.

Windows8 Feature  HyperV Enabled

Windows will need to restart after enabling the feature.

Windows8 Feature  HyperV Required Restart

After restart, Launch Hyper-V Manager and proceed with creating your virtual machines.

How To Disable Internet Explorer Enhanced Security Configuration on Windows Server 2012 RC

Internet explorer security

This is a guide on how to disable the Internet Explorer Enhanced Security Configuration (IE ESC) in Windows Server 2012 RC. I’ve blogged the steps on how to do this on Windows Server 2008 on my previous post – How To Disable Internet Explorer Enhanced Security Configuration

How to Disable Internet Explorer Enhanced Security Configuration on Windows 2012 RC

When you access a website such as the website of MSDN in Windows Server 2012, you would get the message below:

IE Prompt 2012

To disable this message, go to the Server Manager

ServerManager win2012

On the Server Manager window, choose Local Server, then click the IE Enhanced Security Configuration option under Properties

IE ESC Win2012

You will be then be prompted with the options window below. You can turn off the IE ESC to both Administrators and Users.

IE ESC Disable Win2012

After following these steps, close all Internet Explorer instances and then relaunch. You will now be able to go to websites within your Windows Server 2012 without the IE ESC message.

How To Disable Internet Explorer Enhanced Security Configuration

Internet security RS

This is a guide on how to disable the Internet Explorer Enhanced Security Configuration (IE ESC) which is enabled by default on Windows servers. You would usually disable this security feature on development instances of your Windows Server. The IE ESC feature reduces the risk of attack when you access external websites from within the server as explained by the following message from Microsoft Support:

Microsoft Internet Explorer’s Enhanced Security Configuration is currently enabled on your server. This enhanced level of security reduces the risk of attack from Web-based content that is not secure, but it may also prevent Web sites from displaying correctly and restrict access to network resources.

How to Disable Internet Explorer Enhanced Security Configuration on Windows 2008.

Note: See the steps for Windows Server 2012 RC here – Disable Internet Explorer Enhanced Security Configuration on Windows 2012 RC

When you access a website such as the website of MSDN, you would get the message below:

IE Prompt

To disable this message, go to the Server Manager

ServerManager win2008

On the Server Manager Summary window, click the Configure IE ESC option under Security Information. See exact location below:

IE ESC Win2008

You will be prompted with the options window below. You can turn off the IE ESC to both Administrators and Users.

IE ESC Disable Win2008

After following these steps, close all Internet Explorer instances and then relaunch. You will now be able to go to websites within your Windows server without the IE ESC message.

Windows 8 Consumer Preview Installation Options

windows 8 consumer preview beta fish

Windows 8 Consumer Preview Installation Options

I’m sure you have seen Windows 8 Consumer Preview installed to a virtual machine or an actual machine or slate(Tablet). I was able to install and try the Windows 8 Consumer preview myself and I was really surprised how smooth and responsive the system is. Kudos to the Windows team of Microsoft, this is far from the Windows 8 Developers Preview I’ve tried last year.

Curious enough? Install Windows 8 Consumer Preview with the options below and try it for yourself.

First, the Windows 8 Consumer Preview download sources:

(a) MSDN Subscriptionhttp://msdn.microsoft.com
I got my installer from MSDN download since we have volume license and the source server is different from public so downloading is faster 😉

Msdn windows 8 consumer preview links

I’m not sure what “with Apps” means but yes this is the installer you want to download.

(b) Download from Microsoft.comhttp://windows.microsoft.com/en-us/windows-8/download
This is where Microsoft published the public download location of Windows 8 Consumer preview. 1 million downloads for the first few hours of release according to Microsoft.

Add “iso” to get the ISO version of the installer – http://windows.microsoft.com/en-us/windows-8/download/iso

Target environments: Where can it run?

Boot from VHD – I have not tried this before I came across the post of Scott Hanselman on Windows 8 Boot from VHD post. Boot from VHD is only available if you have Windows 7 Enterprise and up version of Windows 7. Also take note that you cannot boot from a VHD hosted in a BitLocker enabled partition. It will not work either if you Suspend the BitLocker. Only way is decrypt the drive or use a different hard drive or partition without BitLocker.

Another approach to boot Windows 8 from VHD is to use the Windows Automated Installation Kit for Windows 7. Eric Boyd has posted the detailed instructions on how to do this on his website – How To Install Windows 8 with Native Boot to VHD.

Both approaches will make use of BCDEDIT and DISKPART commands which is fun!

Parallels Desktop as Virtual Machine – I have version 7 of Parallels for Mac to run my virtual machines. Installation using Parallels is as smooth as if you install directly to a physical machine though I would still prefer to have the boot from VHD option since its using the actual hardware and only the hard drive is virtualized.

Windows 8 Consumer Preview desktop

All of my Windows VM machines works flawlessly with Parallels. I got more VMs installed as you can see 🙂

Windows 8 Consumer Preview Parallels virtual machine list

Windows Virtual PC – Using a Windows Virtual PC is the common approach if you want to install a Windows virtual machine. But it seems Windows Virtual PC is NOT ready yet for Windows 8 (I’ve tried both 32-bit and 64-bit). I got a boot error from Windows 8 Consumer Preview 64-bit installation and an unhappy face for Windows 8 32-bit version.

Windows 8 Consumer Preview 64bit on VirtualPC

Error on 64 bit

Windows 8 Consumer Preview 32Bit on Virtual PC

Error on 32 bit

I was not expecting not to be able to run Windows 8 with Windows Virtual PC. I may need to install an updated version of virtual PC or allocate more memory perhaps? I will just use the boot from VHD approach or the Parallels for now, not a problem! 🙂

I’m excited to see the final release of Windows 8 soon! Metro-style user interface is really nice and it goes well with other Microsoft systems particularly the Windows Phone 7. These early releases and previews will give developers more time to create applications that will adopt the new system and address the bugs.

Everyone can participate in reporting a bug in the Windows 8 forum – http://answers.microsoft.com/en-us/windows/forum/windows_8. Make your bug count!

by