Tag: Visual Studio

.NETDevelopmentVisual Studio

Centralizing NuGet Package Versions with Central Package Management

In my Running and Building Azure Functions with Modern .NET talk this week at the Mississauga .NET User Group, one of the topics that consistently gets a reaction from the audience is Central Package Management (CPM). Once I show people what it does, the reaction is almost always the same: “I didn’t know this existed — I need to go add this to all my solutions.”

This post is the written companion to that section of the talk. If you’ve ever dealt with the pain of keeping NuGet package versions in sync across a large solution, CPM is going to be immediately relevant to you.

What is Central Package Management?

Central Package Management is a built-in .NET feature that lets you define all NuGet package versions in a single place — a Directory.Packages.props file at the solution root — rather than scattering Version attributes across individual .csproj files.

Here’s a simple example of what that file looks like:

<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

And in your individual .csproj files, you simply reference the package without a version:

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" />
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>

The version is automatically resolved from the central file. Clean, simple, and immediately obvious what version you’re on when you look at the central file.

Why This Matters

In a solution with many projects, keeping package versions in sync manually is error-prone. You end up with Project A on Newtonsoft.Json 13.0.1 and Project B on 13.0.3 without anyone really noticing until a subtle runtime difference bites you. CPM solves this by making version drift impossible — there’s one place to look and one place to change.

Benefits at a glance:

  • Single source of truth for all package versions in the solution
  • Eliminates version drift across projects
  • Cleaner .csproj files — no version attributes cluttering your package references
  • Supports both direct and transitive dependency version control

Manually Migrate an Existing Solution to CPM

If you already have a solution with a bunch of projects, migrating to CPM is straightforward but can be tedious to do by hand across many .csproj files. Here’s the approach:

Step 1: Create Directory.Packages.props

At the root of your solution, create a Directory.Packages.props file with ManagePackageVersionsCentrally set to true and consolidate all your package versions as <PackageVersion> entries:

<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="PackageName" Version="x.y.z" />
<!-- add all packages here -->
</ItemGroup>
</Project>

Step 2: Remove Versions from Project Files

Strip the Version attribute from every <PackageReference> in your .csproj files. If you have many projects, do this with the CentralisedPackageConverter CLI tool (covered below) — don’t do it by hand.

Step 3: Validate and Build

Build your solution and confirm everything resolves correctly. Pay attention to any packages that may have conflicting versions across projects — those will need a conscious decision about which version to standardize on.

This is great, but there must be a better way. Let’s take a look at a community tool that automates this process.

Using the CentralisedPackageConverter CLI Tool

The best way to handle the migration for an existing solution is the CentralisedPackageConverter CLI tool, which automates the tedious parts:

# Install the tool globally
dotnet tool install CentralisedPackageConverter --global
# Run the conversion against your solution folder
central-pkg-converter /path/to/your/solution/folder

The tool will:

  • Scan all .csproj files in the solution
  • Generate a Directory.Packages.props with all discovered versions
  • Remove version attributes from individual project files

I highly recommend using this over a manual migration. It’s fast and reduces the chance of missing something.

Let’s try this out.

We now have a Directory.Packages.props with all discovered versions:

And if we look in our project files, the versions are removed:

Advanced Features


Once you’re on CPM, there are a few additional capabilities worth knowing about.

Overriding Versions per Project

There are situations where a specific project needs a different version of a package than the rest of the solution — say, a legacy integration that can’t move to the latest version yet. CPM handles this with VersionOverride in the individual project file:

<PackageReference Include="SomePackage" VersionOverride="1.2.3" />

Use this sparingly. Its presence in a project file is a signal that something needs attention.

Different Versions per Target Framework

If you have a multi-targeted project, you can conditionally apply different versions by target framework using standard MSBuild conditions within Directory.Packages.props:

<PackageVersion Include="SomePackage" Version="2.0.0" Condition="'$(TargetFramework)' == 'net10.0'" />
<PackageVersion Include="SomePackage" Version="1.5.0" Condition="'$(TargetFramework)' == 'net8.0'" />

Transitive Pinning

This one quietly solves a very real problem. Version drift caused by transitive dependencies — packages your packages depend on — is easy to miss and can cause subtle compatibility issues. CPM supports pinning transitive dependencies centrally, so you stay in control of the full dependency graph, not just the packages you reference directly.

Summary

