As you know we continue to incrementally improve Visual Studio 2017 (version 15), and our 7th significant update is currently well under way with the 4th preview shipping today. As we’re winding down the preview, we’d like to stop and take the time to tell you about all of the great things that are coming in 15.7 and ask you to try it and give us any feedback you might have while we still have time to correct things before we ship the final version.
From a .NET tools perspective, 15.7 brings a lot of great enhancements including:
- Support for .NET Core 2.1 projects
- Improvements to Unit Testing
- Improvements to .NET productivity tools
- C# 7.3
- Updates to F# tools
- Azure Key Vault support in Connected Services
- Library Manager for working with client-side libraries in web projects
- More capabilities when publishing projects
In this post we’ll take a brief tour of all these features and talk about how you can try them out (download 15.7 Preview). As always, if you run into any issues, please report them to us using Visual Studio’s built in “Report a Problem” feature.
.NET Core 2.1 Support
.NET Core 2.1 and ASP.NET Core 2.1 brings a list of great new features including performance improvements, global tools, a Windows compatibility pack, minor version roll-forward, and security improvements to name a few. For full details see the .NET Core 2.1 Roadmap and the ASP.NET Core 2.1 Roadmap respectively.
Visual Studio 15.7 is the recommended version of Visual Studio for working with .NET Core 2.1 projects. To get started building .NET Core 2.1 projects in Visual Studio,
- Make sure Visual Studio is closed
- Download and install the .NET Core 2.1 Preview 2 SDK
You’ll now see ASP.NET Core 2.1 as an option in the One ASP.NET dialog
If you are working with a Console Application or Class Library, you’ll need to create the project and then open the project’s property page and change the Target framework to “.NET Core 2.1”
Unit Testing Improvements
- The Test Explorer has undergone more performance improvements which results smoother scrolling and faster updating of the test list for large solutions.
- We’ve also improved the ability to understand what is happening during test runs. When a test run is in progress, a progress ring appears next to tests that are currently executing, and a clock icon appears for tests that are pending execution.
Productivity Improvements
Each release we’ve been working to add more and more refactorings and code fixes to make you productive. In 15.7 Preview 4, invoke Quick Actions and Refactorings (Ctrl+. or Alt+Enter) to use:
- Convert for-loop-to-foreach (and vice versa)
- Make private field readonly
- Toggle between var and the explicit type (without code style enforcement)
To learn more about productivity features see our Visual Studio 2017 Productivity Guide for .NET Developers.
C# 7.3
15.7 also brings the newest incremental update to C#, 7.3. C# 7.3 features are:
- System.Enum, System.Delegate and unmanaged constraints
- Ref local re-assignment: Ref locals and ref parameters can now be reassigned with the ref assignment operator (= ref)
- Stackalloc initializers: Stack-allocated arrays can now be initialized, for example Span<int> x = stackalloc[] { 1, 2, 3 }
- Indexing movable fixed buffers: Fixed buffers can be indexed into without first being pinned
- Custom fixed statement: Types that implement a suitable GetPinnableReference can be used in a fixed statement
- Improved overload candidates: Some overload resolution candidates can be ruled out early, thus reducing ambiguities
- Expression variables in initializers and queries: Expression variables like out var and pattern variables are allowed in field initializers, constructor initializers, and LINQ queries
- Tuple comparison: Tuples can now be compared with == and !=
- Attributes on backing fields: Allows [field: …] attributes on an auto-implemented property to target its backing field
To use C# 7.3 features in your project:
- Open your project’s property page (Project -> [Project Name] Properties…)
- Choose the “Build” tab
- Click the “Advanced…” button on the bottom right
- Change the “Language version” dropdown to “C# latest minor version (latest)”. This setting will enable your project to use the latest C# features available to the version of Visual Studio you are in without needing to change it again in the future. If you prefer, to you can pick a specific version from the list.
F# improvements
15.7 also includes several improvements to F# and F# tooling in Visual Studio.
- Type Providers are now enabled for .NET Core 2.1. To try it out, we recommend using FSharp.Data version 3.0.0-beta, which has been updated to use the new Type Provider infrastructure.
- .NET SDK projects can now generate an F# AssmeblyInfo file from project properties.
- Various smaller bugs in file ordering for .NET SDK projects have been fixed, including initial ordering when pasting a file into a folder.
- Toggles for outlining and Structured Guidelines are now available in the Text Editor > F# > Advanced options page.
- Improvements in editor responsiveness have been made, including ensuring that error diagnostics always appear before other diagnostic information (e.g., unused value analysis)
- Efforts to reduce memory usage of the F# tools have been made in partnership with the open source community, with much of the improvements available in this release.
Finally, templates for ASP.NET Core projects in F# are coming soon, targeted for the RTW release of VS 2017 15.7.
Azure Key Vault support in Connected Services
We have simplified the process to manage your project’s secrets with the ability to create and add a Key Vault to your project as a connected service. The Azure Key Vault provides a secure location to safeguard keys and other secrets used by applications so that they do not get shared unintentionally. Adding a Key Vault through Connected Services will:
- Provide Key Vault support for ASP.NET and ASP.NET Core applications
- Automatically add configuration to access your Key Vault through your project
- Add the required Nuget packages to your project
- Allow you to access, add, edit, and remove your secrets and permissions through the Azure portal
To get started:
- Double click on the “Connected Services” node in Solution Explorer in your ASP.Net or ASP.Net Core application.
- Click on “Secure Secrets with Azure Key Vault”.
- When the Key Vault tab opens, select the Subscription that you would like your Key Vault to be associated with and click the “Add” button on the bottom left. By default Visual Studio will create a Key Vault with a unique name.
Tip: If you would like to use an existing Key Vault, change location settings, resource group, or pricing tiers from the preselected values, you can click on the ‘Edit’ link next to Key Vault - Once the Key Vault has been added, you will be able to manage secrets and permissions with the links on the right.
Library Manager
Library Manager (“LibMan” for short) is Microsoft’s new client-side static content management system for web projects. Designed as a replacement for Bower and npm, LibMan helps users find and fetch library files from an external source (like CDNJS) or from any file system library catalogue.
To get started, right-click a web project from Solution Explorer and choose “Manage Client-side Libraries…”. This creates and opens the LibMan configuration file (libman.json) with some default content. Update the “libraries” section to add library files to your project. This example adds some jQuery files to the wwwroot/lib directory.
For more details, see Library Manager: Client-side content management for web apps.
Azure Publishing Improvements
We also made several improvements for when publishing applications from Visual Studio, including:
- Ability to configure publish settings for ASP.NET Core apps before you create the profile or publish (e.g. whether to publish as a framework-dependent or self-contained deployment)
- Ability to create Azure Storage Accounts and automatically store connection string
- Automatic enablement of Managed Service Identity in new Azure App Services
For more details, see our Publish improvements in Visual Studio 2017 15.7 post on the Web Developer blog.
Conclusion
If you haven’t installed a Visual Studio preview yet, it’s worth noting that they can be installed side by side with your existing stable installations of Visual Studio 2017, so you can try the previews out, and then go back to the stable channel for your regular work. So, we hope that you’ll take the time to install the Visual Studio 2017 15.7 Preview 4 update and let us know what you think. You can either use the built-in feedback tools in Visual Studio 2017 or let us know what you think below in the comments section.