-
Notifications
You must be signed in to change notification settings - Fork 211
ADAL .NET Build & Run
This is documentation about how to build an run the project. I wrote this because I had a lot of problems building the project (it is not the obvious build an run in visual studio) and I would figure that somebody else would have the same problems.
Before you build and run you will need a set of SDK's and tools installed on your box. You can see the pre-requisites here
Please click here to view the the Visual Studio 2017 required components.
From the Visual Studio 2017 Developer Prompt:
-
NuGet restore packages
msbuild /t:restore Combined.NoWinRT.sln -
Disable strong name validation for the entire box or for specific assemblies:
sn.exe -Vr * -
Build (can also be done from VS)
msbuild Combined.NoWinRT.sln
Troubleshooting: if you get messages related to Designer.cs not present, try to build in VS 2017 as well
Important: At this point in time all tools has to be run as Admin.
To build targets for Xamarin Android (MonoAnroid7), Xamarin iOS (Xamarin.iOS10), Windows (net45), UWP (win81, netstandard1.1;netstandard1.3) you will need VS2017 (latest update). See also prerequisites for additional details.
- Open the VS2017 Developer Command Prompt and navigate to the folder where you have the GitHub project.
- Restore packages using the
restore.cmdscript. - Build using the
buildVS2017.cmdscript. (This only builds the core components and the unit tests) - To build everything run the
buildAll.cmdscript (This script also does the strongnaming required to run and build the unit tests and the sample apps) - You can run the
strongname.cmdto ensure you have strong naming disabled for your dev box. This is required to run tests and sample apps with bits that are not signed.
- Note:
build.cmdcallsbuildVS2017.cmd.
Packaging MSAL is done manually, by laying out the assemblies and the nuspec file. This is because the new way of packaging (msbuild /t:pack) does not yet support the scenario of packaging 2 assemblies (see https://github.com/NuGet/Home/issues/3891)
- Make sure you have built MSAL in release mode. When building, you can pass extra params that control assembly versioning: /p:CoreSemVer=1.2.3-internal /p:MsalClientSemVer=4.5.7-beta2
- Layout the assemblies and the nuspec file
msbuild msal/src/Microsoft.Identity.Client/Microsoft.Identity.Client.csproj /t:LayoutNuGet /p:NugetPackageRootFolder=<layout dir> - Package using nuget.exe (the tool has to be downloaded)
nuget pack <layout dir> -Properties Configuration=Release;version=<package version> -Symbols
- Make sure you have built ADAL in release mode. When building, you can pass extra params that control versioning /p:AdalClientSemVer=1.0.0 /p:CoreSemVer=2.1.1-rc
- Layout the assemblies and the nuspec file
msbuild adal\src\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.csproj /t:LayoutNuGet /p:NugetPackageRootFolder=<layout dir> - Package using nuget.exe (the tool has to be downloaded)
nuget pack <layout dir> -Properties Configuration=Release;version=<package version> -Symbols
- First open the Developer command prompt as administrator
- Change the branch to adalv3/dev
- Run the following command:
msbuild Adal.net.nowinrt.sln /t:restore /p:configuration=release- this will restore the nuget packages needed for the project. - Now run
msbuild Adal.net.nowinrt.sln /t:build /p:configuration=release- this will build the project. - Then you can build it inside visual studio no problems.
I got all the info from the following issue.
When you try to run the project, you will get the following exception: System.IO.FileLoadException: 'Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)'
To fix this follow these steps
- First open the Developer command prompt as administrator
- Go to the bin/debug folder of the selected test project.
- Run the following command to fix this dll issue: sn.exe -Vr Microsoft.IdentityModel.Clients.ActiveDirectory.dll
- Now you can run the project!
I got all the info from the following issue.
The Android Emulator now supports Hyper-V as well as HAXM
- Home
- Why use ADAL.NET?
- Register your app with AAD
- AuthenticationContext
- Acquiring Tokens
- Calling a protected API
- Acquiring a token interactively
- Acquiring tokens silently
- Using Device Code Flow
- Using Embedded Webview and System Browser in ADAL.NET and MSAL.NET
- With no user
- In the name of a user
- on behalf of (Service to service calls)
- by authorization code (Web Apps)
- Use async controller actions
- Exception types
- using Broker on iOS and Android
- Logging
- Token Cache serialization
- User management
- Using ADAL with a proxy
- Authentication context in multi-tenant scenarios
- Troubleshooting MFA in a WebApp or Web API
- Provide your own HttpClient
- iOS Keychain Access