Central Package Management is one of those features that makes you wonder how you managed without it once you adopt it. If you’re running a multi-project .NET solution, this is a straightforward improvement with immediate payoff — consistent package versions, cleaner project files, and a single place to make dependency updates.

Enjoy!

References

.NETDevelopmentVisual Studio

The New .slnx Solution File Format — A Better Way to Manage Visual Studio Solutions

In my Running and Building Azure Functions with Modern .NET talk this week at the Mississauga .NET User Group, I closed out the .NET tooling section with a quick look at the new .slnx solution file format. It’s one of those changes that doesn’t get a lot of attention but makes day-to-day .NET development noticeably more pleasant — especially if you’ve ever dealt with a gnarly merge conflict in a .sln file.

This post walks through what .slnx is, why it’s better than the traditional .sln format, and how to migrate.

What’s Wrong with .sln?

If you’ve worked with Visual Studio solutions for any length of time, you’ve almost certainly encountered the pain points with .sln files. They’ve been around since the early 2000s and they work — but they come with a set of frustrations that have never really been addressed:

  • They’re nearly unreadable — the format uses GUIDs and magic identifiers that aren’t intuitive at all
  • Merging is painful — a .sln file being touched by two developers at the same time is a merge conflict waiting to happen
  • Tooling struggles with them — custom scripts or CI tooling that needs to parse a .sln file often resorts to fragile string manipulation

Here’s a snippet of a traditional .sln to illustrate:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyFunctions", "src\MyFunctions\MyFunctions.csproj", "{A1B2C3D4-E5F6-1234-ABCD-EF0123456789}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
EndGlobal

Not exactly something you want to review in a pull request.

Introducing .slnx

The .slnx format is a new, XML-based solution file format introduced in the .NET 9.0.200 SDK. It addresses all of the above problems:

<Solution>
<Project Path="src/MyFunctions/MyFunctions.csproj" />
<Project Path="src/MyFunctions.Tests/MyFunctions.Tests.csproj" />
</Solution>

That’s it. No GUIDs. No magic identifiers. No indecipherable global sections. Just a clean XML file that clearly describes what’s in the solution.

Why It’s Better

Better readability — the XML structure is immediately understandable. Any developer can open a .slnx file and know exactly what’s in the solution without reverse-engineering the format.

Simplified merging — because it’s XML with simple, meaningful elements rather than a blob of GUIDs and platform strings, merge conflicts in .slnx files are much easier to resolve. In most cases, merging two developers’ changes to the solution file becomes a trivial diff.

Easier parsing — if you write build scripts, CI automation, or any tooling that needs to know what projects are in a solution, parsing a .slnx file is now just standard XML parsing. Reliable and straightforward.

Converting from .sln to .slnx

The .NET CLI makes the migration trivially easy. From your solution folder, run:

dotnet sln migrate

From Visual Studio 2022

Go to File and save your solution file as…and select the XML Solution File format.

Before You Migrate

A few things to check before running the migration:

Commit your existing .sln file to source control before converting — gives you a clean rollback point if anything looks off.

Make sure your entire team is on a compatible toolchain — .NET SDK 9.0.200 or later, and a recent version of Visual Studio 2022 or Visual Studio 2026. Anyone still on an older setup won’t be able to open the solution until they update.

If you have CI/CD pipelines that parse or manipulate the .sln file directly (not uncommon in larger teams), update those to handle .slnx before you switch over.

Should You Migrate?

My honest take is yes, especially for new solutions. For existing solutions, there’s no urgency — your .sln files aren’t going anywhere — but if you’re already bumping into merge conflict pain or your solution file is getting unwieldy, the migration is trivially easy, and the payoff is immediate.

For new projects, I’d start with .slnx from day one. In fact if you’ve migrated over to Visual Studio 2026 it’s now the default options. It’s the better format, it’s supported by all current tooling, and you’ll thank yourself later.

Summary

The .slnx solution file format is a small change with a noticeably positive impact on day-to-day .NET development. XML-based, human-readable, merge-friendly, and trivially easy to adopt — there’s very little reason not to switch. Combined with Central Package Management and the new Azure Functions FunctionsApplication builder, these three improvements together represent a meaningfully cleaner modern .NET development experience.

Enjoy!

References

Azure FunctionsVisual Studio

Azurite emulator cannot be started

After installing Visual Studio 2022 and working with Azure Functions I noticed that a new storage emulator is being used called Azurite.

