Merge pull request #259 from microsoft/libtemplateUpdate

Merge latest Library.Template
This commit is contained in:
Andrew Arnott 2024-08-22 12:36:08 -06:00 коммит произвёл GitHub
Родитель 16e8f491ba b4b4ab0b2b
Коммит 42d63e83aa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
17 изменённых файлов: 154 добавлений и 74 удалений

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

@ -3,19 +3,19 @@
"isRoot": true,
"tools": {
"powershell": {
"version": "7.4.3",
"version": "7.4.4",
"commands": [
"pwsh"
]
},
"dotnet-coverage": {
"version": "17.11.3",
"version": "17.11.5",
"commands": [
"dotnet-coverage"
]
},
"nbgv": {
"version": "3.6.139",
"version": "3.6.141",
"commands": [
"nbgv"
]

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

@ -185,5 +185,8 @@ dotnet_diagnostic.DOC202.severity = warning
# CA1062: Validate arguments of public methods
dotnet_diagnostic.CA1062.severity = warning
# CA2016: Forward the CancellationToken parameter
dotnet_diagnostic.CA2016.severity = warning
[*.sln]
indent_style = tab

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

@ -5,21 +5,21 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<MicroBuildVersion>2.0.152</MicroBuildVersion>
<MicroBuildVersion>2.0.165</MicroBuildVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis.ResxSourceGenerator" Version="3.3.5-beta1.23330.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageVersion Include="Microsoft.VisualStudio.Internal.MicroBuild.NonShipping" Version="$(MicroBuildVersion)" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
<PackageVersion Include="xunit" Version="2.8.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit" Version="2.9.0" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.495" />
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.593" />
<GlobalPackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<GlobalPackageReference Include="Microsoft.VisualStudio.Internal.MicroBuild.VisualStudio" Version="$(MicroBuildVersion)" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.139" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.141" />
<GlobalPackageReference Include="Nullable" Version="1.3.1" />
<GlobalPackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" />
</ItemGroup>

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

@ -1,17 +0,0 @@
<?xml version="1.0"?>
<package>
<!-- This file is only used in repos where OptProf is enabled. -->
<metadata>
<id>Microsoft.VisualStudio.Validation.VSInsertionMetadata</id>
<version>$version$</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<projectUrl>https://github.com/Microsoft/vs-validation</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.Validation.VSInsertionMetadata.$InsertionMetadataVersion.nupkg");
$result["$VSRepoPackages"] = (Get-ChildItem "$VSRepoPackages\*.VSInsertionMetadata.*.nupkg");
}
$result

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

@ -65,6 +65,11 @@ parameters:
type: boolean
default: true
# Whether this is a special one-off build for inserting into VS for a validation insertion PR (that will never be merged).
- name: ValidationBuild
type: boolean
default: false
- name: EnableAPIScan
type: boolean
default: false
@ -191,6 +196,7 @@ jobs:
parameters:
EnableOptProf: ${{ parameters.EnableOptProf }}
IsOptProf: ${{ parameters.IsOptProf }}
ValidationBuild: ${{ parameters.ValidationBuild }}
- ${{ if not(parameters.IsOptProf) }}:
- ${{ if parameters.EnableLinuxBuild }}:

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

@ -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

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

@ -5,14 +5,17 @@ parameters:
- name: IsOptProf
type: boolean
default: false
- name: ValidationBuild
type: boolean
steps:
- task: MicroBuildCodesignVerify@3
displayName: 🔍 Verify Signed Files
inputs:
TargetFolders: |
$(Build.SourcesDirectory)/bin/Packages/$(BuildConfiguration)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- ${{ if not(parameters.ValidationBuild) }}: # skip CodesignVerify on validation builds because we don't even test-sign nupkg's.
- task: MicroBuildCodesignVerify@3
displayName: 🔍 Verify Signed Files
inputs:
TargetFolders: |
$(Build.SourcesDirectory)/bin/Packages/$(BuildConfiguration)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- ${{ if parameters.IsOptProf }}:
- task: ms-vscs-artifact.build-tasks.artifactDropTask-1.artifactDropTask@0

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

@ -9,7 +9,6 @@ parameters:
stages:
- stage: release
displayName: Publish
condition: and(succeeded(), eq('${{ parameters.RealSign }}', 'true'))
jobs:
- ${{ if parameters.ArchiveSymbols }}:
- job: symbol_archive
@ -34,7 +33,10 @@ stages:
- ${{ if true }}: # leave the condition to avoid merge conflicts later.
- job: push
displayName: azure-public/vssdk feed
${{ if parameters.RealSign }}:
displayName: azure-public/vssdk feed
${{ else }}:
displayName: devdiv/vs-impl feed # Leave this as-is, since non-signed builds must not be pushed to public feeds.
${{ if parameters.ArchiveSymbols }}:
dependsOn: symbol_archive
pool:
@ -49,8 +51,12 @@ stages:
packagesToPush: '$(Pipeline.Workspace)/deployables-Windows/NuGet/*.nupkg'
packageParentPath: $(Pipeline.Workspace)/deployables-Windows/NuGet
allowPackageConflicts: true
nuGetFeedType: external
publishFeedCredentials: azure-public/vssdk
${{ if parameters.RealSign }}:
nuGetFeedType: external
publishFeedCredentials: azure-public/vssdk
${{ else }}:
nuGetFeedType: internal
publishVstsFeed: vs-impl # Leave this as-is, since non-signed builds must not be pushed to public feeds.
steps:
- checkout: none
- download: current
@ -61,7 +67,8 @@ stages:
- download: current
artifact: deployables-Windows
displayName: 🔻 Download deployables-Windows artifact
- template: WIFtoPATauth.yml
parameters:
wifServiceConnectionName: azure-public/vside package push
deadPATServiceConnectionId: 42175e93-c771-4a4f-a132-3cca78f44b3b # azure-public/vssdk
- ${{ if parameters.RealSign }}:
- template: WIFtoPATauth.yml
parameters:
wifServiceConnectionName: azure-public/vside package push
deadPATServiceConnectionId: 42175e93-c771-4a4f-a132-3cca78f44b3b # azure-public/vssdk

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

@ -21,9 +21,8 @@ steps:
continueOnError: true
- powershell: azure-pipelines/Merge-CodeCoverage.ps1 -Path '$(Pipeline.Workspace)' -OutputFile coveragereport/merged.cobertura.xml -Format Cobertura -Verbose
displayName: ⚙ Merge coverage
- task: PublishCodeCoverageResults@1
- task: PublishCodeCoverageResults@2
displayName: 📢 Publish code coverage results to Azure DevOps
inputs:
codeCoverageTool: cobertura
summaryFileLocation: coveragereport/merged.cobertura.xml
failIfCoverageEmpty: true

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

@ -54,7 +54,7 @@ extends:
- download: CI
artifact: deployables-Windows
displayName: 🔻 Download deployables-Windows artifact
patterns: 'deployables-Windows/NuGet/*'
patterns: 'NuGet/*'
- task: GitHubRelease@1
displayName: 📢 GitHub release (create)
inputs:

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

@ -14,6 +14,8 @@ resources:
variables:
- template: GlobalVariables.yml
- name: MicroBuild_NuPkgSigningEnabled
value: false # test-signed nuget packages fail to restore in the VS insertion PR validations. Just don't sign the *at all*.
extends:
template: azure-pipelines/MicroBuild.1ES.Unofficial.yml@MicroBuildTemplate
@ -33,15 +35,25 @@ extends:
- template: /azure-pipelines/build.yml@self
parameters:
Is1ESPT: true
RealSign: true
RealSign: false
windowsPool: VSEngSS-MicroBuild2022-1ES
linuxPool:
name: AzurePipelines-EO
demands:
- ImageOverride -equals 1ESPT-Ubuntu22.04
os: Linux
macOSPool:
name: Azure Pipelines
vmImage: macOS-12
os: macOS
EnableMacOSBuild: false
RunTests: false
ValidationBuild: true
- template: /azure-pipelines/prepare-insertion-stages.yml@self
parameters:
ArchiveSymbols: false
RealSign: true
RealSign: false
- stage: insertion
displayName: VS insertion
@ -73,12 +85,13 @@ extends:
inputs:
TeamName: $(TeamName)
TeamEmail: $(TeamEmail)
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch)) [Skip-SymbolCheck]
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch)) [Skip-SymbolCheck] [Skip-HashCheck] [Skip-SignCheck]
InsertionDescription: |
This PR is for **validation purposes only** for !$(System.PullRequest.PullRequestId). **Do not complete**.
CustomScriptExecutionCommand: src/VSSDK/NuGet/AllowUnstablePackages.ps1
InsertionBuildPolicy: Request Perf DDRITs
InsertionReviewers: $(Build.RequestedFor)
DraftPR: false # set to true and update InsertionBuildPolicy when we can specify all the validations we want to run (https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2224288)
AutoCompletePR: false
ShallowClone: true
- powershell: |

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

