未验证 提交 147609fd 编写于 作者: I Igor Velikorossov 提交者: GitHub

Pin assembly versions to prevent revving those in servicing releases (#6101)

上级 0fb303d2
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>6.0.3</VersionPrefix>
<MajorVersion>6</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>3</PatchVersion>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<!--
Set assembly version to align with major and minor version, as for the patches and revisions should be manually
updated per assembly if it is serviced.
Note, any components that aren't exposed as references in the targeting pack (like analyzers/generators) those should rev
so that they can exist sxs. The compiler relies on different version to change assembly version for caching purposes.
Because it is possible to build on a lower version and run on a higher version, we're locking the targeting pack and the runtime
assembly vesions to 6.0.2.
There's still a risk that some customers building on 6.0.2+ and trying to run on 6.0.0 and 6.0.1 will still have issue, but
those issues can be mitigated with a workaround described in https://github.com/dotnet/core/issues/7176.
-->
<AssemblyVersion>$(MajorVersion).$(MinorVersion).2.0</AssemblyVersion>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<PreReleaseVersionIteration>
</PreReleaseVersionIteration>
......
[CmdletBinding(PositionalBinding=$false)]
Param(
[Parameter(Mandatory=$True, Position=1)]
[string] $NuspecFile,
[Parameter(Mandatory=$True, Position=2)]
[string] $ExpectedAssemblyVersion,
[Parameter(Mandatory=$True, Position=3)]
[string] $IsServicingRelease,
[Parameter(ValueFromRemainingArguments=$true)][String[]] $properties
)
$servicingRelease = $null;
[bool]::TryParse($IsServicingRelease, [ref]$servicingRelease) | Out-Null;
[xml] $xmlDoc = Get-Content -Path $NuspecFile -Force;
#
# Verify that components that are exposed as references in the targeting packs don't have their versions revved.
# See https://github.com/dotnet/core/issues/7172#issuecomment-1034105137 for more details.
[xml] $xmlDoc = Get-Content -Path $NuspecFile -Force;
# Iterate over files that MUST NOT have their versions revved with every release
$nonRevAssemblies = $xmlDoc.package.files.file | `
Where-Object {
($_.target.StartsWith('lib\') -or $_.target.StartsWith('ref\')) `
-and $_.target.EndsWith('.dll', [System.StringComparison]::OrdinalIgnoreCase) `
-and !$_.target.EndsWith('resources.dll', [System.StringComparison]::OrdinalIgnoreCase)
} | `
Select-Object -Unique src | `
Select-Object -ExpandProperty src;
$nonRevAssemblies | `
sort-object | `
foreach-object {
$assembly = $_;
[string] $version = ([Reflection.AssemblyName]::GetAssemblyName($assembly).Version).ToString()
Write-Host "$assembly`: $version"
if (![string]::Equals($version, $ExpectedAssemblyVersion)) {
throw "$assembly is not versioned correctly. Expected: '$ExpectedAssemblyVersion', found: '$version'."
exit -1;
}
}
# Iterate over files that MUST have their versions revved with every release
$revAssemblies = $xmlDoc.package.files.file | `
Where-Object {
$_.target.StartsWith('sdk\analyzers\') `
-and $_.target.EndsWith('.dll', [System.StringComparison]::OrdinalIgnoreCase) `
-and !$_.target.EndsWith('resources.dll', [System.StringComparison]::OrdinalIgnoreCase)
} | `
Select-Object -Unique src | `
Select-Object -ExpandProperty src;
$revAssemblies | `
sort-object | `
foreach-object {
$assembly = $_;
[string] $version = ([Reflection.AssemblyName]::GetAssemblyName($assembly).Version).ToString()
Write-Host "$assembly`: $version"
if ($servicingRelease -and [string]::Equals($version, $ExpectedAssemblyVersion)) {
throw "$assembly is not versioned correctly. '$version' is not expected."
exit -1;
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<_PowerShellExe Condition="'$(_PowerShellExe)' == ''">%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe</_PowerShellExe>
<_ScriptLocation Condition="'$(_ScriptLocation)' == ''">$(MSBuildProjectDirectory)\Check-AssemblyVersions.ps1</_ScriptLocation>
<_IsServicingRelease>false</_IsServicingRelease>
<_IsServicingRelease Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</_IsServicingRelease>
</PropertyGroup>
<!--
Inspect the following NuSpecs and validate the assembly versions
* .\artifacts\packages\Release\NonShipping\Microsoft.DotNet.Wpf.GitHub.<version>.nuspec produced by Microsoft.DotNet.Wpf.GitHub.ArchNeutral.csproj
* .\artifacts\packages\Release\NonShipping\runtime.<arch>.Microsoft.DotNet.Wpf.GitHub.<version>.nuspec produced by Microsoft.DotNet.Wpf.GitHub.csproj
-->
<Target Name="ValidateTransportPackage"
AfterTargets="GenerateNuspec"
DependsOnTargets="GenerateNuspec"
Condition="'$(IsPackable)' == 'true'">
<ItemGroup>
<_NuspecFile Include="@(NuGetPackOutput)" Condition="'%(Extension)' == '.nuspec'" />
</ItemGroup>
<PropertyGroup>
<_NuspecFilePath>@(_NuspecFile)</_NuspecFilePath>
<!--
When we build Microsoft.DotNet.Wpf.GitHub.csproj GenerateNuspec task creates an arch-specific NuSpec, and
NuSpec declared in NuGetPackOutput does not exist.
Look for the arch-specific NuSpec
-->
<_NuspecFilePath Condition="'$(_NuspecFilePath)' == '' or !Exists('$(_NuspecFilePath)')">$(NuspecOutputPath)\$(PackageId).$(PackageVersion).nuspec</_NuspecFilePath>
</PropertyGroup>
<Error Text="'$(_ScriptLocation)' is missing." Condition="!Exists('$(_ScriptLocation)')" />
<Error Text="'$(_NuspecFilePath)' is missing." Condition="!Exists('$(_NuspecFilePath)')" />
<Exec
Command="$(_PowerShellExe) -NonInteractive -ExecutionPolicy Unrestricted -Command &quot;&amp; { &amp;&apos;$(_ScriptLocation)&apos; &apos;$(_NuspecFilePath)&apos; &apos;$(AssemblyVersion)&apos; $(_IsServicingRelease) } &quot;"
ContinueOnError="False" />
</Target>
</Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册