Azurite is an open source Azure Storage API compatible server (emulator). Based on Node.js, Azurite provides cross platform experiences for customers wanting to try Azure Storage easily in a local environment. Azurite simulates most of the commands supported by Azure Storage with minimal dependencies.

https://github.com/Azure/Azurite

This seemed to replace the old Azure Storage Emulator you would run previously when doing local development. I quickly came across an issue where the Azurite emulator cannot be started because port 10000 is already in use. This is also applied to ports 10001 and 10002 which it uses. Here are the contents of the Service Dependencies from the Visual Studio 2022 Output pane:

Ensuring Azure Functions Core Tools are up to date. This may take a few minutes...
Azure Functions Core Tools are up to date.
DotNetCore31-FunctionApp: Azurite emulator cannot be started because port 10000 is already in use. Another instance of the Azurite emulator or Azure Storage emulator might be already running on your machine.
DotNetCore31-FunctionApp: We detected that Azure Storage emulator is running on your machine. The Azure Storage emulator is now deprecated. Microsoft recommends that you use the Azurite emulator for local development with Azure Storage. Follow the directions in the link 'https://go.microsoft.com/fwlink/?LinkID=2167087' to install and run Azurite emulator.
Unable to start dependency 'functions.storage1'.
Ensuring Azure Functions Core Tools are up to date. This may take a few minutes...
Azure Functions Core Tools are up to date.
Ensuring Azure Functions Core Tools are up to date. This may take a few minutes...
Azure Functions Core Tools are up to date.
DotNetCore31-FunctionApp: Azurite emulator cannot be started because port 10000 is already in use. Another instance of the Azurite emulator or Azure Storage emulator might be already running on your machine.
DotNetCore31-FunctionApp: We detected that Azure Storage emulator is running on your machine. The Azure Storage emulator is now deprecated. Microsoft recommends that you use the Azurite emulator for local development with Azure Storage. Follow the directions in the link 'https://go.microsoft.com/fwlink/?LinkID=2167087' to install and run Azurite emulator.
Unable to start dependency 'storage1'.
DotNetCore31-FunctionApp: Azurite emulator cannot be started because port 10000 is already in use. Another instance of the Azurite emulator or Azure Storage emulator might be already running on your machine.
DotNetCore31-FunctionApp: We detected that Azure Storage emulator is running on your machine. The Azure Storage emulator is now deprecated. Microsoft recommends that you use the Azurite emulator for local development with Azure Storage. Follow the directions in the link 'https://go.microsoft.com/fwlink/?LinkID=2167087' to install and run Azurite emulator.
Unable to start dependency 'storage1'.

Let’s drop into Windows Terminal and take a look at what process is using that port:

Get-Process -Id (Get-NetTCPConnection -LocalPort 10002).OwningProcess

After stopping the Node process and re-running Azurite (I restarted Visual Studio) we can see everything starts up as expected:

Ensuring Azure Functions Core Tools are up to date. This may take a few minutes...
Azure Functions Core Tools are up to date.
DotNetCore31-FunctionApp: azurite.cmd --location "C:\Users\ccampbell\AppData\Local\Temp\Azurite" --debug "C:\Users\ccampbell\AppData\Local\Temp\Azurite\debug.log"
DotNetCore31-FunctionApp: Azurite Blob service is starting at http://127.0.0.1:10000
DotNetCore31-FunctionApp: Azurite Blob service is successfully listening at http://127.0.0.1:10000
DotNetCore31-FunctionApp: Azurite Queue service is starting at http://127.0.0.1:10001
DotNetCore31-FunctionApp: Azurite Queue service is successfully listening at http://127.0.0.1:10001
DotNetCore31-FunctionApp: Azurite Table service is starting at http://127.0.0.1:10002
DotNetCore31-FunctionApp: Azurite Table service is successfully listening at http://127.0.0.1:10002

This was not a great experience on the first day I started to use Visual Studio 2022 with Azure Functions as I had to go off and figure out why the Azure emulator could not be started instead of just working on my application. You can go and change the default ports ft you like which is mentioned in the documentation. For more information on Azurite check out the docs on their GitHub repository.

I hope this helps with anyone new to the Azurite emulator in Visual Studio 2022.

Enjoy!

References

https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio

https://github.com/Azure/Azurite

AIAzureDevOps

Writing code and having fun with Rock, Paper, Scissors, Lizard, Spock | Azure Friday