@ -0,0 +1,6 @@
# https://learn.microsoft.com/azure/devops/pipelines/test/codecoverage-for-pullrequests?view=azure-devops
coverage:
status:
comments: on # add comment to PRs reporting diff in coverage of modified files
diff: # diff coverage is code coverage only for the lines changed in a pull request.
target: 70% # set this to a desired %. Default is 70%

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

@ -1,7 +1,10 @@
{
"sdk": {
"version": "8.0.300",
"version": "8.0.400",
"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,70 @@
<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;
</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>
<Target Name="SubstituteProfilingInputsMacro">
<ItemGroup>
<ProfilingInputsSource Include="ProfilingInputs.props" />
<ProfilingInputsTarget Include="$(IntermediateOutputPath)ProfilingInputs.props" />
</ItemGroup>
<ReplaceFileText
Condition="'$(ProfilingInputsDropName)' != ''"
InputFilename="@(ProfilingInputsSource)"
OutputFilename="@(ProfilingInputsTarget)"
MatchExpression="%TESTSTORE%"
ReplacementText="vstsdrop:$(ProfilingInputsDropName)" />
<Warning
Text="The ProfilingInputsDropName msbuild property has not been set, and the OptProf will not contain accurate content."
Condition="'$(ProfilingInputsDropName)' == ''" />
<Copy SourceFiles="@(ProfilingInputsSource)" DestinationFiles="@(ProfilingInputsTarget)"
Condition="'$(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>
<Target Name="BreakForRename" BeforeTargets="Pack;GenerateNuspec" Condition="'$(MSBuildProjectName)'=='Library.VSInsertionMetadata'">
<Error Text="This project should be renamed so the library name is used instead of 'Library'. Then delete this target." />
</Target>
</Project>