Skip to content

Build and Test

Aisha Wang edited this page Apr 13, 2020 · 24 revisions

Fast build

MSAL .Net supports MANY target frameworks (seven!), but most of the time contributors are only interested in one. To get MSAL to build for all the frameworks, you'll need a pretty hefty Visual Studio 2019 installation plus several Windows SDKs. To workaround against this, open this file and comment out the targets you are not interested in.

Visual Studio gets a bit confused when you do this, so close it, go to a dev command line run msbuild /t:restore LibsAndSamples.sln. Reopen Visual Studio.

Feel free to unload all the projects in the solution except Microsoft.Identity.Client and the unit tests.

Full Visual Studio 2019 installation

  • Use Visual Studio Installer to update or add these workloads:

    • Web & Cloud
      • ASP.NET and web development
      • Azure development
    • Desktop & Mobile
      • .NET desktop development
      • Universal Windows Platform Development
      • Mobile Development with .NET
    • Other Toolsets
      • .NET Core cross-platform development
  • Android SDK level 28 (Pie) and Android SDK build tools are required. If these are not installed through the VS Installer, use the Android SDK Manager (Visual Studio > Tools > Android > Android SDK Manager…)

Visual Studio for Mac

MSAL is a multi-target library and at the time of writing, VS for Mac is not able to understand and layout this project correctly. You can still build from the command line.

Build

  1. Load LibsAndSamples.sln for a bigger solution with lots of apps that exercise MSAL. Load LibsNoSamples.sln for a small solution that has the library and the tests.
  2. Build in VS or via the command line with "msbuild /t:restore" and "msbuild"

Note: if you run into strong name validation issues, please log a bug. Workaround is to disable it on your dev box by running Admin Dev Prompt > sn -Vr *

Run tests

You won't be able to run the Integration test or Automation tests because they require access to a Microsoft KeyVault which is locked down. These tests will run as part of our DevOps pipelines though.

Run the unit tests from the assemblies:

  • Microsoft.Identity.Test.Unit.net45
  • Microsoft.Identity.Test.Unit.netcore

Package

From VS or from the command line if you wish to control the versioning:

msbuild <msal>.csproj /t:pack /p:MsalClientSemVer=1.2.3-preview

Command Line

Use msbuild commands - msbuild /t:restore and msbuild. Do not rely on dotnet command line because it is only for .Net Core, but this library has many other targets.

Note: To enable us to target Xamarin as well as .Net core, we took a dependency on the MsBuild SDK extras - https://github.com/onovotny/MSBuildSdkExtras See this issue about using dotnet

Getting started with MSAL.NET

Acquiring tokens

Web Apps / Web APIs / daemon apps

Desktop/Mobile apps

Advanced topics

FAQ

Other resources

Clone this wiki locally