In this episode of Azure Friday, Isaac Levin joins Scott Hanselman to talk about building highly scalable applications and having fun with the Rock, Paper, Scissors, Lizard, Spock sample application. Rock, Paper, Scissors, Lizard, Spock is a multi-language application built with Visual Studio and Visual Studio Code, deployed with GitHub Actions and running on Azure Kubernetes Service (AKS). It also uses Machine Learning and Azure Cognitive Services (Custom Vision API). Languages used in this application include .NET, Node.js, Python, Java, and PHP.

[0:01:55]

Source: Channel 9

Resources

DevelopmentEvents

Discover the world of .NET – .NET Conf 2018

Discover the world of .NET for free this September 12-14, 2018 by attending the .NET Conf virtual developer event, which is co-organized by Microsoft and the .NET community. Over the course of the three days, you will have a wide selection of live sessions from .NET community and the .NET product teams. This is a great chance for you to learn, ask questions and get inspired for your next great project.

You will learn to build for web, mobile, desktop, games, services, libraries and more for a variety of platforms and devices all with .NET. We have sessions for everyone, no matter if you are just beginning or are a seasoned engineer. We’ll have presentations on .NET Core and ASP.NET Core, C#, F#, Azure, Visual Studio, Xamarin, and much more.

Join your fellow developers in a city near you, and learn more about the world of .NET, Azure, and Xamarin. To watch the sessions from last year, take a look at the 2017 sessions on demand from Channel 9.

Agenda

Day 1 – September 12

8:00 – 9:30
Keynote broadcasted from Microsoft Channel 9 Studios

9:30 – 17:00
Sessions broadcasted from Microsoft Channel 9 Studios

17:00 – 18:30
Virtual Attendee Party! Engage with our partners on Twitter and win prizes!

Day 2 – September 13

9:00 – 17:00
Sessions broadcasted from Microsoft Channel 9 Studios

17:00 – 23:59
Community Sessions in local languages & time zones around the world

Day 3 – September 14

0:00 – 17:00
Community Sessions in local languages & time zones around the world

All times listed are in Pacific Daylight Time (UTC -7).

Attend a Local .NET Conf

In addition to the three day virtual event being held from September 12-14, there will also be some local events you can attend. Take a look at this page for locations and to register. In Canada we will have 2 local events in Vancouver BC and Mississauga ON.

September 26, 2018
Vancouver, BC, Canada
Register Here

October 25, 2018
Mississauga, Ontario, Canada
Register Here

Run your own local event

If you’re interested in running your own .NET Conf take a look at this link for details.

Enjoy!

References

https://www.dotnetconf.net

https://www.dotnetconf.net/local-events/

https://github.com/dotnet-presentations/dotnetconf2018

DevelopmentMobile

Troubleshooting the installation of Xamarin Android Device Manager

UPDATED: Feb 26 2018 (later that day)

This post is a follow up to how I got Xamarin Android Device Manager up and running on Windows. Please read the Xamarin Developer guide first which explains how to install and use the Xamarin Android Device Manager for Visual Studio on Windows (or for Mac). Please keep in mind that at the time of this post the Xamarin Android Device Manager is still in preview.

For me I’m running the latest version of Visual Studio 2017 (15.5.7) and I already had the Xamarin components installed and working. Up until now I wasn’t really using the Android emulators for any Xamarin development as I was more focused on iOS and Windows. However now I have a need to and so I decided to try out the new Xamarin Android Device manager. Why you might ask? Well as of Android SDK Tools version 26.0.1, Google has removed support for their UI-based AVD and SDK managers in favor of their new CLI (Command Line Interface) tools.

After having installed the latest version of the Xamarin Device Manager installer for Windows, I ran it from the Start menu with Administrator privileges like so:

sshot-360

And this is the error I get:

sshot-360-1

I ran through the troubleshooting section section and the issue is that I was missing the Android SDK (requires 26 or higher). Perhaps a one of the latest Visual Studio updates caused this issue because now none of the Android tooling like device or emulator are working. Perhaps installing the Xamarin Device Manager broke it, I’m not sure but it’s broken. The only way I was able to resolve this was to run the Visual Studio Installer and uninstalled the the Xamarin SDK Manager and re-install it. Here is what I did.

My Solution to Fixing Missing Android SDK

1. Run Visual Studio Installer and then click on the Modify button:

image

