Scott Hanselman

How to host your own NuGet Server and Package Feed

April 13, 2016 Comment on this post [39] Posted in NuGet | NUnit
Sponsored By

Local NuGet FeedHosting your own NuGet Server, particularly when you're a company or even a small workgroup is a super useful thing. It's a great way to ensure that the build artifacts of each team are NuGet Packages and that other teams are consuming those packages, rather than loose DLLs.

A lot of folks (myself included a minute ago) don't realize that Visual Studio Team Services also offers private NuGet Feeds for your team so that's pretty sweet. But I wanted to try out was setting up my own quick NuGet Server. I could put it on a web server in my closet or up in Azure.

From the NuGet site:

There are several third-party NuGet Servers available that make remote private feeds easy to configure and set-up, including Visual Studio Team Services, MyGet, Inedo's ProGet, JFrog's Artifactory, NuGet Server, and Sonatype's Nexus. See An Overview of the NuGet Ecosystem to learn more about these options.

File Shares or Directories as NuGet Server

Starting with NuGet 3.3 you can just use a local folder and it can host a hierarchical NuGet feed. So I head out to the command line, and first make sure NuGet is up to date.

C:\Users\scott\Desktop>nuget update -self
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 3.3.0.
NuGet.exe is up to date.

Then I'll make a folder for my "local server" and then go there and run "nuget init source dest" where "source" is a folder I have full of *.nupkg" files.

This command adds all the packages from a flat folder of nupkgs to the destination package source in a hierarchical layout as described below. The following layout has significant performance benefits, when performing a restore or an update against your package source, compared to a folder of nupkg files.

There's two ways to run a "remote feed" handled by a Web Server, rather than a "local feed" that's just a file folder or file share. You can use NuGet.Server *or* run your own internal copy of the NuGet Gallery. The gallery is nice for large multi-user setups or enterprises. For small teams or just yourself and your CI (continuous integration) systems, use NuGet.Server.

Making a simple Web-based NuGet.Server

From Visual Studio, make an empty ASP.NET Web Application using the ASP.NET 4.x Empty template.

New Empty ASP.NET Project

Then, go to References | Manage NuGet Packages and find NuGet.Server and install it. You'll get all the the dependencies you need and your Empty Project will fill up! If you see a warning about overwriting web.config, you DO want the remote web.config so overwrite your local one.

Nuget install NuGet.Server

Next, go into your Web.config and note the packagesPath that you can set. I used C:\LocalNuGet. Run the app and you'll have a NuGet Server!

You are running NuGet.Server v2.10.0

Since my NuGet.Server is pulling from C:\LocalNuGet, as mentioned before I can take a folder filled with NuPkg files (flat) and import them with:

nuget init c:\source c:\localnuget

I can also set an API key in the web.config (or have none if I want to live dangerously) and then have my automated build push NuGet packages into my server like this:

nuget push {package file} -s http://localhost:51217/nuget {apikey}

Again, as a reminder, while you can totally do this and it's great for some enterprises, there are lots of hosted NuGet servers out there. MyGet runs on Azure, for example, and VSO/TFS also supports creating and hosting NuGet feeds.

