Skip to content

Commit

Permalink
Drop netcoreapp3.1, add net7.0 support (Azure#32814)
Browse files Browse the repository at this point in the history
* Drop netcoreapp3.1, add net7.0 support

Resolves Azure#32596. With netcoreapp3.1 falling out of support soon, we're upgrading to net7.0, net6.0, and, on Windows, net461.

* Resolve PR comments and fix build break

* Tweak platform monikers

* Upgrade to .NET 7.0.101 SDK

Required for microsoft/vstest#4014 fix

* Drop unnecessary runtimes from .vsconfig

* Skip Monitor tests failing under net7.0

Relates to Azure#33403

* Resolve track 1 management plane issues on net7.0

* Resolve Key Vault issues after upgrade to net7.0

* Use different platform guard for management plane

* Resolve PR feedback
  • Loading branch information
heaths authored Jan 13, 2023
1 parent d35979d commit 0752525
Show file tree
Hide file tree
Showing 40 changed files with 144 additions and 110 deletions.
16 changes: 16 additions & 0 deletions .vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.Net.ComponentGroup.4.6.2-4.7.1.DeveloperTools",
"Microsoft.Net.Component.4.7.2.TargetingPack",
"Microsoft.Net.Component.4.6.1.TargetingPack",
"Microsoft.Net.Component.4.8.SDK",
"Microsoft.Component.MSBuild",
"Microsoft.NetCore.Component.DevelopmentTools",
"Microsoft.NetCore.Component.Runtime.7.0",
"Microsoft.NetCore.Component.Runtime.6.0",
"Microsoft.NetCore.Component.SDK",
"Microsoft.VisualStudio.Component.Git"
]
}
28 changes: 14 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

