-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Pin assembly versions to prevent revving those in servicing releases #6101
Merged
+129
−1
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packaging/Microsoft.DotNet.Wpf.GitHub/Check-AssemblyVersions.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[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." | ||
RussKie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit -1; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
packaging/Microsoft.DotNet.Wpf.GitHub/Directory.Build.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" /> | ||
|
||
<PropertyGroup> | ||
<_PowerShellExe Condition="'$(_PowerShellExe)' == ''">C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</_PowerShellExe> | ||
RussKie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<_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 "& { &'$(_ScriptLocation)' '$(_NuspecFilePath)' '$(AssemblyVersion)' $(_IsServicingRelease) } "" | ||
ContinueOnError="False" /> | ||
|
||
</Target> | ||
|
||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as on the WinForms PR, using the
.2
patch version should be conditioned on whether we're building for 6.0, and should not apply to 7.0 and forwards.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version here must be 6.0.0.0 or simply 6.0. At least from my point of view and past experience with version pinning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a 6.0 branch. For the 7.0 branch it is locked at Major.Minor.0.0, see #6099.
Is there a situation where you expect 6.0 spill into another branch?