2. Now go to the Individual components tab and Remove Xamarin SDK Manager and then click on the Modify button to apply the changes. Take notice of the amount of disk space that will be freed up. For me it was 113 MB.

image

3. Now do steps 1 and 2 again but this time add back the Xamarin SDK Manager and then notice the amount of disk space required for these changes…for me it was 1.4 GB, obviously something screwed up and I was missing a great deal. Now apply the changes by clicking on the Modify button.

Now when you run the Xamarin Android Device Manager from the start menu (with administrator rights) it should load up as expected. Now if you are like me and don’t have the latest Android SDK Tools, then you are then presented with the following dialog prompting you to download them from the Xamarin Android SDKs and Tools manager:

sshot-361

When the Xamarin Android SDK and Tools manager opens, review the SDK platforms you want installed and then click over to the Tools tab:

sshot-362

In the Tools tab, expand the Android SDK Tools selection and change the selected tooling to the current version which is 26.1.1 and then click on the Apply Changes button. If you’re just changing the Android SDK Tools, this should only take a couple min at most to apply. Once it’s done close down the Android SDKs and Tools manager.

sshot-363

Now go back to Visual Studio (re-run if you have it running already) and run the Android Emulator Manager from the Tools – > Android menu.

image

You will now be presented with the new Android Devices manager. When you first launch the Android Device Manager, it presents a screen that displays all currently configured virtual devices. For each device, the Name, Operating System (Android API Level), CPU, Memory size, and screen resolution are displayed:

image

I then went on and added a new option for Android Oreo and when I tried to run it I got another error:

image

Now it looks like I need to install another tool, Intel’s HAXM which requires Hyper-V be disabled.

Summary

What seemed like a quick and easy update has turned into quite the adventure. It’s 2018…why can’t this be more simple!

Enjoy!

References

Channel 9 | The Xamarin Show: Snack Pack | The New Xamarin Android Device Manager

How to setup and create Android virtual devices using Xamarin Android Device Manager

Installing Xamarin.Android on Windows

Installation Instructions for Intel® Hardware Accelerated Execution Manager (Intel® HAXM) – Microsoft Windows*

Development

GitHub for Visual Studio now allows Pull Request Comments from IDE

0917vsm_github_vs

GitHub for Visual Studio 2.3 was recently released and it brought new functionality that now allows you to add pull request comments directly from the IDE.

To get started you  will need the latest version of GitHub Extension for Visual Studio. Next open up a pull request from the GitHub pane and while viewing a file you can click on the left gutter (see blue plus button) to add your feedback, all without leaving Visual Studio.

image

This functionality is still pretty limited but its a step in the right direction. I look forward to more GitHub online functionality making it’s way to this great extension.

Enjoy!

References

Inline comments in GitHub for Visual Studio

DevelopmentInfographics

Visual Studio 2017 Infographic – What’s New

Curious about what’s new in Visual Studio 2017? The Visual Studio team has released an infographic with all the new features. Take a look.

Enjoy!

VisualStudio2017_ProductLaunchPoster

Development

Visual Studio 2017 has Landed

Visual Studio 2017 is finally here and you can download now. Visual Studio 2017 enables you to be more productive for any application and on any platform.

If you download Visual Studio 2017 by March 14, you’ll get a 60-day access to Xamarin University which is a sweet deal.

What’s New

Visual Studio 2017 has a brand new installation experience which includes a minimal footprint for Visual Studio. Installation is quick (minutes not hours) and finally uninstalls cleanly. It’s also much easier to just install the features you want and need.

image

Quick Reference of New Features

For a full list of all new features, please take a look at the release notes.

Enjoy!

image

References

Visual Studio
Visual Studio 2017 Download
Visual Studio 2017 System Requirements
Visual Studio 2017 Release Notes

 

Development

Extended Strongly Typed Resource Generator for VS2013 and VS2015

Following up to a post I did in 2012 on ResXFileCodeGeneratorEx Update for VS2010, here are links to download this tool for Visual Studio 2015 and Visual Studio 2013:

Extension for Visual Studio 2015 can be found here:
https://visualstudiogallery.msdn.microsoft.com/f43d27fa-6bf7-4f3d-bf5e-3e716e63716b

Extension for Visual Studio 2013 can be found here:
https://visualstudiogallery.msdn.microsoft.com/16d24be3-6400-4a43-b946-766e41aca4bd

Enjoy!