Skip to content

Commit

Permalink
Merge pull request #196 from microsoft/libtemplateUpdate
Browse files Browse the repository at this point in the history
Merge latest Library.Template
  • Loading branch information
AArnott authored Oct 30, 2024
2 parents 5427aad + 8726727 commit 0415b55
Show file tree
Hide file tree
Showing 39 changed files with 660 additions and 143 deletions.
6 changes: 3 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"isRoot": true,
"tools": {
"powershell": {
"version": "7.4.3",
"version": "7.4.6",
"commands": [
"pwsh"
]
},
"dotnet-coverage": {
"version": "17.11.3",
"version": "17.12.6",
"commands": [
"dotnet-coverage"
]
},
"nbgv": {
"version": "3.6.139",
"version": "3.6.146",
"commands": [
"nbgv"
]
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions
FROM mcr.microsoft.com/dotnet/sdk:8.0.300-jammy
FROM mcr.microsoft.com/dotnet/sdk:8.0.402-jammy

# Installing mono makes `dotnet test` work without errors even for net472.
# But installing it takes a long time, so it's excluded by default.
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
72 changes: 72 additions & 0 deletions .github/workflows/libtemplate-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Library.Template update

# PREREQUISITE: This workflow requires the repo to be configured to allow workflows to push commits and create pull requests.
# Visit https://github.com/USER/REPO/settings/actions
# Under "Workflow permissions", select "Read and write permissions" and check "Allow GitHub Actions to create ...pull requests"
# Click Save.

on:
schedule:
- cron: "0 3 * * Mon" # Sun @ 8 or 9 PM Mountain Time (depending on DST)
workflow_dispatch:

jobs:
merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

- name: merge
shell: pwsh
run: |
$LibTemplateBranch = & ./azure-pipelines/Get-LibTemplateBasis.ps1 -ErrorIfNotRelated
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
git fetch https://github.com/aarnott/Library.Template $LibTemplateBranch
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$LibTemplateCommit = git rev-parse FETCH_HEAD
if ((git rev-list FETCH_HEAD ^HEAD --count) -eq 0) {
Write-Host "There are no Library.Template updates to merge."
exit 0
}
git -c http.extraheader="AUTHORIZATION: bearer $env:GH_TOKEN" push origin -u FETCH_HEAD:refs/heads/auto/libtemplateUpdate
- name: pull request
shell: pwsh
run: |
# If there is already an active pull request, don't create a new one.
$existingPR = gh pr list -H auto/libtemplateUpdate --json url | ConvertFrom-Json
if ($existingPR) {
Write-Host "::warning::Skipping pull request creation because one already exists at $($existingPR[0].url)"
exit 0
}
$prTitle = "Merge latest Library.Template"
$prBody = "This merges the latest features and fixes from [Library.Template's branch](https://github.com/AArnott/Library.Template/tree/).
<details>
<summary>Merge conflicts?</summary>
Resolve merge conflicts locally by carrying out these steps:
```
git fetch
git checkout auto/libtemplateUpdate
git merge origin/main
# resolve conflicts
git commit
git push
```
</details>
⚠️ Do **not** squash this pull request when completing it. You must *merge* it."
gh pr create -H auto/libtemplateUpdate -b $prBody -t $prTitle
env:
GH_TOKEN: ${{ github.token }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ bld/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# Jetbrains Rider cache directory
.idea/

# Visual Studio 2017 auto generated files
Generated\ Files/

Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<BaseIntermediateOutputPath>$(RepoRootPath)obj\$([MSBuild]::MakeRelative($(RepoRootPath), $(MSBuildProjectDirectory)))\</BaseIntermediateOutputPath>
<BaseOutputPath Condition=" '$(BaseOutputPath)' == '' ">$(RepoRootPath)bin\$(MSBuildProjectName)\</BaseOutputPath>
<PackageOutputPath>$(RepoRootPath)bin\Packages\$(Configuration)\NuGet\</PackageOutputPath>
<VSIXOutputPath>$(RepoRootPath)bin\Packages\$(Configuration)\Vsix\$(Platform)\</VSIXOutputPath>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AnalysisLevel>latest</AnalysisLevel>
Expand Down
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<MicroBuildVersion>2.0.152</MicroBuildVersion>
<MicroBuildVersion>2.0.165</MicroBuildVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.11.9" />
<PackageVersion Include="Microsoft.VisualStudio.Internal.MicroBuild.NonShipping" Version="$(MicroBuildVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Interop" Version="17.11.39607" />
Expand All @@ -17,15 +17,15 @@
<PackageVersion Include="Microsoft.ServiceHub.Framework.Testing" Version="4.4.22" />
<PackageVersion Include="NSubstitute" Version="5.0.0" />
<PackageVersion Include="System.ComponentModel.Composition" Version="8.0.0" />
<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.2" />
</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.146" />
<GlobalPackageReference Include="Nullable" Version="1.3.1" />
<GlobalPackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" />
</ItemGroup>
Expand Down
25 changes: 25 additions & 0 deletions azure-pipelines/Get-LibTemplateBasis.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<#
.SYNOPSIS
Returns the name of the well-known branch in the Library.Template repository upon which HEAD is based.
#>
[CmdletBinding(SupportsShouldProcess = $true)]
Param(
[switch]$ErrorIfNotRelated
)

# This list should be sorted in order of decreasing specificity.
$branchMarkers = @(
@{ commit = 'fd0a7b25ccf030bbd16880cca6efe009d5b1fffc'; branch = 'microbuild' };
@{ commit = '05f49ce799c1f9cc696d53eea89699d80f59f833'; branch = 'main' };
)

foreach ($entry in $branchMarkers) {
if (git rev-list HEAD | Select-String -Pattern $entry.commit) {
return $entry.branch
}
}

if ($ErrorIfNotRelated) {
Write-Error "Library.Template has not been previously merged with this repo. Please review https://github.com/AArnott/Library.Template/tree/main?tab=readme-ov-file#readme for instructions."
exit 1
}
2 changes: 2 additions & 0 deletions azure-pipelines/GlobalVariables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ variables:
# These variables are required for MicroBuild tasks
TeamName: VS IDE
TeamEmail: [email protected]
# These variables influence insertion pipelines
ContainsVsix: false # This should be true when the repo builds a VSIX that should be inserted to VS.
17 changes: 0 additions & 17 deletions azure-pipelines/InsertionMetadataPackage.nuspec

This file was deleted.

5 changes: 4 additions & 1 deletion azure-pipelines/OptProf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ variables:
value: false # avoid using nice version since we're building a preliminary/unoptimized package
- name: IsOptProf
value: true
- name: MicroBuild_NuPkgSigningEnabled
value: false # test-signed nuget packages fail to restore in the VS insertion PR validations. Just don't sign them *at all*.

stages:
- stage: Library
Expand All @@ -40,12 +42,13 @@ stages:
- template: build.yml
parameters:
Is1ESPT: false
RealSign: true
RealSign: false
windowsPool: VSEngSS-MicroBuild2022-1ES
EnableMacOSBuild: false
ShouldSkipOptimize: ${{ parameters.ShouldSkipOptimize }}
IsOptProf: true
RunTests: false
SkipCodesignVerify: true
- stage: QueueVSBuild
jobs:
- job: QueueOptProf
Expand Down
4 changes: 3 additions & 1 deletion azure-pipelines/OptProf_part2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ resources:
- pipeline: DartLab.OptProf
source: DartLab.OptProf
branch: main
tags:
- production
repositories:
- repository: DartLabTemplates
type: git
Expand All @@ -22,7 +24,7 @@ resources:
- repository: DartLabOptProfTemplates
type: git
name: DartLab.OptProf
ref: refs/heads/main
ref: refs/tags/Production

parameters:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ Get-ChildItem "$ArtifactStagingFolder\*.pdb" -Recurse |% {
Move-Item $legacyPdbPath $_ -Force
}
}

Write-Host "##vso[artifact.upload containerfolder=symbols-legacy;artifactname=symbols-legacy;]$ArtifactStagingFolder"
35 changes: 9 additions & 26 deletions azure-pipelines/artifacts/VSInsertion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ if (!$BuildConfiguration) {
$BuildConfiguration = 'Debug'
}

$NuGetPackages = "$RepoRoot/bin/Packages/$BuildConfiguration/NuGet"
$PackagesRoot = "$RepoRoot/bin/Packages/$BuildConfiguration"
$NuGetPackages = "$PackagesRoot/NuGet"
$VsixPackages = "$PackagesRoot/Vsix"

if (!(Test-Path $NuGetPackages)) {
Write-Warning "Skipping because NuGet packages haven't been built yet."
Expand All @@ -27,32 +29,13 @@ $result = @{
"$NuGetPackages" = (Get-ChildItem $NuGetPackages -Recurse)
}

if (Test-Path $VsixPackages) {
$result["$PackagesRoot"] += Get-ChildItem $VsixPackages -Recurse
}

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\LibraryName.VSInsertionMetadata.$InsertionMetadataVersion.nupkg");
$VSRepoPackages = "$PackagesRoot/VSRepo"
$result["$VSRepoPackages"] = (Get-ChildItem "$VSRepoPackages\*.VSInsertionMetadata.*.nupkg");
}

$result
25 changes: 23 additions & 2 deletions azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ parameters:
##### Feel free to adjust their default value as needed.

# Whether this repo uses OptProf to optimize the built binaries.
# When enabling this, be sure to update these files:
# - OptProf.targets: InstallationPath and match TestCase selection with what's in the VS repo.
# - The project file(s) for the libraries to optimize must import OptProf.targets (for multi-targeted projects, only import it for ONE target).
# - OptProf.yml: Search for LibraryName (or your library's name) and verify that those names are appropriate.
# - OptProf_part2.yml: Search for LibraryName (or your library's name) and verify that those names are appropriate.
# and create pipelines for OptProf.yml, OptProf_part2.yml
- name: EnableOptProf
type: boolean
default: false
Expand Down Expand Up @@ -65,6 +71,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: SkipCodesignVerify
type: boolean
default: false

- name: EnableAPIScan
type: boolean
default: false
Expand All @@ -85,11 +96,11 @@ parameters:
- name: linuxPool
type: object
default:
vmImage: ubuntu-20.04
vmImage: ubuntu-22.04
- name: macOSPool
type: object
default:
vmImage: macOS-12
vmImage: macOS-14

jobs:
- job: Windows
Expand Down Expand Up @@ -191,6 +202,7 @@ jobs:
parameters:
EnableOptProf: ${{ parameters.EnableOptProf }}
IsOptProf: ${{ parameters.IsOptProf }}
SkipCodesignVerify: ${{ parameters.SkipCodesignVerify }}

- ${{ if not(parameters.IsOptProf) }}:
- ${{ if parameters.EnableLinuxBuild }}:
Expand Down Expand Up @@ -263,6 +275,15 @@ jobs:
- macOS
pool: ${{ parameters.windowsPool }} # Use Windows agent because PublishSymbols task requires it (https://github.com/microsoft/azure-pipelines-tasks/issues/13821).
condition: succeededOrFailed()
${{ if eq(variables['system.collectionId'], '011b8bdf-6d56-4f87-be0d-0092136884d9') }}:
templateContext:
outputParentDirectory: $(Build.ArtifactStagingDirectory)
outputs:
- output: pipelineArtifact
displayName: 📢 Publish symbols-legacy
targetPath: $(Build.ArtifactStagingDirectory)/symbols-legacy
artifactName: symbols-legacy
condition: succeededOrFailed()
steps:
- checkout: self
fetchDepth: 0 # avoid shallow clone so nbgv can do its work.
Expand Down
7 changes: 3 additions & 4 deletions azure-pipelines/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ parameters:

steps:

- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) -warnaserror /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) -warnAsError -warnNotAsError:NU1901,NU1902,NU1903,NU1904 /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
displayName: 🛠 dotnet build

- ${{ if not(parameters.IsOptProf) }}:
Expand All @@ -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
Expand Down
Loading

0 comments on commit 0415b55

Please sign in to comment.