New for Visual Basic: .NET Standard Class Libraries and the dotnet CLI!

Anthony D. Green [MSFT]

Visual Studio 2017 15.3 Preview 1 included templates for VB class libraries targeting .NET Standard class libraries and for .NET Core console apps. With the release of .NET Core 2.0 today those templates go-live. The .NET Standard You can use the built-in templates to create cross-platform command-line apps, as well as creating and testing cross-platform VB libraries targeting the new .NET Standard. When you target a version of the .NET Standard you get access to all the APIs included in that version of the standard. You can then use that single library in any app targeting a platform that supports that version of the .NET Standard or higher with confidence that all those APIs will be available on that platform. This is similar to portable libraries of the past but the set of APIs supported across all the different platforms that support .NET is much larger. Additionally, unlike in the past where, for example, .NET Framework might support a particular overload of a method and that method could be missing on another platform, with .NET Standard if you can see that overload in that version of the standard it’ll be there everywhere—no surprise MethodNotFoundExceptions. This opens up new opportunities for VB developers to package up and reuse their business logic (and more) in new places like Xamarin and .NET Core all while maintaining a single codebase. Last month VB MVP Klaus Loeffelmann showed us a powerful example of this in action building a single library that drives an app targeting UWP, iOS, and Android devices. VB in the .NET CLI (“dotnet new -lang VB”) Additionally, for the first time ever, Visual Basic is included as part of the .NET Command-Line Interface (CLI) Tools. This means you’ll be able to install the dotnet CLI on Windows, Mac OS X, and supported Linux distros; create, modify, compile, and run a VB project entirely without Visual Studio. Once you download the .NET Core 2.0 tools, making and running your first cross-platform .NET Core app is as simple as 1-2-3:

  1. Opening a console window and creating a new directory for your project.
  2. Entering the command dotnet new console -lang vb.
  3. Entering the command dotnet run.

Out of the box the CLI comes with four VB templates:

  • .NET Core console apps
  • Class libraries targeting either .NET Standard or .NET Core
  • Unit test projects using MSTest
  • Unit test projects using xUnit

But that’s just the beginning. The .NET CLI comes with a new and much simpler templating engine that makes it super easy for community members to create their own templates (instructions here). These templates will work both with the CLI and within Visual Studio. For full instructions on how to use the .NET CLI as well as What’s New in this release of the CLI, including Visual Basic support check out this page. To learn more about .NET Standard go here. In closing… Earlier this year, we identified VB support for .NET Core and .NET Standard as top priorities for VB and today we deliver on this important step toward VBs future. We hope you’ll go get the .NET Core 2.0 SDK today and get to work building great tools and libraries in VB (and for the first time ever *cross-platform*!). Until next time, happy coding! Regards, Anthony D. Green, Program Manager, Visual Basic

0 comments

Leave a comment

Feedback usabilla icon