- Install Visual Studio 2022 (Community or higher) and make sure you have the latest updates (https://www.visualstudio.com/).
- Need at least .NET Framework 4.6.1 and 4.7 development tools
- Install the **.NET Core cross-platform development** workloads in VisualStudio
- Install **.NET Core 6.0.100 SDK** for your specific platform. (or a higher version within the 6.0.*** band) (https://dotnet.microsoft.com/download/dotnet-core/6.0)
- Install the **.NET cross-platform development** workloads in VisualStudio
- Install **.NET 7.0.100 SDK** for your specific platform. (or a higher version within the 7.0.*** band) (https://dotnet.microsoft.com/download/dotnet-core/7.0)
- Install the latest version of git (https://git-scm.com/downloads)
- Install [PowerShell](https://docs.microsoft.com/powershell/scripting/install/installing-powershell), version 6 or higher, if you plan to make public API changes or are working with generated code snippets.
- Install [NodeJS](https://nodejs.org/) (16.x.x) if you plan to use [C# code generation](https://github.com/Azure/autorest.csharp).
Expand Down Expand Up @@ -182,7 +182,7 @@ In some cases, you might want to test against the latest versions of the client

If you make public API changes or additions, the `eng\scripts\Export-API.ps1` script has to be run to update public API listings. This generates a file in the library's directory similar to the example found in `sdk\template\Azure.Template\api\Azure.Template.netstandard2.0.cs`.

Running the script for a project in `sdk\tables` would look like this:
Running the script for a project in `sdk\tables` would look like this:
```
eng\scripts\Export-API.ps1 tables
```
Expand All @@ -191,7 +191,7 @@ eng\scripts\Export-API.ps1 tables
If the specific client library has sample snippets in markdown format, they were most likely created with help of the `eng\scripts\Update-Snippets.ps1` script.
Any changes made to the snippet markdown should be done via updating the corresponding C# snippet code and subsequently running the script.

Running the script for a project, for example in `sdk\keyvault`, would look like this:
Running the script for a project, for example in `sdk\keyvault`, would look like this:
```
eng\scripts\Update-Snippets.ps1 keyvault
```
Expand All @@ -211,13 +211,13 @@ string ignored = "this code will not appear in the snippet markdown";

#endregion
```
will be mapped to any markdown file with a corresponding code region in the format below where the snippet names match:
will be mapped to any markdown file with a corresponding code region in the format below where the snippet names match:

**\`\`\`C# Snippet:\<snippetName>**

**\`\`\`**

See the following example of a [snippet C# file](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/tests/Samples/Sample01_HelloWorld.cs) and a [snippet markdown file](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample01a_HelloWorld.md).
See the following example of a [snippet C# file](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/tests/Samples/Sample01_HelloWorld.cs) and a [snippet markdown file](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample01a_HelloWorld.md).
Note that snippet names need to be globally unique under a given service directory.

Snippets also can be integrated into XML doc comments. For example:
Expand All @@ -238,7 +238,7 @@ For general information about samples, see the [Samples Guidelines](https://azur

## Updating Source on Build
You can run `eng\scripts\Export-API.ps1` and `eng\scripts\Update-Snippets.ps1` simultaneously as part of the build by setting as true either:
1. The property `UpdateSourceOnBuild`
1. The property `UpdateSourceOnBuild`
2. The Environment variable `AZURE_DEV_UPDATESOURCESONBUILD=true`

e.g.
Expand Down Expand Up @@ -329,7 +329,7 @@ As you can see in the example below, we want to use the `Azure.Data.Tables` vers

## Preparing a new library release

To prepare a package for release you should make use of `.\eng\common\scripts\Prepare-Release.ps1` script passing it appropriate arguments for the package intended for release. This script will correctly update the package version and changelog in the repo as well as update the DevOps release work items for that release.
To prepare a package for release you should make use of `.\eng\common\scripts\Prepare-Release.ps1` script passing it appropriate arguments for the package intended for release. This script will correctly update the package version and changelog in the repo as well as update the DevOps release work items for that release.

```
.\eng\common\scripts\Prepare-Release.ps1 <PackageName> [<ServiceDirectory>] [<ReleaseDate>] [-ReleaseTrackingOnly]
Expand Down Expand Up @@ -419,7 +419,7 @@ See [Data Plane Quick Start Tutorial](https://github.com/Azure/azure-sdk-for-net
{
private const ServiceVersion Latest = ServiceVersion.V2019_06_01;
internal static StorageManagementClientOptions Default { get; } = new StorageManagementClientOptions();
public StorageManagementClientOptions(ServiceVersion serviceVersion = Latest)
{
VersionString = serviceVersion switch
Expand All @@ -428,9 +428,9 @@ See [Data Plane Quick Start Tutorial](https://github.com/Azure/azure-sdk-for-net
_ => throw new ArgumentOutOfRangeException(nameof(serviceVersion))
};
}
internal string VersionString { get; }
public enum ServiceVersion
{
#pragma warning disable CA1707 // Identifiers should not contain underscores
Expand All @@ -449,7 +449,7 @@ See [Data Plane Quick Start Tutorial](https://github.com/Azure/azure-sdk-for-net
public FileSharesClient(string subscriptionId, TokenCredential tokenCredential): this(subscriptionId, tokenCredential, StorageManagementClientOptions.Default)
{
}
public FileSharesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options):
this(new ClientDiagnostics(options), ManagementClientPipeline.Build(options, tokenCredential), subscriptionId, apiVersion: options.VersionString)
{
Expand Down Expand Up @@ -520,8 +520,8 @@ Once all of the above steps are met, the following process will be followed:

| | Linux (Ubuntu 20.04) | MacOS 10.15 | Windows Server 2019 |
| ------------------------ | :------------------: | :---------: | :-----------------: |
| **.NET 6** | x | x | x |
| **.NET Core 3.1** | x | x | x |
| **.NET 7.0** | x | x | x |
| **.NET 6.0** | x | x | x |
| **.NET Framework 4.6.1** | | | x |

### Issues with Generated Code
Expand Down
4 changes: 2 additions & 2 deletions common/SmokeTests/SmokeTest/SmokeTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net461;net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;net461</TargetFrameworks>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>
Expand Down Expand Up @@ -38,7 +38,7 @@
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.1'))">
<!-- This package supports netcoreapp3.1 -->
<PackageReference Remove="Microsoft.Azure.WebPubSub.AspNetCore" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion doc/ApiDocGeneration/assets/docgen.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<Description>This is a dummy project used to restore nuget packages used for doc generation</Description>
<AssemblyTitle>Doc generation Packages</AssemblyTitle>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions doc/dev/Using-Mock-Test-Generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Below is a sample for mock testcase:

<div id="generate-mock-test"/>

# Generate Mock Test
# Generate Mock Test
The Mgmt mock tests can be generated by below steps:

1. Go to folder Azure.ResourceManager.xxx\tests
Expand Down Expand Up @@ -56,7 +56,7 @@ The Mgmt mock tests can be generated by below steps:
[USE autorest]
~~~
// clone autorest.csharp and build
> autorest --use=PATH_TO_AUTOREST.CSHARP\artifacts\bin\AutoRest.CSharp\Debug\netcoreapp3.1 autorest.tests.md --testmodeler={} --debug
> autorest --use=PATH_TO_AUTOREST.CSHARP\artifacts\bin\AutoRest.CSharp\Debug\net6.0 autorest.tests.md --testmodeler={} --debug
~~~
[or USE dotnet target]
Expand Down
2 changes: 1 addition & 1 deletion eng/Directory.Build.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<PropertyGroup Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsSamplesProject)' == 'true' or '$(IsPerfProject)' == 'true' or '$(IsStressProject)' == 'true'">
<IsPackable>false</IsPackable>
<!-- List newest targets first so that recordings are made with latest, running tests from editor runs latest, etc. -->
<RequiredTargetFrameworks>net6.0;netcoreapp3.1</RequiredTargetFrameworks>
<RequiredTargetFrameworks>net7.0;net6.0</RequiredTargetFrameworks>
<!-- Also test net461 on Windows. -->
<RequiredTargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(RequiredTargetFrameworks);net461</RequiredTargetFrameworks>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions eng/mgmt/AzSdk.test.reference.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(RepoEngPath)\..\sdk\mgmtcommon\TestFramework\Microsoft.Azure.Test.HttpRecorder\Microsoft.Azure.Test.HttpRecorder.csproj" />
Expand All @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(RepoEngPath)\mgmt\DisableTestRunParallel.cs" Link="DisableTestRunParallel.cs" />
<ItemGroup>
<Compile Include="$(RepoEngPath)\mgmt\DisableTestRunParallel.cs" Link="DisableTestRunParallel.cs" />
</ItemGroup>
</Project>
12 changes: 8 additions & 4 deletions eng/pipelines/templates/jobs/smoke.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@ jobs:
condition: and(succeeded(), eq(dependencies.smoke_test_eligibility.outputs['output_eligibility.RunSmokeTests'], true))
strategy:
matrix:
Ubuntu_Net60:
Pool: "azsdk-pool-mms-ubuntu-2004-general"
OSVmImage: "MMSUbuntu20.04"
TestTargetFramework: net6.0
Windows_NetFramework:
Pool: "azsdk-pool-mms-win-2022-general"
OSVmImage: "MMS2022"
TestTargetFramework: net461
Windows_NetCore:
Pool: "azsdk-pool-mms-ubuntu-2004-general"
OSVmImage: "MMSUbuntu20.04"
TestTargetFramework: netcoreapp3.1
Windows_Net60:
Pool: "azsdk-pool-mms-win-2022-general"
OSVmImage: "MMS2022"
TestTargetFramework: net6.0
Windows_Net70:
Pool: "azsdk-pool-mms-win-2022-general"
OSVmImage: "MMS2022"
TestTargetFramework: net7.0
pool:
name: $(Pool)
vmImage: $(OSVmImage)
Expand Down
30 changes: 15 additions & 15 deletions eng/pipelines/templates/stages/platform-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
},
"matrix": {
"Agent": {
"Ubuntu-20.04_NETCore3.1": {
"Ubuntu-20.04_NET6.0": {
"OSVmImage": "MMSUbuntu20.04",
"Pool": "azsdk-pool-mms-ubuntu-2004-general",
"TestTargetFramework": "netcoreapp3.1"
"TestTargetFramework": "net6.0"
},
"Ubuntu-20.04_NET6.0": {
"Ubuntu-20.04_NET7.0": {
"OSVmImage": "MMSUbuntu20.04",
"Pool": "azsdk-pool-mms-ubuntu-2004-general",
"TestTargetFramework": "net6.0"
"TestTargetFramework": "net7.0"
},
"windows2022_NET6.0": {
"Windows2022_NET461": {
"OSVmImage": "MMS2022",
"Pool": "azsdk-pool-mms-win-2022-general",
"TestTargetFramework": "net6.0"
"TestTargetFramework": "net461"
},
"windows2022_NET461": {
"Windows2022_NET7.0": {
"OSVmImage": "MMS2022",
"Pool": "azsdk-pool-mms-win-2022-general",
"TestTargetFramework": "net461"
"TestTargetFramework": "net7.0"
},
"macos-11_NETCore3.1": {
"MacOS-11_NET6.0": {
"OSVmImage": "macos-11",
"Pool": "Azure Pipelines",
"TestTargetFramework": "netcoreapp3.1"
"TestTargetFramework": "net6.0"
},
"macos-11_NET6.0": {
"MacOS-11_NET7.0": {
"OSVmImage": "macos-11",
"Pool": "Azure Pipelines",
"TestTargetFramework": "net6.0"
"TestTargetFramework": "net7.0"
}
},
"AdditionalTestArguments": [
Expand All @@ -48,14 +48,14 @@
"include": [
{
"Agent": {
"windows2022": {
"Windows2022_NET7.0": {
"OSVmImage": "MMS2022",
"Pool": "azsdk-pool-mms-win-2022-general",
"TestTargetFramework": "net6.0"
"TestTargetFramework": "net7.0"
}
},
"TestMode": {
"NET6.0_Coverage_Record": {
"Coverage_Record": {
"SupportsRecording": true,
"CollectCoverage": true
}
Expand Down
11 changes: 10 additions & 1 deletion eng/pipelines/templates/steps/install-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ steps:
msbuildArguments: /p:WorkFolder="$(Agent.WorkFolder)" /p:BuildDirectory="$(Agent.BuildDirectory)"
# Installation steps need to be uncommented when switching to a newer SDK that's not available on DevOps agents
- task: UseDotNet@2
displayName: 'Use .NET Core SDK'
displayName: 'Use .NET SDK'
retryCountOnTaskFailure: 3
inputs:
useGlobalJson: true
performMultiLevelLookup: true
- task: UseDotNet@2
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) # Windows supports MultiLevelLookup and doesn't need explicit framework installation
displayName: 'Use .NET 6.0 SDK'
retryCountOnTaskFailure: 3
inputs:
# AspNetCore runtime pack can't be installed outside of SDK and we need it for integration tests
packageType: sdk
performMultiLevelLookup: true
version: "6.0.x"
- task: UseDotNet@2
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) # Windows supports MultiLevelLookup and doesn't need explicit framework installation
displayName: 'Use .NET Core 3.1 SDK'
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/dependencies/azure-sdk.deps.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<EnableDefaultItems>false</EnableDefaultItems>
<!--
Loading a dev version of some dependencies causes some downgrade warnings.
This can happen sometimes after releaseing a new version when the version in
<!--
Loading a dev version of some dependencies causes some downgrade warnings.
This can happen sometimes after releaseing a new version when the version in
the repo has not yet been updated.
-->
<NoWarn>$(NoWarn);NU1605</NoWarn>
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Microsoft.Build.Traversal": "3.2.0"
},
"sdk": {
"version": "6.0.403",
"version": "7.0.101",
"rollForward": "feature"
}
}
}
2 changes: 1 addition & 1 deletion samples/AppSecretsConfig/AppSecretsConfig.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>AppSecretsConfig</RootNamespace>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>preview</LangVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion samples/linecounter/LineCounter.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>67ca5d37-051b-4ab1-b013-c74a2d4edb76</UserSecretsId>
</PropertyGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions sdk/appconfiguration/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Before working on a contribution, it would be beneficial to familiarize yourself

These libraries follow the [Azure SDK Design Guidelines for .NET][sdk_design_guidelines_dotnet] and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features in the [Azure.Core README][sdk_dotnet_code_readme].

## Public API changes
## Public API changes

To update [`Azure.Data.AppConfiguration.netstandard2.0.cs`][azconfig_api] after making changes to the public API, execute [`./eng/scripts/Export-API.ps1`][azconfig_export_api].
To update [`Azure.Data.AppConfiguration.netstandard2.0.cs`][azconfig_api] after making changes to the public API, execute [`./eng/scripts/Export-API.ps1`][azconfig_export_api].

## Testing

Expand All @@ -48,7 +48,7 @@ Properly supporting recorded tests does require a few extra considerations. All

The easiest way to run the tests is via Visual Studio's unit test runner.

You can also run tests via the command line using `dotnet test`, but that will run tests for all supported platforms simultaneously and intermingle their output. You can run the tests for just one platform with `dotnet test -f netcoreapp3.1` or `dotnet test -f net461`.
You can also run tests via the command line using `dotnet test`, but that will run tests for all supported platforms simultaneously and intermingle their output. You can run the tests for just one platform with `dotnet test -f net6.0` or `dotnet test -f net461`.

The recorded tests are run automatically on every pull request. Live tests are run nightly. Contributors with write access can ask Azure DevOps to run the live tests against a pull request by commenting `/azp run net - appconfiguration - tests` in the PR.

Expand Down
Loading

0 comments on commit 0752525

Please sign in to comment.