Skip to main content Skip to main content Windows Experience Devices Windows Developer Microsoft Edge Windows Insider Microsoft 365 Microsoft 365 Azure Copilot Windows Surface Xbox Deals Small Business Support Windows Apps Outlook OneDrive Microsoft Teams OneNote Microsoft Edge Moving from Skype to Teams Computers Shop Xbox Accessories VR & mixed reality Certified Refurbished Trade-in for cash Xbox Game Pass Ultimate PC Game Pass Xbox games PC games Microsoft AI Microsoft Security Dynamics 365 Microsoft 365 for business Microsoft Power Platform Windows 365 Small Business Digital Sovereignty Azure Microsoft Developer Microsoft Learn Support for AI marketplace apps Microsoft Tech Community Microsoft Marketplace Marketplace Rewards Visual Studio Microsoft Rewards Free downloads & security Education Gift cards Licensing Unlocked stories View Sitemap
September 30, 2019
PC

Windows 10 WinRT API Packs released

With the announcement of the release of .NET Core 3.0, we are pleased to announce we have posted on nuget.org the released versions of the Windows 10 WinRT API Pack. The Windows 10 WinRT API Pack allows your WPF or Winforms application to quickly and easily access Windows functionality like Geolocation, Windows AI, Machine Learning, Bluetooth and much more. 

Accessing these APIs in your project is as simple as adding the NuGet to your project.

Getting Started

Step 1: Configure your project to support Package Reference 

Step 2: Add the Microsoft.Windows.SDK.Contracts NuGet package to your project 

  1. Open the NuGet Package Manager Console 
  2. Install the package that includes the Windows 10 Contracts you want to target. Currently the following are supported:

Windows 10 version 1803 

[code lang=”csharp”]

Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.17134.1000

[/code]

Windows 10 version 1809 

[code lang=”csharp”]

Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.17763.1000

[/code]

Windows 10 version 1903 

[code lang=”csharp”]

Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.18362.2005

[/code]

Step 3: Get coding 

By adding one of the above NuGet packages, you now have access to calling the Windows Runtime (WinRT) APIs in your project.  

For example, this snippet shows a WPF Message box displaying the latitude and longitude coordinates: 

[code lang=”csharp”]

private async void Button_Click(object sender, RoutedEventArgs e)
{
    var locator = new Windows.Devices.Geolocation.Geolocator();
    var location = await locator.GetGeopositionAsync();
    var position = location.Coordinate.Point.Position;
    var latlong = string.Format("lat:{0}, long:{1}", position.Latitude, position.Longitude);
    var result = MessageBox.Show(latlong);
}

[/code]

Many partners are already using these NuGet files. If you check out a project that is already using these NuGet packages, see the Microsoft.Toolkit.

Your Privacy Choices Opt-Out Icon Your Privacy Choices
Consumer Health Privacy Sitemap Contact Microsoft Privacy Manage cookies Terms of use Trademarks Safety & eco Recycling About our ads