Fix ApiCompat (#4385)
This commit is contained in:
parent
3d0cf75442
commit
7db694157f
|
|
@ -12,22 +12,28 @@
|
|||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
|
||||
<PropertyGroup>
|
||||
<RunApiCompat>true</RunApiCompat>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true' AND '$(RunApiCompat)' == 'true'">
|
||||
<PackageReference Include="Microsoft.DotNet.ApiCompat" Version="6.0.0-beta.21308.1" PrivateAssets="All" />
|
||||
<ResolvedMatchingContract Include="$(RepoRoot)\build\LastMajorVersionBinaries\$(AssemblyName)\$(OTelPreviousStableVer)\lib\$(TargetFramework)\$(AssemblyName).dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="DispatchToInnerBuilds;ValidateApiCompatForSrc" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
|
||||
<Target Name="PreBuild" BeforeTargets="DispatchToInnerBuilds;ValidateApiCompatForSrc" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true' AND '$(RunApiCompat)' == 'true'">
|
||||
<!-- Note: DispatchToInnerBuilds is called for projects with multiple
|
||||
targets defined to spawn a build process for each target framework being
|
||||
compiled. Executing BEFORE that step means this runs once for a project
|
||||
instead of in parallel for each target framework defined. If we ever have a
|
||||
project with only a single target, this will NOT run and an alternative
|
||||
solution will be needed. -->
|
||||
<Message Text="ApiCompat: Running the powershell script to download the package for $(MSBuildProjectName)." Importance="High"/>
|
||||
<Exec Command="powershell -ExecutionPolicy Unrestricted -File "$(RepoRoot)\build\PreBuild.ps1" -package $(AssemblyName) -version "$(OTelPreviousStableVer)" -workDir "$(RepoRoot)\build\LastMajorVersionBinaries"" />
|
||||
</Target>
|
||||
|
||||
<Target Name="FindContractDependencyPaths" BeforeTargets="ValidateApiCompatForSrc" AfterTargets="ResolveAssemblyReferences" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
|
||||
<Target Name="FindContractDependencyPaths" BeforeTargets="ValidateApiCompatForSrc" AfterTargets="ResolveAssemblyReferences" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true' AND '$(RunApiCompat)' == 'true'">
|
||||
<Message Text="ApiCompat: Finding the contract dependency path for $(MSBuildProjectName)." Importance="High"/>
|
||||
<ItemGroup>
|
||||
<_ReferencePathDirectories Include="@(ReferencePath -> '%(RootDir)%(Directory)')" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -12,20 +12,35 @@ if (-Not (Test-Path $workDir))
|
|||
|
||||
if (Test-Path -Path "$workDir\$package.$version.zip")
|
||||
{
|
||||
Write-Debug "Previous package $package@$version already downloaded for compatibility check"
|
||||
Write-Host "Previous package $package@$version already downloaded for compatibility check"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Retrieving package $package@$version for compatibility check"
|
||||
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/$package/$version -Outfile "$workDir\$package.$version.zip"
|
||||
try
|
||||
{
|
||||
$Response = Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/$package/$version -Outfile "$workDir\$package.$version.zip"
|
||||
}
|
||||
catch
|
||||
{
|
||||
$StatusCode = $_.Exception.Response.StatusCode.value__
|
||||
throw "Error downloading the package $package@$version. Status code of the received response: $StatusCode"
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Path -Path "$workDir\$package\$version\lib")
|
||||
{
|
||||
Write-Debug "Previous package $package@$version already extracted to '$workDir\$package\$version\lib'"
|
||||
Write-Host "Previous package $package@$version already extracted to '$workDir\$package\$version\lib'"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Extracting package $package@$version from '$workDir\$package.$version.zip' to '$workDir\$package\$version' for compatibility check"
|
||||
Expand-Archive -LiteralPath "$workDir\$package.$version.zip" -DestinationPath "$workDir\$package\$version" -Force
|
||||
try
|
||||
{
|
||||
Expand-Archive -LiteralPath "$workDir\$package.$version.zip" -DestinationPath "$workDir\$package\$version" -Force
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw "Error extracting $package@$version.zip"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue