Merge pull request #500 from microsoft/fixOptProfPackageSigning

Fix the OptProf pipeline
This commit is contained in:
Andrew Arnott 2024-07-15 11:55:34 -06:00 коммит произвёл GitHub
Родитель ede259f6f7 b6b75efe9c
Коммит bf39b80398
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
8 изменённых файлов: 86 добавлений и 49 удалений

Просмотреть файл

@ -4,7 +4,7 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<MicroBuildVersion>2.0.152</MicroBuildVersion>
<MicroBuildVersion>2.0.162</MicroBuildVersion>
<CodeAnalysisVersion>3.11.0</CodeAnalysisVersion>
<CodeAnalysisVersionForTesting>4.8.0</CodeAnalysisVersionForTesting>
<CodefixTestingVersion>1.1.1</CodefixTestingVersion>
@ -36,11 +36,11 @@
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Metadata" Version="6.0.0" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />
<PackageVersion Include="xunit.extensibility.execution" Version="2.8.1" />
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.0" />
<PackageVersion Include="xunit.runner.console" Version="2.5.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageVersion Include="xunit" Version="2.8.1" />
<PackageVersion Include="xunit" Version="2.9.0" />
</ItemGroup>
<ItemGroup Condition="'$(IsTestProject)'=='true'">
<PackageVersion Update="Microsoft.CodeAnalysis" Version="$(CodeAnalysisVersionForTesting)" />
@ -51,7 +51,7 @@
<PackageVersion Update="System.Reflection.Metadata" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.495" />
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.593" />
<GlobalPackageReference Include="IsExternalInit" Version="1.0.3" />
<GlobalPackageReference Include="Required" Version="1.0.0" />
<GlobalPackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />

Просмотреть файл

@ -1,17 +0,0 @@
<?xml version="1.0"?>
<package>
<!-- This file is only used in repos where OptProf is enabled. -->
<metadata>
<id>Microsoft.VisualStudio.Composition.VSInsertionMetadata</id>
<version>$version$</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<projectUrl>https://github.com/Microsoft/vs-mef</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Contains metadata for insertion into VS.</description>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
</metadata>
<files>
<file src="ProfilingInputs.props" target="InsertionVS/" />
</files>
</package>

Просмотреть файл

@ -29,30 +29,7 @@ $result = @{
if ($env:IsOptProf) {
$VSRepoPackages = "$RepoRoot/bin/Packages/$BuildConfiguration/VSRepo"
$ArtifactBasePath = "$RepoRoot\obj\_artifacts"
$ArtifactPath = "$ArtifactBasePath\VSInsertion"
if (-not (Test-Path $ArtifactPath)) { New-Item -ItemType Directory -Path $ArtifactPath | Out-Null }
$profilingInputs = [xml](Get-Content -Path "$PSScriptRoot\..\ProfilingInputs.props")
$profilingInputs.Project.ItemGroup.TestStore.Include = "vstsdrop:" + (& "$PSScriptRoot\..\variables\ProfilingInputsDropName.ps1")
$profilingInputs.Save("$ArtifactPath\ProfilingInputs.props")
$InsertionMetadataVersion = $(dotnet tool run nbgv get-version -p "$RepoRoot\src" -f json | ConvertFrom-Json).NuGetPackageVersion
if ($env:BUILD_BUILDID) {
# We must ensure unique versions for the insertion metadata package so
# it can contain information that is unique to this build.
# In particular it includes the ProfilingInputsDropName, which contains the BuildId.
# A non-unique package version here may collide with a prior run of this same commit,
# ultimately resulting in a failure of the optprof run.
$InsertionMetadataVersion += '.' + $env:BUILD_BUILDID
}
& (& "$PSScriptRoot\..\Get-NuGetTool.ps1") pack "$PSScriptRoot\..\InsertionMetadataPackage.nuspec" -OutputDirectory $VSRepoPackages -BasePath $ArtifactPath -Version $InsertionMetadataVersion | Out-Null
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$result["$VSRepoPackages"] = (Get-ChildItem "$VSRepoPackages\Microsoft.VisualStudio.Composition.VSInsertionMetadata.$InsertionMetadataVersion.nupkg");
$result["$VSRepoPackages"] = (Get-ChildItem "$VSRepoPackages\*.VSInsertionMetadata.*.nupkg");
}
$result

Просмотреть файл

@ -17,9 +17,8 @@ steps:
condition: and(succeeded(), ${{ parameters.RunTests }})
- ${{ if parameters.IsOptProf }}:
# We have to artifically run this script so that the extra .nupkg is produced for variables/InsertPropsValues.ps1 to notice.
- powershell: azure-pipelines\artifacts\VSInsertion.ps1
displayName: 🔧 Prepare VSInsertion artifact
- script: dotnet pack src\VSInsertionMetadata -c $(BuildConfiguration) -warnaserror /bl:"$(Build.ArtifactStagingDirectory)/build_logs/VSInsertion-Pack.binlog"
displayName: 🔧 dotnet pack VSInsertionMetadata
- powershell: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true

Просмотреть файл

@ -3,5 +3,8 @@
"version": "8.0.300",
"rollForward": "patch",
"allowPrerelease": false
},
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.7.56"
}
}

