Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into bumpMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed May 9, 2024
2 parents af68891 + 9b7a024 commit 9c9861c
Show file tree
Hide file tree
Showing 48 changed files with 1,169 additions and 456 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
},
"dotnet-coverage": {
"version": "17.9.6",
"version": "17.10.3",
"commands": [
"dotnet-coverage"
]
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.100-jammy
FROM mcr.microsoft.com/dotnet/sdk:8.0.201-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
Empty file added .prettierrc.yaml
Empty file.
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"ms-dotnettools.csharp",
"k--kato.docomment",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"pflannery.vscode-versionlens",
"davidanson.vscode-markdownlint",
"dotjoshjohnson.xml",
Expand Down
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"azure-pipelines.1ESPipelineTemplatesSchemaFile": true,
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true,
"dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true,
"editor.formatOnSave": true,
"[xml]": {
"editor.wordWrap": "off"
}
},
// Treat these files as Azure Pipelines files
"files.associations": {
"**/azure-pipelines/**/*.yml": "azure-pipelines",
"azure-pipelines.yml": "azure-pipelines"
},
// Use Prettier as the default formatter for Azure Pipelines files.
// Needs to be explicitly configured: https://github.com/Microsoft/azure-pipelines-vscode#document-formatting
"[azure-pipelines]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false // enable this when they conform
},
}
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(CodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(CodeAnalysisVersion)" />
<!-- <PackageVersion Include="Microsoft.Dia.Win32Metadata" Version="0.2.185-preview-g7e1e6a442c" /> -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageVersion Include="Microsoft.Windows.SDK.Win32Docs" Version="$(ApiDocsVersion)" />
<PackageVersion Include="Microsoft.Windows.SDK.Win32Metadata" Version="$(MetadataVersion)" />
Expand All @@ -31,11 +31,11 @@
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Reflection.Metadata" Version="7.0.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="4.7.2" />
<PackageVersion Include="System.Text.Encodings.Web" Version="4.7.1" />
<PackageVersion Include="System.Text.Json" Version="4.7.2" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageVersion Include="xunit" Version="2.6.4" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7" />
<PackageVersion Include="xunit" Version="2.7.0" />
</ItemGroup>
<ItemGroup Condition="'$(IsTestProject)'!='true'">
<!-- These versions carefully chosen to support VS 2019 Update 11. -->
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ Install the `Microsoft.Windows.CsWin32` package:
dotnet add package Microsoft.Windows.CsWin32 --prerelease
```

**Tip**: Remove the `IncludeAssets` metadata from the package reference so that you get better code generation by allowing nuget to bring in the `System.Memory` package as a transitive dependency.
You should also install the `System.Memory` package when targeting .NET Framework 4.5+ or .NET Standard 2.0,
as that adds APIs that significantly improve much of the code generated by CsWin32:

```diff
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.647-beta">
<PrivateAssets>all</PrivateAssets>
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
```ps1
dotnet add package System.Memory
```

Projects targeting .NET Core 2.1+ or .NET 5+ do *not* need to add the `System.Memory` package reference,
although it is harmless to do so.

Your project must allow unsafe code to support the generated code that will likely use pointers.
This does *not* automatically make all your code *unsafe*.
Use of the `unsafe` keyword is required anywhere you use pointers.
Expand Down
10 changes: 4 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trigger:
- azure-pipelines/release.yml

parameters:
- name: includeMacOS
- name: EnableMacOSBuild
displayName: Build on macOS
type: boolean
default: false # macOS is often bogged down in Azure Pipelines
Expand All @@ -23,13 +23,11 @@ parameters:
default: true

variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
BuildConfiguration: Release
# #codecov_token: # Get a new one from https://codecov.io/
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages/
- template: /azure-pipelines/BuildStageVariables.yml@self

jobs:
- template: azure-pipelines/build.yml
parameters:
includeMacOS: ${{ parameters.includeMacOS }}
Is1ESPT: false
EnableMacOSBuild: ${{ parameters.EnableMacOSBuild }}
RunTests: ${{ parameters.RunTests }}
5 changes: 5 additions & 0 deletions azure-pipelines/BuildStageVariables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
BuildConfiguration: Release
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages/
# codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/
4 changes: 4 additions & 0 deletions azure-pipelines/GlobalVariables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variables:
# These variables are required for MicroBuild tasks
TeamName: VS IDE
TeamEmail: vsidemicrobuild@microsoft.com
17 changes: 17 additions & 0 deletions azure-pipelines/InsertionMetadataPackage.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package>
<!-- This file is only used in repos where OptProf is enabled. -->
<metadata>
<id>LibraryName.VSInsertionMetadata</id>
<version>$version$</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<!-- <projectUrl>https://github.com/Microsoft/LibraryName</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>
112 changes: 112 additions & 0 deletions azure-pipelines/OptProf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
trigger: none
pr: none
schedules:
- cron: "0 3 * * Fri" # Thu @ 8 or 9 PM Mountain Time (depending on DST)
displayName: Weekly OptProf run
branches:
include:
- 'v*.*'
- main
always: true # we must keep data fresh since optimizationdata drops are purged after 30 days

# Avoid errant CI builds: https://developercommunity.visualstudio.com/content/problem/1154409/azure-pipeline-is-triggering-due-to-events-that-ne.html
#resources:
# repositories:
# - repository: scripts
# type: git
# name: DeploymentScripts
# ref: refs/heads/test

variables:
- template: GlobalVariables.yml
- name: PublicRelease
value: false # avoid using nice version since we're building a preliminary/unoptimized package
- name: IsOptProf
value: true

stages:
- stage: Library
variables:
- name: OptProf
value: true
- template: BuildStageVariables.yml
jobs:
- template: build.yml
parameters:
Is1ESPT: false
RealSign: true
windowsPool: VSEngSS-MicroBuild2022-1ES
EnableMacOSBuild: false
ShouldSkipOptimize: true
IsOptProf: true
RunTests: false
- stage: QueueVSBuild
jobs:
- job: QueueOptProf
pool: VSEngSS-MicroBuild2022-1ES
variables:
InsertPayloadName: LibraryName
InsertTopicBranch: team/VS-IDE/LibraryName-OptProf-run-$(Build.BuildId)
steps:
- checkout: none # We don't need source from our own repo
clean: true

# Pipeline YAML does not yet support checking out other repos. So we'll do it by hand.
# - checkout: scripts # We DO need source from the DeploymentScripts repo
# clean: true
# path: $(Agent.TempDirectory)/DeploymentScripts
# fetchDepth: 1
- script: 'git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" clone https://devdiv.visualstudio.com/DevDiv/_git/DeploymentScripts --depth 1 --branch test "$(Agent.TempDirectory)/DeploymentScripts"'
displayName: Download DeploymentScripts repo

- task: DownloadBuildArtifacts@0
displayName: Download insertion artifacts
inputs:
artifactName: VSInsertion-Windows
downloadPath: $(Agent.TempDirectory)
- task: DownloadBuildArtifacts@0
displayName: Download variables artifacts
inputs:
artifactName: Variables-Windows
downloadPath: $(Agent.TempDirectory)
- task: PowerShell@2
displayName: Set pipeline variables based on artifacts
inputs:
targetType: filePath
filePath: $(Agent.TempDirectory)/Variables-Windows/_pipelines.ps1
- task: NuGetCommand@2
displayName: Push CoreXT packages to VS feed
inputs:
command: push
packagesToPush: $(Agent.TempDirectory)/VSInsertion-Windows/*.nupkg
publishVstsFeed: 97a41293-2972-4f48-8c0e-05493ae82010 # VS feed
allowPackageConflicts: true
- task: MicroBuildInsertVsPayload@4
displayName: Insert VS Payload
inputs:
TeamName: $(TeamName)
TeamEmail: $(TeamEmail)
SkipCreatePR: true
CustomScriptExecutionCommand: src\VSSDK\NuGet\AllowUnstablePackages.ps1
- task: benjhuser.tfs-extensions-build-tasks.trigger-build-task.TriggerBuild@3
displayName: Trigger a new build of DD-CB-TestSignVS-devCI
inputs:
buildDefinition: DD-CB-TestSignVS-devCI
useSameBranch: false
branchToUse: $(InsertTopicBranch)
storeInEnvironmentVariable: true
queueBuildForUserThatTriggeredBuild: false
authenticationMethod: OAuth Token
password: $(System.AccessToken)
- task: PowerShell@2
displayName: Associate InsertionOutputs artifacts with CloudBuild
inputs:
targetType: filePath
filePath: $(Agent.TempDirectory)/DeploymentScripts/Scripts/Insertion/WriteArtifact.ps1
arguments: '-oldBuildID $(Build.BuildId) -newBuildID $(TriggeredBuildIds) -artifactName "InsertionOutputs" -accessToken $(System.AccessToken)'
- task: PowerShell@2
displayName: Tag the build with LibraryName-insertion
inputs:
targetType: filePath
filePath: $(Agent.TempDirectory)/DeploymentScripts/Scripts/Insertion/TagBuild.ps1
arguments: '-buildID $(TriggeredBuildIds) -tagName "LibraryName-insertion" -accessToken $(System.AccessToken)'
89 changes: 89 additions & 0 deletions azure-pipelines/OptProf_part2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
trigger: none
pr: none

resources:
pipelines:
- pipeline: VisualStudioBuildUnderTest
source: DD-CB-TestSignVS-devCI
trigger:
tags:
- LibraryName-insertion
- pipeline: DartLab
source: DartLab
branch: main
- pipeline: DartLab.OptProf
source: DartLab.OptProf
branch: main
repositories:
- repository: DartLabTemplates
type: git
name: DartLab.Templates
ref: refs/heads/main
- repository: DartLabOptProfTemplates
type: git
name: DartLab.OptProf
ref: refs/heads/main

parameters:

# The prefix naming of the OptimizationInputs drop
- name: optimizationDropPrefix
type: string
default: OptimizationInputs/$(System.TeamProject)/$(Build.Repository.Name)

stages:
- template: \templates\stages\visual-studio\single-runsettings.yml@DartLabOptProfTemplates
parameters:
##### Required #####
runSettingsURI: $(Pipeline.Workspace)\VisualStudioBuildUnderTest\BuildArtifacts\runsettings\LibraryName.OptProf.runsettings
visualStudioBootstrapperURI: https://vsdrop.corp.microsoft.com/file/v1/$(VisualStudio.BuildUnderTest.ProductsDropName);bootstrappers/Enterprise/vs_enterprise.exe
##### Optional #####
name: OptProfProfilingWorkflow
displayName: OptProf Profiling Workflow
optOptimizationInputsDropName: $(OptimizationInputsDropName)
previousOptimizationInputsDropName: $(PreviousOptimizationInputsDropName)
testLabPoolName: VS-Platform
##### Step Hooks #####
preTestMachineConfigurationStepList:
- download: VisualStudioBuildUnderTest
- task: PowerShell@2
name: SetProductsDropName
displayName: Set 'VisualStudio.BuildUnderTest.ProductsDropName'
inputs:
filePath: $(DartLab.Path)\Scripts\VisualStudio\Build\Get-VisualStudioDropName.ps1
arguments: -DropNamePrefix 'Products' -VstsDropUrlsJson '$(Pipeline.Workspace)\VisualStudioBuildUnderTest\BuildArtifacts\VstsDropUrls.json' -OutVariableName 'VisualStudio.BuildUnderTest.ProductsDropName'
preDeployAndRunTestsStepList:
- download: VisualStudioBuildUnderTest
prePublishOptimizationInputsDropStepList:
# Set parameter for PreviousOptimizationInputsDropName, MicroBuildCommitID, and OptimizationInputsDropName
- powershell: |
try {
$artifactName = 'InsertionOutputs'
$BuildID = $(resources.pipeline.VisualStudioBuildUnderTest.runID)
$artifact = Get-BuildArtifact -InstanceURL 'https://dev.azure.com/devdiv' -ProjectName 'DevDiv' -BuildID $BuildID -ArtifactName $artifactName -OAuthAccessToken (ConvertTo-SecureString '$(System.AccessToken)' -AsPlainText -Force)
$containerName = $artifact.Resource.Data -Split '/' | Select-Object -Last 1
$fileName = Join-Path $containerName 'Metadata.json'
$jsonString = Read-BuildArtifactFile -InstanceURL 'https://dev.azure.com/devdiv' -ProjectName 'DevDiv' -BuildID $BuildID -ArtifactName $artifactName -FileName $fileName -OAuthAccessToken (ConvertTo-SecureString '$(System.AccessToken)' -AsPlainText -Force)
$json = $jsonString | ConvertFrom-Json
Write-Host "The content of the metadata.json file was $json"
$dropname = $json.OptimizationData
$commitID = $json.CommitID
$OptimizationInputsDropName = "${{parameters.optimizationDropPrefix}}/$($commitID)/$(Build.BuildId)/$(System.StageId)/$(System.StageAttempt)"
Write-Host "PreviousOptimizationInputsDropName: $dropname"
Set-AzurePipelinesVariable 'PreviousOptimizationInputsDropName' $dropname
Write-Host "MicroBuildCommitID: $commitID"
Set-AzurePipelinesVariable 'MicroBuildCommitID' $commitID
Write-Host "OptimizationInputsDropName: $OptimizationInputsDropName"
Set-AzurePipelinesVariable 'OptimizationInputsDropName' $OptimizationInputsDropName
}
catch {
Write-Host $_
Write-Error "Failed to set OptimizationInputsDropName pipeline variable"
throw
}
displayName: Set MicroBuildCommitID, PreviousOptimizationInputsDropName, and OptimizationInputsDropName
5 changes: 5 additions & 0 deletions azure-pipelines/ProfilingInputs.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<TestStore Include="%TESTSTORE%" />
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions azure-pipelines/TSAOptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"tsaVersion": "TsaV2",
"codebase": "NewOrUpdate",
"codebaseName": "LibraryName",
"tsaStamp": "DevDiv",
"tsaEnvironment": "PROD",
"notificationAliases": [
"vsidemicrobuild@microsoft.com"
],
"codebaseAdmins": [
"REDMOND\\andarno"
],
"instanceUrl": "https://devdiv.visualstudio.com",
"projectName": "DevDiv",
"areaPath": "DevDiv\\VS Core",
"iterationPath": "DevDiv",
"alltools": true,
"repositoryName": "Library.Template"
}
Loading

0 comments on commit 9c9861c

Please sign in to comment.