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

Switch ApiCompat to use PackageDownload #15250

Merged
merged 1 commit into from
Sep 18, 2020
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
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
41 changes: 0 additions & 41 deletions eng/ApiCompat/ApiCompat.csproj

This file was deleted.

6 changes: 0 additions & 6 deletions eng/ApiCompat/Directory.Build.targets

This file was deleted.

25 changes: 16 additions & 9 deletions eng/Directory.Build.Data.targets
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,22 @@
Text="When UseProjectReferenceToAzureClients=true all Azure.* references should be Project References, but the following are not [@(ShouldBeProjectReference)]" />
</Target>

<Target Name="RunApiCompat" AfterTargets="CoreBuild" Condition="'$(ApiCompatVersion)' != '' and '$(DesignTimeBuild)' != 'true' and '$(SkipApiCompat)' != 'true'">
<MSBuild
Projects="$(MSBuildThisFileDirectory)/ApiCompat/ApiCompat.csproj"
Properties="TargetPackageName=$(PackageId);
TargetPackageVersion=$(ApiCompatVersion);
TargetOutputPath=$(IntermediateOutputPath);
BaseIntermediateOutputPath=$(IntermediateOutputPath)\ApiCompat\"
Targets="ApiCompatVerification"
/>
<ItemGroup Condition="'$(ApiCompatVersion)' != ''">
<PackageDownload Include="$(PackageId)" Version="[$(ApiCompatVersion)]" />
<PackageReference Include="Microsoft.DotNet.ApiCompat" />
</ItemGroup>

<Target Name="_ResolveResolvedMatchingContract" BeforeTargets="ValidateApiCompatForSrc" Condition="'$(ApiCompatVersion)' != ''">
<ItemGroup>
<_ReferencePathDirectories Include="@(ReferencePath -> '%(RootDir)%(Directory)')" />
<ResolvedMatchingContract Include="$(NuGetPackageRoot)\$(PackageId.ToLower())\$(ApiCompatVersion)\lib\$(TargetFramework)\$(TargetFileName)">
<DependencyPaths>@(_ReferencePathDirectories->Distinct(), ',')</DependencyPaths>
</ResolvedMatchingContract>
</ItemGroup>
</Target>

<Target Name="ApiCompatFinishedMessage" AfterTargets="ValidateApiCompatForSrc" Condition="'$(ApiCompatVersion)' != ''">
<Message Text="Ran ApiCompat against %(ResolvedMatchingContract.Identity) using assemblies from $(IntermediateOutputPath)" Importance="High" />
weshaggard marked this conversation as resolved.
Show resolved Hide resolved
</Target>

<Import Project="$(CentralPackageVersionPackagePath)\Sdk.targets" />
Expand Down
1 change: 1 addition & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.6.1" />
weshaggard marked this conversation as resolved.
Show resolved Hide resolved
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.6.2" />
<PackageReference Update="Microsoft.CodeAnalysis" Version="2.3.0" />
<PackageReference Update="Microsoft.DotNet.ApiCompat" Version="5.0.0-beta.19552.1" />
weshaggard marked this conversation as resolved.
Show resolved Hide resolved
<PackageReference Update="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.5.1" />
<PackageReference Update="Microsoft.Identity.Client" Version="4.16.1" />
<PackageReference Update="Microsoft.Identity.Client.Extensions.Msal" Version="2.12.0" />
Expand Down
2 changes: 1 addition & 1 deletion eng/scripts/Export-API.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
weshaggard marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 0 additions & 14 deletions sdk/core/Azure.Core/Azure.Core.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<Version>4.0.0-beta.2</Version>
<PackageTags>Microsoft Azure EventGrid;Event Grid;Event Grid Publishing;</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableApiCompat>false</EnableApiCompat>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<PropertyGroup>
<AssemblyTitle>Azure IoT Hub Service Client SDK</AssemblyTitle>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableApiCompat>false</EnableApiCompat>
</PropertyGroup>

<!-- Nuget properties -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
</Description>
<GenerateAPIListing>true</GenerateAPIListing>
<EnableApiCompat>false</EnableApiCompat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<AssemblyTitle>Microsoft Azure.Storage.Internal.Avro client library</AssemblyTitle>
<Version>12.0.0-preview.1</Version>
<GenerateAPIListing>false</GenerateAPIListing>
<EnableApiCompat>false</EnableApiCompat>
weshaggard marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" />
Expand Down