From 425349b8ce750caac87b3bd1844d872ff4fb358a Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Thu, 17 Sep 2020 16:33:23 -0700 Subject: [PATCH] Switch ApiCompat to use PackageDownload Turns out instead of using the apicompat project workaround we can use a PackageDownload reference to get the last shipped package. This allows us to do the apicompat check completely inside the project we are checking. --- CONTRIBUTING.md | 5 +-- eng/ApiCompat/ApiCompat.csproj | 41 ------------------- eng/ApiCompat/Directory.Build.targets | 6 --- eng/Directory.Build.Data.targets | 25 +++++++---- eng/Packages.Data.props | 1 + eng/scripts/Export-API.ps1 | 2 +- sdk/core/Azure.Core/Azure.Core.All.sln | 14 ------- .../src/Azure.Messaging.EventGrid.csproj | 1 - .../src/Azure.Iot.Hub.Service.csproj | 1 - .../src/Azure.Storage.Blobs.ChangeFeed.csproj | 1 - .../src/Azure.Storage.Internal.Avro.csproj | 1 - 11 files changed, 19 insertions(+), 79 deletions(-) delete mode 100644 eng/ApiCompat/ApiCompat.csproj delete mode 100644 eng/ApiCompat/Directory.Build.targets diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d579dbd9563f5..6cd40c3eaa50c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -229,10 +229,7 @@ dotnet build eng\service.proj /p:ServiceDirectory=eventhub /p:UpdateSourceOnBuil .NET is using the [ApiCompat tool](https://github.com/dotnet/arcade/tree/master/src/Microsoft.DotNet.ApiCompat) to enforce API compatibility between versions. Builds of GA'ed libraries will fail locally and in CI if there are breaking changes. ### How it works -We use a dummy project called [ApiCompat](https://github.com/Azure/azure-sdk-for-net/tree/master/eng/ApiCompat/ApiCompat.csproj) to enforce API compatibility between the GA'ed libraries and the most recent version available on Nuget. This project includes package references to the GA'ed library and to Microsoft.DotNet.ApiCompat. -Each library needs to provide a `ApiCompatVersion` property which is set to the last GA'ed version of the library which is used to compare APIs with the current to ensure no breaks -have been introduced. -The `ApiCompatVerification` target defined in `ApiCompat.csproj` is referenced in the [eng/Directory.Build.Data.targets](https://github.com/Azure/azure-sdk-for-net/blob/master/eng/Directory.Build.Data.targets) which causes this target to be executed for each csproj that has the `ApiCompatVersion` property set. For libraries that wish to disable the APICompat check they can remove the `ApiCompatVersion` property from their project. Our version bump automation will automatically add or increment the `ApiCompatVersion` property to the project when it detects that the version it is changing was a GA version which usually indicates that we just shipped that GA version and so it should be the new baseline for api checks. +Each library needs to provide a `ApiCompatVersion` property which is set to the last GA'ed version of the library that will be used to compare APIs with the current to ensure no breaks have been introduced. Projects with this property set will download the specified package and the ApiCompat (Microsoft.DotNet.ApiCompat) tools package as part of the restore step of the project. Then as a post build step of the project it will run ApiCompat to verify the current APIs are compatible with the last GA'ed version of the APIs. For libraries that wish to disable the APICompat check they can remove the `ApiCompatVersion` property from their project. Our version bump automation will automatically add or increment the `ApiCompatVersion` property to the project when it detects that the version it is changing was a GA version which usually indicates that we just shipped that GA version and so it should be the new baseline for API checks. ### Releasing a new version of a GA'ed libary Since the [eng/Packages.Data.props](https://github.com/Azure/azure-sdk-for-net/blob/master/eng/Packages.Data.props) is currently maintained manually, you will need to update the version number for your library in this file when releasing a new version. diff --git a/eng/ApiCompat/ApiCompat.csproj b/eng/ApiCompat/ApiCompat.csproj deleted file mode 100644 index 29384b8ee3f5f..0000000000000 --- a/eng/ApiCompat/ApiCompat.csproj +++ /dev/null @@ -1,41 +0,0 @@ - - - - netstandard2.0 - true - - - - - - - - - - - - - - - - - - %(ResolvedCompileFileDefinitions.Identity) - - - - - <_DependencyDirectories Include="$(TargetOutputPath)" /> - - - - - \ No newline at end of file diff --git a/eng/ApiCompat/Directory.Build.targets b/eng/ApiCompat/Directory.Build.targets deleted file mode 100644 index cb0b0f09518d6..0000000000000 --- a/eng/ApiCompat/Directory.Build.targets +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/eng/Directory.Build.Data.targets b/eng/Directory.Build.Data.targets index 18c7a348ebaa5..289e28c04b393 100644 --- a/eng/Directory.Build.Data.targets +++ b/eng/Directory.Build.Data.targets @@ -175,15 +175,22 @@ Text="When UseProjectReferenceToAzureClients=true all Azure.* references should be Project References, but the following are not [@(ShouldBeProjectReference)]" /> - - + + + + + + + + <_ReferencePathDirectories Include="@(ReferencePath -> '%(RootDir)%(Directory)')" /> + + @(_ReferencePathDirectories->Distinct(), ',') + + + + + + diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index 6028b496d7590..4c3924ccba3a4 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -63,6 +63,7 @@ + diff --git a/eng/scripts/Export-API.ps1 b/eng/scripts/Export-API.ps1 index 974c498059320..78adb1f54b30a 100644 --- a/eng/scripts/Export-API.ps1 +++ b/eng/scripts/Export-API.ps1 @@ -7,4 +7,4 @@ param ( $servicesProj = Resolve-Path "$PSScriptRoot/../service.proj" -dotnet build /p:GenerateApiListingOnBuild=true /p:SkipApiCompat=true /p:GeneratePackageOnBuild=false /p:Configuration=Release /p:IncludeSamples=false /p:IncludeTests=false /p:Scope="$ServiceDirectory" /restore $servicesProj +dotnet build /p:GenerateApiListingOnBuild=true /p:RunApiCompat=false /p:GeneratePackageOnBuild=false /p:Configuration=Release /p:IncludeSamples=false /p:IncludeTests=false /p:Scope="$ServiceDirectory" /restore $servicesProj diff --git a/sdk/core/Azure.Core/Azure.Core.All.sln b/sdk/core/Azure.Core/Azure.Core.All.sln index b13c95a7a720d..ca17ffd9a0455 100644 --- a/sdk/core/Azure.Core/Azure.Core.All.sln +++ b/sdk/core/Azure.Core/Azure.Core.All.sln @@ -161,8 +161,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Stora EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalTwinsClientSample", "..\..\digitaltwins\Azure.DigitalTwins.Core\samples\DigitalTwinsClientSample\DigitalTwinsClientSample.csproj", "{635AF2FC-2E5D-4335-8F8D-72F25BD61C95}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiCompat", "..\..\..\eng\ApiCompat\ApiCompat.csproj", "{EC964E8B-58ED-42B3-BCAA-740FFEFFF155}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Analytics.Synapse.AccessControl", "..\..\synapse\Azure.Analytics.Synapse.AccessControl\src\Azure.Analytics.Synapse.AccessControl.csproj", "{3B583609-3429-4231-A690-BAB60A7CFF66}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Analytics.Synapse.AccessControl.Tests", "..\..\synapse\Azure.Analytics.Synapse.AccessControl\tests\Azure.Analytics.Synapse.AccessControl.Tests.csproj", "{8833E803-A2DD-41F1-A264-7455A085AF47}" @@ -1226,18 +1224,6 @@ Global {635AF2FC-2E5D-4335-8F8D-72F25BD61C95}.Release|x64.Build.0 = Release|Any CPU {635AF2FC-2E5D-4335-8F8D-72F25BD61C95}.Release|x86.ActiveCfg = Release|Any CPU {635AF2FC-2E5D-4335-8F8D-72F25BD61C95}.Release|x86.Build.0 = Release|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Debug|x64.ActiveCfg = Debug|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Debug|x64.Build.0 = Debug|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Debug|x86.ActiveCfg = Debug|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Debug|x86.Build.0 = Debug|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Release|Any CPU.Build.0 = Release|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Release|x64.ActiveCfg = Release|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Release|x64.Build.0 = Release|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Release|x86.ActiveCfg = Release|Any CPU - {EC964E8B-58ED-42B3-BCAA-740FFEFFF155}.Release|x86.Build.0 = Release|Any CPU {3B583609-3429-4231-A690-BAB60A7CFF66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3B583609-3429-4231-A690-BAB60A7CFF66}.Debug|Any CPU.Build.0 = Debug|Any CPU {3B583609-3429-4231-A690-BAB60A7CFF66}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj index f504f658c570c..36683d7668d60 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj @@ -5,7 +5,6 @@ 4.0.0-beta.2 Microsoft Azure EventGrid;Event Grid;Event Grid Publishing; $(RequiredTargetFrameworks) - false diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Azure.Iot.Hub.Service.csproj b/sdk/iot/Azure.Iot.Hub.Service/src/Azure.Iot.Hub.Service.csproj index 44b6cefe49ab0..bd2fdcdcf6478 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Azure.Iot.Hub.Service.csproj +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Azure.Iot.Hub.Service.csproj @@ -2,7 +2,6 @@ Azure IoT Hub Service Client SDK $(RequiredTargetFrameworks) - false diff --git a/sdk/storage/Azure.Storage.Blobs.ChangeFeed/src/Azure.Storage.Blobs.ChangeFeed.csproj b/sdk/storage/Azure.Storage.Blobs.ChangeFeed/src/Azure.Storage.Blobs.ChangeFeed.csproj index 62fcd9218c2ca..df348afd2b0b3 100644 --- a/sdk/storage/Azure.Storage.Blobs.ChangeFeed/src/Azure.Storage.Blobs.ChangeFeed.csproj +++ b/sdk/storage/Azure.Storage.Blobs.ChangeFeed/src/Azure.Storage.Blobs.ChangeFeed.csproj @@ -13,7 +13,6 @@ in addition to the breaking changes https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs.ChangeFeed/BreakingChanges.txt true - false diff --git a/sdk/storage/Azure.Storage.Internal.Avro/src/Azure.Storage.Internal.Avro.csproj b/sdk/storage/Azure.Storage.Internal.Avro/src/Azure.Storage.Internal.Avro.csproj index cb09c70284d34..720a651ca4c99 100644 --- a/sdk/storage/Azure.Storage.Internal.Avro/src/Azure.Storage.Internal.Avro.csproj +++ b/sdk/storage/Azure.Storage.Internal.Avro/src/Azure.Storage.Internal.Avro.csproj @@ -6,7 +6,6 @@ Microsoft Azure.Storage.Internal.Avro client library 12.0.0-preview.1 false - false