Friday, March 6, 2015

How to get started with OneGet on Windows 10 Technical Preview

Ill start this post off by saying, I am not a huge Windows fan, but due to my line of work, I must keep up with Windows as much as possible. One of the newest features which actually excites me is the addition of the windows command line package management system called OneGet which can be found in the latest versions of Powershell and Windows. If you are familiar with Linux based package management systems such as apt, yum, and ebuild then you can think of OneGet as the Windows version of these systems.

As of now, OneGet is available in Powershell version 5 which comes with Windows 10 Technical Preview. You can also utilize OneGet on Windows 8.1 if you upgrade Powershell to version 5 with the Windows Management Framework Preview which is available here.

In this tutorial, I will assume you are going the Windows 10 route as I find updating Windows to 8.1 to be too time consuming for my tastes.

Obtain a free copy of Windows 10 TP

At the time of writing (3/6/15) you can head over to their download page and download a free copy of Windows 10 TP. Go ahead and install this to a virtual manchine or to a test box.

Enable the Ability to run Powershell Scripts

Before we get started, we must first enable the ability to run Powershell scripts in your Windows environment. By default, Windows will allow you to run Powershell but will not allow externally generated Powershell scripts to be run. Oneget and Chocolaty typically run Powershell scripts to finalize the installation of applications installed from OneGet.

Open up an administrator Powershell console

  • type Win + r to pop open a run command window and type powershell
  • Either right click on the Powershell icon on your taskbar and click "Run as Administrator" or type the following into your current Powershell console
Start-Process powershell -Verb runas

Enable Powershell scripts

  • in the administrator powershell window, run the following
Set-ExecutionPolicy Unrestricted 
  • In the above command, I set the execution policy to unrestricted. If you want to be more secure, you can chose a more restricted execution level. Details on the execution policy settings can be found here

Close your admin window

  • For the rest of this tutorial, we will be using the non-administrator Powershell console. If you have closed it, go ahead and open it again and close the admin console by clicking the close button in the top right corner or by typing exit

Install the NuGet package

  • Before we start installing packages, we have to install the NuGet package. The NuGet package management tool is used to manage software dependancies of all of the packages we will be installing. You can find more about NuGet here.
  • Note: during the nuget.vs install step, you may see an error. Just go ahead and install it and ignore the error. I have not found a solution for properly avoiding the error in this step. The error does not seem to affect anything.
install-package nuget.vs

Find a package to install:

  • This step is optional, but it shows how we can search for packages with OneGet. In this example, we are looking for the Windows SSH package named Putty.
find-package putty

Install a package:

  • Once we know our package exists in our application repositories, we can install it with the following command.
install-package putty

Run your newly installed application

  • That's it!!! Most applications get installed to the directory . To start up the example putty application we installed in the previous step, run the following:

No comments:

Post a Comment