Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to net6.0 on Windows #154

Merged
merged 11 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
source-url: https://office.pkgs.visualstudio.com/DefaultCollection/_packaging/Office/nuget/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.ADO_TOKEN }}

- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
Expand All @@ -37,9 +27,9 @@ jobs:

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
9 changes: 1 addition & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
source-url: https://office.pkgs.visualstudio.com/DefaultCollection/_packaging/Office/nuget/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.ADO_TOKEN }}
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
Expand Down Expand Up @@ -175,7 +168,7 @@ jobs:
with:
name: azureauth-${{ github.event.inputs.version }}-osx-arm64.tar.gz
path: azureauth-${{ github.event.inputs.version }}-osx-arm64.tar.gz

release:
runs-on: ubuntu-latest
needs: [package]
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# Unreleased

### Changed
- Upgrade the Windows build to use net6 now that net5 has reached end of life.

## [0.5.4] - 2022-09-29
### Fixed
- Enable IWA authmode when interactive authentication is disabled.
Expand All @@ -15,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.5.2] - 2022-09-28
### Fixed
- Option `--resource` is not needed if option `--scope` is provided.
- Refactoring IWA AuthFlow to call GetTokenIWA when we have a MsalUiRequiredException
- Refactoring IWA AuthFlow to call GetTokenIWA when we have a MsalUiRequiredException

## [0.5.1] - 2022-09-08
### Fixed
Expand Down
42 changes: 42 additions & 0 deletions bin/mac_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Fail on any failed commands
set -e

GIT_DIR="$(git rev-parse --show-toplevel)"
DIST="$GIT_DIR/dist"

# Clean Up existing dist.
rm -rf "$DIST"

# This block stolen from our src/install.sh
#------------------------------------------
os_info="$(uname -a)"
os_name="$(echo $os_info | cut -d ' ' -f1)"
case "${os_name}" in
Darwin)
name="${name}-osx"
arch="$(echo $os_info | rev | cut -d ' ' -f1 | rev)"

case "${arch}" in
arm64)
runtime="osx-arm64"
;;
x86_64)
runtime="osx-x64"
;;
*)
error "Unsupported architecture '${arch}'"
exit 1
;;
esac
;;
*)
error "Unsupported OS '${os_name}'"
exit 1
;;
esac
#------------------------------------------

# Publish
dotnet publish "$GIT_DIR/src/AzureAuth/AzureAuth.csproj" --self-contained true -r "$runtime" -c release -o $DIST $*
4 changes: 4 additions & 0 deletions bin/win_publish.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ECHO OFF

rmdir /S /Q %~dp0\dist
dotnet publish %~dp0\..\src\AzureAuth\AzureAuth.csproj --self-contained true -r win10-x64 -c release -o %~dp0\..\dist %*
4 changes: 2 additions & 2 deletions src/AzureAuth.Test/AzureAuth.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<TargetFramework>net5.0-windows10.0.17763.0</TargetFramework>
<SupportedOSPlatformVersion>7</SupportedOSPlatformVersion>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<DefineConstants>PlatformWindows</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
Expand Down
11 changes: 9 additions & 2 deletions src/AzureAuth/AzureAuth.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<TargetFramework>net5.0-windows10.0.17763.0</TargetFramework>
<SupportedOSPlatformVersion>7</SupportedOSPlatformVersion>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<DefineConstants>PlatformWindows</DefineConstants>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
Expand All @@ -14,6 +14,7 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<!-- Release configuration -->
<PropertyGroup Condition="'$(Configuration)'=='release'">
<PublishReadyToRun>true</PublishReadyToRun>
<PublishReadyToRunShowWarnings>true</PublishReadyToRunShowWarnings>
Expand Down Expand Up @@ -54,4 +55,10 @@
<ProjectReference Include="..\MSALWrapper\MSALWrapper.csproj" />
</ItemGroup>

<!-- Assemblies we need to manually mark as roots so they are not trimmed. -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<!-- Needed for Web mode on Windows -->
<TrimmerRootAssembly Include="System.Private.CoreLib" />
<TrimmerRootAssembly Include="WinRT.Runtime" />
</ItemGroup>
</Project>
7 changes: 2 additions & 5 deletions src/MSALWrapper/AuthFlow/Broker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

namespace Microsoft.Authentication.MSALWrapper.AuthFlow
{
#if NET472
using Microsoft.Identity.Client.Desktop;
#endif
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -86,8 +83,8 @@ private enum GetAncestorFlags
public async Task<AuthFlowResult> GetTokenAsync()
{
IAccount account = await this.pcaWrapper.TryToGetCachedAccountAsync(this.preferredDomain)
?? Identity.Client.PublicClientApplication.OperatingSystemAccount;
this.logger.LogDebug($"Using cached account '{account.Username}'");
?? PublicClientApplication.OperatingSystemAccount;
this.logger.LogDebug($"Using cached account '{account?.Username}'");

try
{
Expand Down
3 changes: 0 additions & 3 deletions src/MSALWrapper/AuthFlow/DeviceCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

namespace Microsoft.Authentication.MSALWrapper.AuthFlow
{
#if NET472
using Microsoft.Identity.Client.Desktop;
#endif
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand Down
3 changes: 0 additions & 3 deletions src/MSALWrapper/AuthFlow/Web.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

namespace Microsoft.Authentication.MSALWrapper.AuthFlow
{
#if NET472
using Microsoft.Identity.Client.Desktop;
#endif
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand Down
24 changes: 18 additions & 6 deletions src/MSALWrapper/MSALWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<DefineConstants>PlatformWindows</DefineConstants>
</PropertyGroup>
Expand All @@ -31,20 +31,32 @@
<AdditionalFiles Include="..\stylecop\stylecop.json" Link="stylecop.json" />
<Compile Include="..\stylecop\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.4" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.43.1" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.19.6" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.16.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<PackageReference Include="Microsoft.Identity.Client.Desktop" Version="4.43.1" />
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows')) == false">
<!-- Not Windows: simple package reference -->
<PackageReference Include="Microsoft.Identity.Client" Version="4.43.1" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<!-- Windows: Explicitly continue using the net5 version of MSAL since there is no net6 target yet -->
<!-- https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/3682 -->
<PackageReference Include="Microsoft.Identity.Client" GeneratePathProperty="true">
<Version>4.43.1</Version>
</PackageReference>

<Reference Include="Microsoft.Identity.Client">
<HintPath>$(PkgPMicrosoft_Identity_Client)\lib\net5.0-windows10.0.17763\Microsoft.Identity.Client.dll</HintPath>
</Reference>
</ItemGroup>

</Project>