Просмотреть файл

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<PackageOutputPath>$(RepoRootPath)bin\Packages\$(Configuration)\VSRepo\</PackageOutputPath>
<IncludeSymbols>false</IncludeSymbols>
<EnableDefaultSignFiles>false</EnableDefaultSignFiles>
<Description>Contains metadata for insertion into VS.</Description>
</PropertyGroup>
<Import Project="VSInsertionMetadata.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,64 @@
<Project>
<UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<InputFilename ParameterType="System.String" Required="true" />
<OutputFilename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(
OutputFilename,
Regex.Replace(File.ReadAllText(InputFilename), MatchExpression, ReplacementText)
);
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup>
<TargetsForTfmSpecificContentInPackage>
$(TargetsForTfmSpecificContentInPackage);
SubstituteProfilingInputsMacro;
SubstituteProfilingInputsMacroWarning;
</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>
<Target Name="SubstituteProfilingInputsMacroWarning" Condition="'$(ProfilingInputsDropName)'==''">
<Warning Text="The ProfilingInputsDropName msbuild property has not been set, and the OptProf will not contain accurate content."/>
</Target>
<Target Name="SubstituteProfilingInputsMacro" Condition="'$(ProfilingInputsDropName)'!=''">
<ItemGroup>
<ProfilingInputsSource Include="ProfilingInputs.props" />
<ProfilingInputsTarget Include="$(IntermediateOutputPath)ProfilingInputs.props" />
</ItemGroup>
<ReplaceFileText
Condition="'$(ProfilingInputsDropName)' != ''"
InputFilename="@(ProfilingInputsSource)"
OutputFilename="@(ProfilingInputsTarget)"
MatchExpression="%TESTSTORE%"
ReplacementText="vstsdrop:$(ProfilingInputsDropName)" />
<ItemGroup>
<TfmSpecificPackageFile Include="@(ProfilingInputsTarget)" PackagePath="InsertionVS/" />
</ItemGroup>
</Target>
<Target Name="EnsureUniquePackageVersion"
Condition="'$(Build_BuildId)' != ''"
AfterTargets="GetBuildVersion">
<!--
We must ensure unique versions for the insertion metadata package so
it can contain information that is unique to this build.
In particular it includes the ProfilingInputsDropName, which contains the BuildId.
A non-unique package version here may collide with a prior run of this same commit,
ultimately resulting in a failure of the optprof run.
-->
<PropertyGroup>
<PackageVersion>$(PackageVersion).$(Build_BuildId)</PackageVersion>
</PropertyGroup>
</Target>
</Project>