Aside: Some folks have said that they tried NuGet.Server (again, that's the small server, not the full gallery) a few years ago and found it didn't scale or it was slow. This new version uses the Expanded Folder Format and adds significant caching, so if you've only see the "folder full of flat nupkg files" version, then you should try out this new one! It's version 2.10+. How much faster is it? First request to /nuget (cold start, no metadata cache) before was 75.266 sec and after is 8.482 sec!

The main point is that if you've got an automated build system then you really should be creating NuGet packages and publishing them to a feed. If you're consuming another group's assemblies, you should be consuming versioned packages from their feeds. Each org makes packages and they flow through the org via a NuGet server.

Important! If you are using a Network Share with NuGet.Server, make sure you have the newest version because this file folder structure can give you MAJOR performance improvements!

How do YOU handle NuGet in YOUR organization? Do you have a NuGet server, and if so, which one?


Sponsor: Big thanks to RedGate and my friends on ANTS for sponsoring the feed this week!

How can you find & fix your slowest .NET code? Boost the performance of your .NET application with the ANTS Performance Profiler. Find your bottleneck fast with performance data for code & queries. Try it free

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Installing Fish Shell on Ubuntu on Windows 10

April 09, 2016 Comment on this post [23] Posted in Linux | Open Source | Win10
Sponsored By

So hopefully by now you've heard that you can run Bash via Ubuntu on Windows...and not in a VM. You can run the Bash Shell and real ELF Linux Binaries (this is not emulation) on Windows 10.

I've recorded a 30 min video with developers from the project and there's a blog post from Dustin from Ubuntu about HOW this works if you want more technical details. You should also check out the Command Line Blog and subscribe and head over to User Voice to help pick the next features.

It's beta, but it's super fun. A common question is "hey bash is lovely but what about _____ shell." Right now as I understand it supports bash and adding other shells may not work, and if it does, you're hacking around. So, let's hack around.

I noticed this shell called Fish Shell and noticed that Ruby Nealon had Fish tweaked and running. I asked for some more detail and they were happy to oblige with a medium post. Thanks Ruby!

Let me give it a try.

Add the Fish Apt Repo and install.

I headed over to the fish site and did this.

sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update
sudo apt-get install fish

Oh, and I also changed my Console Font to use Ubuntu Mono because

Note: I'm hearing it will be WAY easier to add new fonts as the console continues improving. The conhost.exe stuff improves console for everyone, including cmd.exe, powershell.exe, and bash. That console work includes VT100, ANSI, and other stuff, and is separate, but complementary to the bash work.

Nice font.

Bash on Ubuntu on Windows - Cats and Dogs Living Together Mass Hysteria

Because we're still launching bash, we need to use the .bashrc today to launch fish, so you'll need to add ssh-agent fish, and exit to your .bashrc if you want to try this.

OK, next, kind of unrelated to fish, but still useful, I wanted to setup git and ssh-agent, so I generate a new key, add it to ssh agent, following these guides.

Theming Fish

Ruby also points out that Fish has a "Oh My Fish" framework for packages and themes. You can get it easily:

curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish
omf help

Ruby also included their own fish_prompt.sh file here for the "chain" theme that I installed with "omf install chain" as some glyphs rendered weird. If you want unicode characters like → in your prompt, make sure your files are UTF-8 and not ANSI or you'll get squares!

Now my prompt uses fish, has cool auto complete, nice colors, shows the git dirty bit and branch.

image

Yes, I realize there are literally fiftyleven billion ways to customize bash, zsh, and lots of other shells to do much cooler stuff than this. I too, am old, and I to have used *nix for years. But it was fun and easy to get fish running on Ubuntu on Windows. Thanks Ruby!


Sponsor: Quality instrumentation is critical for modern applications. Seq helps .NET teams make sense of complex, asynchronous, and distributed apps on-premises or in the cloud. Learn more about structured logging and try Seq free for 30 days at https://getseq.net.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Visual C++ for Linux and Raspberry Pi Development

April 06, 2016 Comment on this post [8] Posted in Open Source | VS2015
Sponsored By

It's bananas over at Microsoft. Last week they announced you can run Bash on Ubuntu on Windows 10, and now I'm seeing I missed an announcement of an extension to Visual Studio that enables Visual C++ for Linux Development.

With this extension you can author C++ code for Linux servers, desktops and devices. You can manage your connections to these machines from within VS. VS will automatically copy and remote build your sources and can launch your application with the debugger. Their project system supports targeting specific architectures, including ARM which means Raspberry Pi, folks.

ASIDE: I also noticed there's a C/C++ extension for Visual Studio Code also. I need to add that to my list of stuff to check out, it looks pretty compelling as well.

Once Visual C++ for Linux Development is installed, you go and File New Project like this. Cool to see Linux in that list along with a Raspberry Pi project.

File New | Linux App

You can pick x86, x64, and ARM, and you can see Remote GDB Debugger is an option.

Remote GDB Debugger

Here I'm running Ubuntu in a VM and connecting to it over SSH from Visual Studio. I needed to set up a few things first on the Ubuntu machine

sudo apt-get install openssh-server g++ gdb gdbserver

Once that was setup, connecting to the remote Linux machine was pretty straightforward as VS is using SSH.

Debugging C++ apps remotely talking to a Linux VM

Pretty cool.

NOTE: Today this cool extension has nothing to do with the Bash on Ubuntu on Windows announcement or that subsystem.  The obvious next question is "can I use this without a VM and talk to gdb on the local Linux subsystem?" From what I can tell, no, but I'm still trying to get SSH and GDB working locally. It's theoretically possible but I'm not sure if it's also insane. Both teams are talking, but again, this feature isn't related to the other.

This extension feels a little beta to me but it does a good job providing the framework for talking to Linux from VS. The team looks to be very serious and even has a cool demo where they code and debug a Linux desktop app.

If you're looking for a another full featured solution for Linux and Embedded Systems development with Visual Studio, be sure to download and check out VisualGDB, it's amazing.


Sponsor: Quality instrumentation is critical for modern applications. Seq helps .NET teams make sense of complex, asynchronous, and distributed apps on-premises or in the cloud. Learn more about structured logging and try Seq free for 30 days at https://getseq.net.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Developers can run Bash Shell and user-mode Ubuntu Linux binaries on Windows 10

March 30, 2016 Comment on this post [107] Posted in Open Source | Win10
Sponsored By

UPDATE: I've recorded a 30 min video with developers from the project as well as Dustin from Ubuntu about HOW this works if you want more technical details.

As a web developer who uses Windows 10, sometimes I'll end up browsing the web and stumble on some cool new open source command-line utility and see something like this:

A single lonely $

In that past, that $ prompt meant "not for me" as a Windows user.

I'd look for prompts like

C:\>

or

PS C:\>

Of course, I didn't always find the prompts that worked like I did. But today at BUILD in the Day One keynote Kevin Gallo announced that you can now run "Bash on Ubuntu on Windows." This is a new developer feature included in a Windows 10 "Anniversary" update (coming soon). It lets you run native user-mode Linux shells and command-line tools unchanged, on Windows.

After turning on Developer Mode in Windows Settings and adding the Feature, run you bash and are prompted to get Ubuntu on Windows from Canonical via the Windows Store, like this:

Installing Ubuntu on Windows

This isn't Bash or Ubuntu running in a VM. This is a real native Bash Linux binary running on Windows itself. It's fast and lightweight and it's the real binaries. This is an genuine Ubuntu image on top of Windows with all the Linux tools I use like awk, sed, grep, vi, etc. It's fast and it's lightweight. The binaries are downloaded by you - using apt-get - just as on Linux, because it is Linux. You can apt-get and download other tools like Ruby, Redis, emacs, and on and on. This is brilliant for developers that use a diverse set of tools like me.

This runs on 64-bit Windows and doesn't use virtual machines. Where does bash on Windows fit in to your life as a developer?

If you want to run Bash on Windows, you've historically had a few choices.

  • Cygwin - GNU command line utilities compiled for Win32 with great native Windows integration. But it's not Linux.
  • HyperV and Ubuntu - Run an entire Linux VM (dedicating x gigs of RAM, and x gigs of disk) and then remote into it (RDP, VNC, ssh)
    • Docker is also an option to run a Linux container, under a HyperV VM

Running bash on Windows hits in the sweet spot. It behaves like Linux because it executes real Linux binaries. Just hit the Windows Key and type bash.

After you're setup, run apt-get update and get a few developer packages. I wanted Redis and Emacs. I did an apt-get install emacs23 to get emacs. Note this is the actual emacs retrieved from Ubuntu's feed.

Running emacs on Windows

Of course, I have no idea how to CLOSE emacs, so I'll close the window. ;)

Note that this isn't about Linux Servers or Server workloads. This is a developer-focused release that removes a major barrier for developers who want or need to use Linux tools as part of their workflow. Here I got Redis via apt-get and now I can run it in standalone mode.

Running Redis Standalone on Windows

I'm using bash to run Redis while writing ASP.NET apps in Visual Studio that use the Redis cache. I can then later deploy to Azure using the Azure Redis Cache, so it's a very natural workflow for me.

Look how happy my Start Menu is now!

A happy start menu witih Ubuntu

Keep an eye out at http://blogs.msdn.microsoft.com/commandline for technical details in the coming weeks. There's also some great updates to the underlying console with better support for control codes, ANSI, VT100, and lots more. This is an early developer experience and the team will be collection feedback and comments. You'll find Ubuntu on Windows available to developers as a feature in a build Windows 10 coming soon. Expect some things to not work early on, but have fun exploring and seeing how bash on Ubuntu on Windows fits into your developer workflow!


Sponsor:  BUILD - it’s what being a developer is all about so do it the best you can. That’s why Stackify built Prefix. No .NET profiler is easier or more powerful. You’re 2 clicks and $0 away, so build on! prefix.io

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Docker for Windows Beta announced

March 27, 2016 Comment on this post [17] Posted in VS2015
Sponsored By

Docker Desktop AppI'm continuing to learn about Docker and how it works in a developer's workflow (and Devops, and Production, etc as you move downstream). This week Docker released a beta of their new Docker for Mac and Docker for Windows. They've included OS native apps that run in the background (the "tray") that make Docker easier to use and set up. Previously I needed to disable Hyper-V and use VirtualBox, but this new Docker app automates Hyper-V automatically which more easily fits into my workflow, especially if I'm using other Hyper-V features, like the free Visual Studio Android Emulator.

I signed up at http://beta.docker.com. Once installed, when you run the Docker app with Hyper-V enabled Docker automatically creates the Linux "mobylinux" VM you need in Hyper-V, sets it up and starts it up.

"Moby" the Docker VM running in Hyper-V

After Docker for Windows (Beta) is installed, you just run PowerShell or CMD and type "docker" and it's already set up with the right PATH and Environment Variables and just works. It gets setup on your local machine as http://docker but the networking goes through Hyper -V, as it should.

The best part is that Docker for Windows supports "volume mounting" which means the container can see your code on your local device (they have a "wormhole" between the container and the host) which means you can do a "edit and refresh" type scenarios for development. In fact, Docker Tools for Visual Studio uses this feature - there's more details on this "Edit and Refresh "support in Visual Studio here.

The Docker Tools for Visual Studio can be downloaded at http://aka.ms/dockertoolsforvs. It adds a lot of nice integration like this:

Docker in VS

This makes the combination of Docker for Windows + Docker Tools for Visual Studio pretty sweet. As far as the VS Tools for Docker go, support for Windows is coming soon, but for now, here's what Version 0.10 of these tools support with a Linux container:

  • Docker assets for Debug and Release configurations are added to the project
  • A PowerShell script added to the project to coordinate the build and compose of containers, enabling you to extend them while keeping the Visual Studio designer experiences
  • F5 in Debug config, launches the PowerShell script to build and run your docker-compose.debug.yml file, with Volume Mapping configured
  • F5 in Release config launches the PowerShell script to build and run your docker-compose.release.yml file, with an image you can verify and push to your docker registry for deployment to other environment

You can read more about how Docker on Windows works at Steve Lasker's Blog and also watch his video about Visual Studio's support for Docker in his video on Ch9 and again, sign up for Docker Beta at http://beta.docker.com.


Sponsor: Thanks to Seq for sponsoring the feed this week! Need to make sense of complex or distributed apps? Structured logging helps your team cut through that complexity and resolve issues faster. Learn more about structured logging with Serilog and Seq at https://getseq.net.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.