From 05f49ce799c1f9cc696d53eea89699d80f59f833 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 16 Jun 2019 07:01:14 -0600 Subject: [PATCH 001/641] Initial commit --- .gitattributes | 63 ++++ .gitignore | 349 +++++++++++++++++++++++ .vscode/extensions.json | 18 ++ CONTRIBUTING.md | 24 ++ LICENSE | 21 ++ README.md | 31 ++ azure-pipelines.yml | 58 ++++ azure-pipelines/collect-deployables.yml | 15 + azure-pipelines/collect-logs.yml | 9 + azure-pipelines/dotnet.yml | 64 +++++ azure-pipelines/install-dependencies.yml | 25 ++ global.json | 5 + nuget.config | 8 + src/.editorconfig | 157 ++++++++++ src/Directory.Build.props | 35 +++ src/Directory.Build.targets | 8 + src/Library.Tests/CalculatorTests.cs | 28 ++ src/Library.Tests/Library.Tests.csproj | 29 ++ src/Library.Tests/app.config | 5 + src/Library/Calculator.cs | 29 ++ src/Library/Library.csproj | 10 + src/lib.template.sln | 28 ++ src/shipping.ruleset | 74 +++++ src/strongname.snk | Bin 0 -> 596 bytes src/stylecop.json | 15 + src/tests.ruleset | 83 ++++++ version.json | 8 + 27 files changed, 1199 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 azure-pipelines.yml create mode 100644 azure-pipelines/collect-deployables.yml create mode 100644 azure-pipelines/collect-logs.yml create mode 100644 azure-pipelines/dotnet.yml create mode 100644 azure-pipelines/install-dependencies.yml create mode 100644 global.json create mode 100644 nuget.config create mode 100644 src/.editorconfig create mode 100644 src/Directory.Build.props create mode 100644 src/Directory.Build.targets create mode 100644 src/Library.Tests/CalculatorTests.cs create mode 100644 src/Library.Tests/Library.Tests.csproj create mode 100644 src/Library.Tests/app.config create mode 100644 src/Library/Calculator.cs create mode 100644 src/Library/Library.csproj create mode 100644 src/lib.template.sln create mode 100644 src/shipping.ruleset create mode 100644 src/strongname.snk create mode 100644 src/stylecop.json create mode 100644 src/tests.ruleset create mode 100644 version.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..1ff0c4230 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..846c8c0a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,349 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..f910c6876 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,18 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "ms-azure-devops.azure-pipelines", + "ms-vscode.csharp", + "k--kato.docomment", + "editorconfig.editorconfig", + "pflannery.vscode-versionlens", + "davidanson.vscode-markdownlint" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [ + + ] +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..2f36ba668 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,24 @@ +# Contributing + +This project has adopted the [Microsoft Open Source Code of +Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct +FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) +with any additional questions or comments. + +## Prerequisites + +The only prerequisite for building, testing, and deploying from this repository +is the [.NET SDK](https://get.dot.net/). +You should install the version specified in `global.json` or a later version within +the same major.minor.Bxx "hundreds" band. +For example if 2.2.300 is specified, you may install 2.2.300, 2.2.301, or 2.2.310 +while the 2.2.400 version would not be considered compatible by .NET SDK. +See [.NET Core Versioning](https://docs.microsoft.com/en-us/dotnet/core/versions/) for more information. + +This repository can be built on Windows, Linux, and OSX. + +## Building + +Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.). diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..3bb6360cc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) PLACEHOLDER + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 000000000..e99ca933e --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Your Library + +***An awesome template for your awesome library*** + +![NuGet package](https://img.shields.io/badge/nuget-your--package--here-yellow.svg) +[![Build Status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/AArnott.Library.Template?branchName=master)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=29&branchName=master) +[![codecov](https://codecov.io/gh/aarnott/library.template/branch/master/graph/badge.svg)](https://codecov.io/gh/aarnott/library.template) + +## Features + +* Follow the best and simplest patterns of build, pack and test with dotnet CLI. +* Static analyzers: [FxCop](https://docs.microsoft.com/en-us/visualstudio/code-quality/fxcop-analyzers?view=vs-2019) and [StyleCop](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) +* Read-only source tree (builds to top-level bin/obj folders) +* Auto-versioning (via [Nerdbank.GitVersioning](https://github.com/aarnott/nerdbank.gitversioning)) +* Azure Pipeline via YAML with all dependencies declared for long-term serviceability. +* Testing on .NET Framework, multiple .NET Core versions +* Testing on Windows, Linux and OSX +* Code coverage published to Azure Pipelines +* Code coverage published to codecov.io so GitHub PRs get code coverage results added as a PR comment + +## Consumption + +Once you've expanded this template for your own use, you should: + +1. Verify the license is suitable for your goal as it appears in the LICENSE and stylecop.json files + and the Directory.Build.props file's `PackageLicenseExpression` property. +1. Search the repo for all `PLACEHOLDER` occurrences and replace them. +1. Regenerate `src\strongname.snk` file: `sn -k src\strongname.snk` +1. Rename project files, directories, namespaces, and update sln file to match. +1. Reset or remove the `codecov_token` variable in `azure-pipelines.yml` +1. Reset or replace the badges at the top of this file. diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..6d7cf7691 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,58 @@ +trigger: + branches: + include: + - master + - validate/* + paths: + exclude: + - doc/ + - '*.md' + - .vscode/ + +variables: + TreatWarningsAsErrors: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + BuildConfiguration: Release + BuildPlatform: Any CPU + codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # PLACEHOLDER - Get a new one from https://codecov.io/ + +jobs: +- job: Windows + pool: Hosted Windows 2019 with VS2019 + steps: + - template: azure-pipelines/install-dependencies.yml + + - powershell: | + dotnet tool install --tool-path .. nbgv + ../nbgv cloud + displayName: Set build number + workingDirectory: src + + - template: azure-pipelines/dotnet.yml + - template: azure-pipelines/collect-deployables.yml + - template: azure-pipelines/collect-logs.yml + + - task: NuGetCommand@2 + displayName: Push packages to CI feed + inputs: + command: push + packagesToPush: $(Build.ArtifactStagingDirectory)/deployables/*.nupkg;$(Build.ArtifactStagingDirectory)/deployables/*.snupkg + nuGetFeedType: internal + publishVstsFeed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # PLACEHOLDER + allowPackageConflicts: true + +- job: Linux + pool: + vmImage: Ubuntu 16.04 + steps: + - template: azure-pipelines/install-dependencies.yml + - template: azure-pipelines/dotnet.yml + - template: azure-pipelines/collect-logs.yml + +- job: macOS + pool: + vmImage: macOS 10.13 + steps: + - template: azure-pipelines/install-dependencies.yml + - template: azure-pipelines/dotnet.yml + - template: azure-pipelines/collect-logs.yml diff --git a/azure-pipelines/collect-deployables.yml b/azure-pipelines/collect-deployables.yml new file mode 100644 index 000000000..5d77acfca --- /dev/null +++ b/azure-pipelines/collect-deployables.yml @@ -0,0 +1,15 @@ +steps: +- task: CopyFiles@1 + inputs: + Contents: | + bin/Packages/$(BuildConfiguration)/* + TargetFolder: $(Build.ArtifactStagingDirectory)/deployables + flattenFolders: true + displayName: Collecting deployable artifacts + +- task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: $(Build.ArtifactStagingDirectory)/deployables + ArtifactName: deployables + ArtifactType: Container + displayName: Publish deployables artifacts diff --git a/azure-pipelines/collect-logs.yml b/azure-pipelines/collect-logs.yml new file mode 100644 index 000000000..ab39d91f0 --- /dev/null +++ b/azure-pipelines/collect-logs.yml @@ -0,0 +1,9 @@ +steps: + +- task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: $(Build.ArtifactStagingDirectory)/build_logs + ArtifactName: build_logs-$(Agent.JobName) + ArtifactType: Container + displayName: Publish build_logs artifacts + condition: succeededOrFailed() diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml new file mode 100644 index 000000000..f53bc8030 --- /dev/null +++ b/azure-pipelines/dotnet.yml @@ -0,0 +1,64 @@ +steps: +- script: dotnet restore /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/restore.binlog" + displayName: dotnet restore + workingDirectory: src + +- script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" + displayName: dotnet build + workingDirectory: src + +- script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog" + displayName: dotnet pack + workingDirectory: src + +- script: dotnet test --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/net472.trx" /p:CollectCoverage=true + displayName: dotnet test -f net472 + workingDirectory: src + condition: eq(variables['Agent.OS'], 'Windows_NT') + +- script: dotnet test --no-build -c $(BuildConfiguration) -f netcoreapp2.0 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/netcoreapp2.0.trx" /p:CollectCoverage=true + displayName: dotnet test -f netcoreapp2.0 + workingDirectory: src + +- script: dotnet test --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/netcoreapp2.1.trx" /p:CollectCoverage=true + displayName: dotnet test -f netcoreapp2.1 + workingDirectory: src + +- script: dotnet test --no-build -c $(BuildConfiguration) -f netcoreapp2.2 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/netcoreapp2.2.trx" /p:CollectCoverage=true + displayName: dotnet test -f netcoreapp2.2 + workingDirectory: src + +- task: PublishTestResults@2 + displayName: Publish test results + inputs: + testRunner: VSTest + #mergeTestResults: true + testResultsFormat: trx + testResultsFiles: $(Build.ArtifactStagingDirectory)/testlogs/*.trx + failTaskOnFailedTests: true + +- task: PublishCodeCoverageResults@1 + displayName: Publish code coverage results to Azure DevOps + inputs: + codeCoverageTool: cobertura + summaryFileLocation: '**/coverage.cobertura.xml' + +- bash: bash <(curl -s https://codecov.io/bash) + displayName: Publish code coverage results to codecov.io + condition: ne(variables['codecov_token'], '') + +- task: CopyFiles@1 + inputs: + Contents: | + obj/**/project.assets.json + TargetFolder: $(Build.ArtifactStagingDirectory)/projectAssetsJson + displayName: Collecting project.assets.json artifacts + condition: succeededOrFailed() + +- task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: $(Build.ArtifactStagingDirectory)/projectAssetsJson + ArtifactName: projectAssetsJson-$(Agent.JobName) + ArtifactType: Container + displayName: Publish projectAssetsJson artifacts + condition: succeededOrFailed() diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml new file mode 100644 index 000000000..80830cc7f --- /dev/null +++ b/azure-pipelines/install-dependencies.yml @@ -0,0 +1,25 @@ +steps: +- script: dotnet --info + displayName: .NET Core SDK/runtimes (on host) + workingDirectory: $(Agent.HomeDirectory) + +- task: UseDotNet@2 + displayName: Install .NET Core SDK 2.2.300 + inputs: + packageType: sdk + version: 2.2.300 + +- task: UseDotNet@2 + displayName: Install .NET Core runtime 2.0.x + inputs: + packageType: runtime + version: 2.0.x + +- task: UseDotNet@2 + displayName: Install .NET Core runtime 2.1.x + inputs: + packageType: runtime + version: 2.1.x + +- script: dotnet --info + displayName: .NET Core SDK/runtimes (explicitly installed) diff --git a/global.json b/global.json new file mode 100644 index 000000000..932387844 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.2.300" + } +} \ No newline at end of file diff --git a/nuget.config b/nuget.config new file mode 100644 index 000000000..4941d22b8 --- /dev/null +++ b/nuget.config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 000000000..94cda0d5f --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,157 @@ +# EditorConfig is awesome:http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Don't use tabs for indentation. +[*] +indent_style = space + +# (Please don't specify an indent_size here; that has too many unintended consequences.) + +# Code files +[*.{cs,csx,vb,vbx,h,cpp,idl}] +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +# Xml project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +indent_size = 2 + +# Xml config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 + +# JSON files +[*.json] +indent_size = 2 + +# Dotnet code style settings: +[*.{cs,vb}] +# Sort using and Import directives with System.* appearing first +dotnet_sort_system_directives_first = true +dotnet_style_qualification_for_field = true:warning +dotnet_style_qualification_for_property = true:warning +dotnet_style_qualification_for_method = true:warning +dotnet_style_qualification_for_event = true:warning + +# Use language keywords instead of framework type names for type references +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion + +# Suggest more modern language features when available +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion + +# Non-private static fields are PascalCase +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected internal, private protected +dotnet_naming_symbols.non_private_static_fields.required_modifiers = static + +dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case + +# Constants are PascalCase +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants +dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style + +dotnet_naming_symbols.constants.applicable_kinds = field, local +dotnet_naming_symbols.constants.required_modifiers = const + +dotnet_naming_style.constant_style.capitalization = pascal_case + +# Static fields are camelCase +dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields +dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style + +dotnet_naming_symbols.static_fields.applicable_kinds = field +dotnet_naming_symbols.static_fields.required_modifiers = static + +dotnet_naming_style.static_field_style.capitalization = camel_case + +# Instance fields are camelCase +dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields +dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style + +dotnet_naming_symbols.instance_fields.applicable_kinds = field + +dotnet_naming_style.instance_field_style.capitalization = camel_case + +# Locals and parameters are camelCase +dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion +dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters +dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style + +dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local + +dotnet_naming_style.camel_case_style.capitalization = camel_case + +# Local functions are PascalCase +dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function + +dotnet_naming_style.local_function_style.capitalization = pascal_case + +# By default, name items with PascalCase +dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members +dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.all_members.applicable_kinds = * + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +# CSharp code style settings: +[*.cs] +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left + +# Prefer "var" everywhere +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_var_elsewhere = true:suggestion + +# Prefer method-like constructs to have a block body +csharp_style_expression_bodied_methods = false:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none + +# Prefer property-like constructs to have an expression-body +csharp_style_expression_bodied_properties = true:none +csharp_style_expression_bodied_indexers = true:none +csharp_style_expression_bodied_accessors = true:none + +# Suggest more modern language features when available +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# Newline settings +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true + +# Blocks are allowed +csharp_prefer_braces = true:silent diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 000000000..c3f28530e --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,35 @@ + + + + Debug + $(MSBuildThisFileDirectory)..\obj\$(MSBuildProjectName)\ + $(MSBuildThisFileDirectory)..\bin\$(MSBuildProjectName)\ + $(MSBuildThisFileDirectory)..\bin\Packages\$(Configuration)\ + 7.3 + true + + true + $(MSBuildThisFileDirectory)\strongname.snk + + PLACEHOLDER + PLACEHOLDER + MIT + true + true + true + snupkg + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 000000000..1ddcba6f4 --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,8 @@ + + + cobertura + [xunit.*]* + + $(OutputPath)/ + + diff --git a/src/Library.Tests/CalculatorTests.cs b/src/Library.Tests/CalculatorTests.cs new file mode 100644 index 000000000..506ca1b8e --- /dev/null +++ b/src/Library.Tests/CalculatorTests.cs @@ -0,0 +1,28 @@ +// Copyright (c) PLACEHOLDER. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using Library; +using Xunit; +using Xunit.Abstractions; + +public class CalculatorTests +{ + private readonly ITestOutputHelper logger; + + public CalculatorTests(ITestOutputHelper logger) + { + this.logger = logger; + } + + [Fact] + public void AddOrSubtract() + { + // This tests aggregation of code coverage. +#if NETCOREAPP2_0 + Assert.Equal(3, Calculator.Add(1, 2)); +#else + Assert.Equal(-1, Calculator.Subtract(1, 2)); +#endif + } +} diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj new file mode 100644 index 000000000..fc8854183 --- /dev/null +++ b/src/Library.Tests/Library.Tests.csproj @@ -0,0 +1,29 @@ + + + + net472;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2 + false + $(NoWarn);CS1591 + true + ..\tests.ruleset + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/src/Library.Tests/app.config b/src/Library.Tests/app.config new file mode 100644 index 000000000..61890f055 --- /dev/null +++ b/src/Library.Tests/app.config @@ -0,0 +1,5 @@ + + + + + diff --git a/src/Library/Calculator.cs b/src/Library/Calculator.cs new file mode 100644 index 000000000..826790509 --- /dev/null +++ b/src/Library/Calculator.cs @@ -0,0 +1,29 @@ +// Copyright (c) PLACEHOLDER. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Library +{ + using System; + + /// + /// My first class. + /// + public static class Calculator + { + /// + /// Adds two integers. + /// + /// The first integer. + /// The second integer. + /// The sum of the two integers. + public static int Add(int a, int b) => a + b; + + /// + /// Subtracts one integer from another. + /// + /// The original integer. + /// The integer to subtract. + /// The difference between the two integers. + public static int Subtract(int a, int b) => a - b; + } +} diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj new file mode 100644 index 000000000..aa8cf2c62 --- /dev/null +++ b/src/Library/Library.csproj @@ -0,0 +1,10 @@ + + + + netstandard2.0 + ..\shipping.ruleset + + PLACEHOLDER + + + diff --git a/src/lib.template.sln b/src/lib.template.sln new file mode 100644 index 000000000..17645391b --- /dev/null +++ b/src/lib.template.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library.Tests", "Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C06D702E-6FC7-453B-BDDF-608F825EC003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C06D702E-6FC7-453B-BDDF-608F825EC003}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C06D702E-6FC7-453B-BDDF-608F825EC003}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C06D702E-6FC7-453B-BDDF-608F825EC003}.Release|Any CPU.Build.0 = Release|Any CPU + {DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/shipping.ruleset b/src/shipping.ruleset new file mode 100644 index 000000000..729035460 --- /dev/null +++ b/src/shipping.ruleset @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/strongname.snk b/src/strongname.snk new file mode 100644 index 0000000000000000000000000000000000000000..a4d0a2ce39df5f7c284340b4a2c4690385c44208 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097Td7B6KsP|cl#<{bONo_!&t)QUG9wW^j zM1zvNAOI=XF}potSO>54lS%MGl8tv)xYTSw?~K<1McvNlJ;DITeY__C?><|;F`bgX zj;&2ME}KBWPb0zVSK+iW?{2`tzZR-#x0K_|t&0FhD+3urA!lNmCH;&b|?g|_AC39ox-0 zcV%KJis3}%`RVWSXN58fc}#LF$A#kcB2VWh=MH0zs+k7{ zQT<5V>NGhWzC7Jnt4A?n%Kk`fPt&FR4k~q{TSW%@D{plIpotzop}i+x`~C))*Vr-i zrW2)aE17f*=wCRa_#bHkYlQko_Jh)wN@;?yML9mYk)XZ`l6IQ*D7xZmmL=m(T|zMG i={(T>StYQl!YSPV literal 0 HcmV?d00001 diff --git a/src/stylecop.json b/src/stylecop.json new file mode 100644 index 000000000..f1d8168cb --- /dev/null +++ b/src/stylecop.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "companyName": "PLACEHOLDER", + "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.", + "variables": { + "licenseName": "MIT", + "licenseFile": "LICENSE" + }, + "fileNamingConvention": "metadata", + "xmlHeader": false + } + } +} \ No newline at end of file diff --git a/src/tests.ruleset b/src/tests.ruleset new file mode 100644 index 000000000..c74c6ed34 --- /dev/null +++ b/src/tests.ruleset @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/version.json b/version.json new file mode 100644 index 000000000..38da1662c --- /dev/null +++ b/version.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "0.1-beta", + "publicReleaseRefSpec": [ + "^refs/heads/master$", + "^refs/heads/v\\d+(?:\\.\\d+)?$" + ] +} \ No newline at end of file From 9a6c1df41cb75c41b7b5039aaddbe59456a93366 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 16 Jun 2019 21:32:09 -0600 Subject: [PATCH 002/641] Add VS Code whitespace settings --- .vscode/settings.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..f0cafc05f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true +} From 26696c117d5f65dbcdf91209ae0b0816593cec4d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 16 Jun 2019 22:24:54 -0600 Subject: [PATCH 003/641] Add script for proper expansion Closes #3 --- Expand-Template.ps1 | 148 ++++++++++++++++++++++++++ LICENSE | 2 +- README.md | 13 +-- azure-pipelines.yml | 11 +- azure-pipelines/expand-template.yml | 10 ++ src/Directory.Build.props | 6 +- src/Library.Tests/CalculatorTests.cs | 2 +- src/{lib.template.sln => Library.sln} | 0 src/Library/Calculator.cs | 2 +- src/Library/Library.csproj | 2 - src/stylecop.json | 4 +- 11 files changed, 179 insertions(+), 21 deletions(-) create mode 100644 Expand-Template.ps1 create mode 100644 azure-pipelines/expand-template.yml rename src/{lib.template.sln => Library.sln} (100%) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 new file mode 100644 index 000000000..edde82a0f --- /dev/null +++ b/Expand-Template.ps1 @@ -0,0 +1,148 @@ +<# +.SYNOPSIS +Expands this template into an actual project, taking values for placeholders +.PARAMETER Name +The name of the library +#> +[CmdletBinding()] +Param( + [Parameter(Mandatory=$true)] + [string]$LibraryName, + [Parameter(Mandatory=$true)] + [string]$Author, + [Parameter()] + [string]$CodeCovToken, + [Parameter()] + [string]$CIFeed +) + +function Replace-Placeholders { + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)] + [string]$Path, + [Parameter(Mandatory=$true)] + $Replacements + ) + + $Path = Resolve-Path $Path + Write-Host "Replacing tokens in `"$Path`"" + $content = Get-Content -Path $Path | Out-String + $Replacements.GetEnumerator() |% { + $modifiedContent = $content -replace $_.Key,$_.Value + if ($modifiedContent -eq $content) { + Write-Error "No $($_.Key) token found to replace." + } + $content = $modifiedContent + } + $content = $content.TrimEnd(("`r","`n")) + [System.IO.File]::WriteAllLines($Path, $content) # Don't use Set-Content because that adds a UTF8 BOM + git add $Path +} + +# Try to find sn.exe if it isn't on the PATH +$sn = Get-Command sn -ErrorAction SilentlyContinue +if (-not $sn) { + $snExes = Get-ChildItem -Recurse "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\sn.exe" + if ($snExes) { + $sn = Get-Command $snExes[0].FullName + } else { + Write-Error "sn command not found on PATH and SDK could not be found." + exit(1) + } +} + +# Verify all commands we use are on the PATH +('git','dotnet') |% { + if (-not (Get-Command $_ -ErrorAction SilentlyContinue)) { + Write-Error "$_ command not found on PATH." + exit(1) + } +} + +Push-Location $PSScriptRoot +try { + # Rename project directories and solution + Set-Location src + git mv Library.sln "$LibraryName.sln" + git mv Library/Library.csproj "Library/$LibraryName.csproj" + git mv Library "$LibraryName" + git mv Library.Tests/Library.Tests.csproj "Library.Tests/$LibraryName.Tests.csproj" + git mv Library.Tests "$LibraryName.Tests" + + # Refresh solution file both to update paths and give the projects unique GUIDs + dotnet sln remove Library/Library.csproj + dotnet sln remove Library.Tests/Library.Tests.csproj + dotnet sln add "$LibraryName" + dotnet sln add "$LibraryName.Tests" + git add "$LibraryName.sln" + + # Update project reference in test project. Add before removal to keep the same ItemGroup in place. + dotnet add "$LibraryName.Tests" reference "$LibraryName" + dotnet remove "$LibraryName.Tests" reference Library/Library.csproj + git add "$LibraryName.Tests/$LibraryName.Tests.csproj" + + # Establish a new strong-name key + & $sn.Path -k 2048 strongname.snk + git add strongname.snk + + Set-Location .. + + # Replace placeholders in source files + Replace-Placeholders -Path "src/$LibraryName/Calculator.cs" -Replacements @{ + 'Library'=$LibraryName + 'COMPANY-PLACEHOLDER'=$Author + } + Replace-Placeholders -Path "src/$LibraryName.Tests/CalculatorTests.cs" -Replacements @{ + 'Library'=$LibraryName + 'COMPANY-PLACEHOLDER'=$Author + } + Replace-Placeholders -Path "LICENSE" -Replacements @{ + 'COMPANY-PLACEHOLDER'=$Author + } + Replace-Placeholders -Path "src/stylecop.json" -Replacements @{ + 'COMPANY-PLACEHOLDER'=$Author + } + Replace-Placeholders -Path "src/Directory.Build.props" -Replacements @{ + 'COMPANY-PLACEHOLDER'=$Author + } + Replace-Placeholders -Path "README.md" -Replacements @{ + "(?m)^.*\[NuGet package\][^`r`n]*"="[![NuGet package](https://img.shields.io/nuget/v/$LibraryName.svg)](https://nuget.org/packages/$LibraryName)" + "(?m)^.*\[Build Status\].*`r?`n"="" + "(?m)^.*\[codecov\].*`r?`n"="" + } + + # Specially handle azure-pipelines.yml edits + $YmlReplacements = @{ + "(?m).*expand-template\.yml(?:\r)?\n" = "" + } + if ($CodeCovToken) { + $YmlReplacements['(codecov_token: ).*(#.*)'] = "`$1$CodeCovToken" + } else { + $YmlReplacements['(codecov_token: ).*(#.*)'] = "#`$1`$2" + } + if ($CIFeed) { + $YmlReplacements['(ci_feed: ).*(#.*)'] = "`$1$CIFeed" + } else { + $YmlReplacements['(ci_feed: ).*(#.*)'] = "#`$1`$2" + } + Replace-Placeholders -Path "azure-pipelines.yml" -Replacements $YmlReplacements + + # Self destruct + $Invocation = (Get-Variable MyInvocation -Scope 1).Value + git rm Expand-Template.ps1 + git rm :/azure-pipelines/expand-template.yml + + # Self-integrity check + Get-ChildItem -Recurse -File -Exclude bin,obj,README.md,Expand-Template.ps1 |? { -not $_.FullName.Contains("obj") } |% { + $PLACEHOLDERS = Get-Content -Path $_.FullName |? { $_.Contains('PLACEHOLDER') } + if ($PLACEHOLDERS) { + Write-Error "PLACEHOLDER discovered in $($_.FullName)" + } + } +} finally { + Pop-Location +} + +# When testing this script, all the changes can be quickly reverted with this command: +# git reset HEAD :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git co -- :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git clean -fd :/src diff --git a/LICENSE b/LICENSE index 3bb6360cc..44122ac6e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) PLACEHOLDER +Copyright (c) COMPANY-PLACEHOLDER Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e99ca933e..d05ac0d72 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,9 @@ ## Consumption -Once you've expanded this template for your own use, you should: - -1. Verify the license is suitable for your goal as it appears in the LICENSE and stylecop.json files - and the Directory.Build.props file's `PackageLicenseExpression` property. -1. Search the repo for all `PLACEHOLDER` occurrences and replace them. -1. Regenerate `src\strongname.snk` file: `sn -k src\strongname.snk` -1. Rename project files, directories, namespaces, and update sln file to match. -1. Reset or remove the `codecov_token` variable in `azure-pipelines.yml` +Once you've expanded this template for your own use, you should **run the `Expand-Template.ps1` script** to customize the template for your own project. + +Further customize your repo by: + +1. Verify the license is suitable for your goal as it appears in the LICENSE and stylecop.json files and the Directory.Build.props file's `PackageLicenseExpression` property. 1. Reset or replace the badges at the top of this file. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6d7cf7691..a670bbef0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,13 +8,14 @@ trigger: - doc/ - '*.md' - .vscode/ - + variables: TreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BuildConfiguration: Release BuildPlatform: Any CPU - codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # PLACEHOLDER - Get a new one from https://codecov.io/ + codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ + ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed jobs: - job: Windows @@ -31,6 +32,7 @@ jobs: - template: azure-pipelines/dotnet.yml - template: azure-pipelines/collect-deployables.yml - template: azure-pipelines/collect-logs.yml + - template: azure-pipelines/expand-template.yml - task: NuGetCommand@2 displayName: Push packages to CI feed @@ -38,8 +40,9 @@ jobs: command: push packagesToPush: $(Build.ArtifactStagingDirectory)/deployables/*.nupkg;$(Build.ArtifactStagingDirectory)/deployables/*.snupkg nuGetFeedType: internal - publishVstsFeed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # PLACEHOLDER + publishVstsFeed: $(ci_feed) allowPackageConflicts: true + condition: ne(variables['ci_feed'], '') - job: Linux pool: @@ -48,6 +51,7 @@ jobs: - template: azure-pipelines/install-dependencies.yml - template: azure-pipelines/dotnet.yml - template: azure-pipelines/collect-logs.yml + - template: azure-pipelines/expand-template.yml - job: macOS pool: @@ -56,3 +60,4 @@ jobs: - template: azure-pipelines/install-dependencies.yml - template: azure-pipelines/dotnet.yml - template: azure-pipelines/collect-logs.yml + - template: azure-pipelines/expand-template.yml diff --git a/azure-pipelines/expand-template.yml b/azure-pipelines/expand-template.yml new file mode 100644 index 000000000..74960e566 --- /dev/null +++ b/azure-pipelines/expand-template.yml @@ -0,0 +1,10 @@ +steps: +- script: git clean -fdx + displayName: Cleaning repo for template expansion +- powershell: ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott" + displayName: Expanding template + failOnStderr: true +# TODO: Verify that all changes are staged to the git index +- script: dotnet build + workingDirectory: src + displayName: dotnet build (expanded template) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index c3f28530e..7b354beb7 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -11,8 +11,8 @@ true $(MSBuildThisFileDirectory)\strongname.snk - PLACEHOLDER - PLACEHOLDER + COMPANY-PLACEHOLDER + COMPANY-PLACEHOLDER MIT true true @@ -32,4 +32,4 @@ - \ No newline at end of file + diff --git a/src/Library.Tests/CalculatorTests.cs b/src/Library.Tests/CalculatorTests.cs index 506ca1b8e..2166fb1fb 100644 --- a/src/Library.Tests/CalculatorTests.cs +++ b/src/Library.Tests/CalculatorTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) PLACEHOLDER. All rights reserved. +// Copyright (c) COMPANY-PLACEHOLDER. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; diff --git a/src/lib.template.sln b/src/Library.sln similarity index 100% rename from src/lib.template.sln rename to src/Library.sln diff --git a/src/Library/Calculator.cs b/src/Library/Calculator.cs index 826790509..9156a1a34 100644 --- a/src/Library/Calculator.cs +++ b/src/Library/Calculator.cs @@ -1,4 +1,4 @@ -// Copyright (c) PLACEHOLDER. All rights reserved. +// Copyright (c) COMPANY-PLACEHOLDER. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Library diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index aa8cf2c62..ae6eca97c 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -3,8 +3,6 @@ netstandard2.0 ..\shipping.ruleset - - PLACEHOLDER diff --git a/src/stylecop.json b/src/stylecop.json index f1d8168cb..379189493 100644 --- a/src/stylecop.json +++ b/src/stylecop.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "settings": { "documentationRules": { - "companyName": "PLACEHOLDER", + "companyName": "COMPANY-PLACEHOLDER", "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.", "variables": { "licenseName": "MIT", @@ -12,4 +12,4 @@ "xmlHeader": false } } -} \ No newline at end of file +} From 159d180e61350798bbbc3fc94845ac0242a8fc11 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 18 Jun 2019 07:08:34 -0600 Subject: [PATCH 004/641] Fix test run names --- azure-pipelines/dotnet.yml | 42 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index f53bc8030..3e294f0b6 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -11,37 +11,45 @@ steps: displayName: dotnet pack workingDirectory: src -- script: dotnet test --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/net472.trx" /p:CollectCoverage=true +- task: DotNetCoreCLI@2 displayName: dotnet test -f net472 - workingDirectory: src + inputs: + command: test + arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + testRunTitle: net472-$(Agent.JobName) + workingDirectory: src condition: eq(variables['Agent.OS'], 'Windows_NT') -- script: dotnet test --no-build -c $(BuildConfiguration) -f netcoreapp2.0 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/netcoreapp2.0.trx" /p:CollectCoverage=true +- task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp2.0 - workingDirectory: src + inputs: + command: test + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + testRunTitle: netcoreapp2.0-$(Agent.JobName) + workingDirectory: src -- script: dotnet test --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/netcoreapp2.1.trx" /p:CollectCoverage=true +- task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp2.1 - workingDirectory: src - -- script: dotnet test --no-build -c $(BuildConfiguration) -f netcoreapp2.2 --filter "TestCategory!=FailsInCloudTest" -v n -l "trx;LogFileName=$(Build.ArtifactStagingDirectory)/testlogs/netcoreapp2.2.trx" /p:CollectCoverage=true + inputs: + command: test + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + testRunTitle: netcoreapp2.1-$(Agent.JobName) + workingDirectory: src + +- task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp2.2 - workingDirectory: src - -- task: PublishTestResults@2 - displayName: Publish test results inputs: - testRunner: VSTest - #mergeTestResults: true - testResultsFormat: trx - testResultsFiles: $(Build.ArtifactStagingDirectory)/testlogs/*.trx - failTaskOnFailedTests: true + command: test + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.2 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + testRunTitle: netcoreapp2.2-$(Agent.JobName) + workingDirectory: src - task: PublishCodeCoverageResults@1 displayName: Publish code coverage results to Azure DevOps inputs: codeCoverageTool: cobertura summaryFileLocation: '**/coverage.cobertura.xml' + failIfCoverageEmpty: true - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io From 42d3ae5b22f73214c17035277317bf324a430eeb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 20 Jun 2019 15:25:57 -0600 Subject: [PATCH 005/641] Fill in missing parameter docs in the ps1 script --- Expand-Template.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index edde82a0f..c1447d4c9 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -1,8 +1,15 @@ <# .SYNOPSIS Expands this template into an actual project, taking values for placeholders -.PARAMETER Name -The name of the library +.PARAMETER LibraryName +The name of the library. Should consist only of alphanumeric characters and periods. +.PARAMETER Author +The name to use in copyright and owner notices. +.PARAMETER CodeCovToken +A token obtained from codecov.io for your repo. If not specified, code coverage results will not be published to codecov.io, +but can be added later by editing the Azure Pipelines YAML file. +.PARAMETER CIFeed +The `/{guid}` path to the Azure Pipelines artifact feed to push your nuget package to as part of your CI. #> [CmdletBinding()] Param( From 0f19c143cae80dbcf9079d18d6aba4592abbbd10 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 21 Jun 2019 07:32:46 -0600 Subject: [PATCH 006/641] Publish merged code coverage from all test runs on Windows agent Merge code coverage from all test runs on each agent. Although we capture that merged result from each agent as its own build artifact, we have to pick just one agent's merged result to publish to ADO as the summary file. --- azure-pipelines/dotnet.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 3e294f0b6..b86e4bd3f 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -44,12 +44,27 @@ steps: testRunTitle: netcoreapp2.2-$(Agent.JobName) workingDirectory: src +- powershell: | + dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool + $Inputs = [string]::join(';', (Get-ChildItem bin/coverage.cobertura.xml -Recurse |% { Resolve-Path -Relative $_ })) + obj/reportgenerator -reports:"$Inputs" -targetdir:"$(Build.ArtifactStagingDirectory)/coverageResults" -reporttypes:Cobertura + displayName: Merge code coverage results + +- task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: $(Build.ArtifactStagingDirectory)/coverageResults + ArtifactName: coverageResults-$(Agent.JobName) + ArtifactType: Container + displayName: Publish coverageResults artifacts + condition: succeededOrFailed() + - task: PublishCodeCoverageResults@1 displayName: Publish code coverage results to Azure DevOps inputs: codeCoverageTool: cobertura - summaryFileLocation: '**/coverage.cobertura.xml' + summaryFileLocation: $(Build.ArtifactStagingDirectory)/coverageResults/Cobertura.xml failIfCoverageEmpty: true + condition: eq(variables['Agent.OS'], 'Windows_NT') # We have to pick just one agent to publish the code coverage summary file (https://github.com/tonerdo/coverlet/issues/474#issuecomment-504446150) - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io From fc34ef4c21bed5c1c06c5df75800f74db297d03a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 21 Jun 2019 11:57:51 -0600 Subject: [PATCH 007/641] Merge code coverage from all test runs and agents (#9) --- azure-pipelines.yml | 11 ++++++++ azure-pipelines/dotnet.yml | 28 ++++++++++--------- azure-pipelines/publish-codecoverage.yml | 34 ++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 azure-pipelines/publish-codecoverage.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a670bbef0..a41bc3369 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -61,3 +61,14 @@ jobs: - template: azure-pipelines/dotnet.yml - template: azure-pipelines/collect-logs.yml - template: azure-pipelines/expand-template.yml + +- job: MergeCoverage + dependsOn: + - Windows + - Linux + - macOS + pool: + vmImage: Ubuntu 16.04 + steps: + - template: azure-pipelines/install-dependencies.yml + - template: azure-pipelines/publish-codecoverage.yml diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index b86e4bd3f..72f3b5a24 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -44,11 +44,23 @@ steps: testRunTitle: netcoreapp2.2-$(Agent.JobName) workingDirectory: src +- task: CopyFiles@1 + inputs: + Contents: | + bin/**/coverage.cobertura.xml + obj/**/*.cs + TargetFolder: $(Build.ArtifactStagingDirectory)/coverageResults + displayName: Collecting coverage.cobertura.xml artifacts + condition: succeededOrFailed() + - powershell: | - dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool - $Inputs = [string]::join(';', (Get-ChildItem bin/coverage.cobertura.xml -Recurse |% { Resolve-Path -Relative $_ })) - obj/reportgenerator -reports:"$Inputs" -targetdir:"$(Build.ArtifactStagingDirectory)/coverageResults" -reporttypes:Cobertura - displayName: Merge code coverage results + Write-Host "Substituting $(System.DefaultWorkingDirectory) with {reporoot}" + $reports = Get-ChildItem "$(Build.ArtifactStagingDirectory)/coverageResults/coverage.cobertura.xml" -Recurse + $reports |% { + $content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape("$(System.DefaultWorkingDirectory)"), "{reporoot}" } + Set-Content -Path $_ -Value $content -Encoding UTF8 + } + displayName: Preparing code coverage reports for merging on another machine - task: PublishBuildArtifacts@1 inputs: @@ -58,14 +70,6 @@ steps: displayName: Publish coverageResults artifacts condition: succeededOrFailed() -- task: PublishCodeCoverageResults@1 - displayName: Publish code coverage results to Azure DevOps - inputs: - codeCoverageTool: cobertura - summaryFileLocation: $(Build.ArtifactStagingDirectory)/coverageResults/Cobertura.xml - failIfCoverageEmpty: true - condition: eq(variables['Agent.OS'], 'Windows_NT') # We have to pick just one agent to publish the code coverage summary file (https://github.com/tonerdo/coverlet/issues/474#issuecomment-504446150) - - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml new file mode 100644 index 000000000..fc5307817 --- /dev/null +++ b/azure-pipelines/publish-codecoverage.yml @@ -0,0 +1,34 @@ +steps: +- task: DownloadBuildArtifacts@0 + displayName: Download Windows code coverage results + inputs: + artifactName: coverageResults-Windows + downloadPath: $(System.DefaultWorkingDirectory)/bin +- task: DownloadBuildArtifacts@0 + displayName: Download Linux code coverage results + inputs: + artifactName: coverageResults-Linux + downloadPath: $(System.DefaultWorkingDirectory)/bin +- task: DownloadBuildArtifacts@0 + displayName: Download macOS code coverage results + inputs: + artifactName: coverageResults-macOS + downloadPath: $(System.DefaultWorkingDirectory)/bin +- powershell: | + dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 + Copy-Item -Recurse $(System.DefaultWorkingDirectory)/bin/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj + Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" + $reports = Get-ChildItem -Recurse "$(System.DefaultWorkingDirectory)/bin/coverage.cobertura.xml" + $reports |% { + $content = Get-Content -Path $_ |% { $_.Replace("{reporoot}", "$(System.DefaultWorkingDirectory)") } + Set-Content -Path $_ -Value $content -Encoding UTF8 + } + $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_ })) + obj/reportgenerator -reports:"$Inputs" -targetdir:coveragereport -reporttypes:Cobertura + displayName: Merge coverage +- task: PublishCodeCoverageResults@1 + displayName: Publish code coverage results to Azure DevOps + inputs: + codeCoverageTool: cobertura + summaryFileLocation: 'coveragereport/Cobertura.xml' + failIfCoverageEmpty: true From 753dd46974212dafd30b4e60d16f545a84ca695c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 24 Jun 2019 10:33:03 -0600 Subject: [PATCH 008/641] Avoid `var` when type is not apparent --- src/.editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/.editorconfig b/src/.editorconfig index 94cda0d5f..03c2bcf34 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -126,7 +126,7 @@ csharp_indent_labels = flush_left # Prefer "var" everywhere csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion -csharp_style_var_elsewhere = true:suggestion +csharp_style_var_elsewhere = false:warning # Prefer method-like constructs to have a block body csharp_style_expression_bodied_methods = false:none From e1d68f227cc93a873a8903bb25a78c58b979b2cf Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 07:10:13 -0600 Subject: [PATCH 009/641] Update packages (#14) And a few path manipulating msbuild properties --- src/Directory.Build.props | 13 +++++++------ src/Library.Tests/Library.Tests.csproj | 12 +++--------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7b354beb7..f4ef32972 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,9 +2,10 @@ Debug - $(MSBuildThisFileDirectory)..\obj\$(MSBuildProjectName)\ - $(MSBuildThisFileDirectory)..\bin\$(MSBuildProjectName)\ - $(MSBuildThisFileDirectory)..\bin\Packages\$(Configuration)\ + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\')) + $(RepoRootPath)obj\$(MSBuildProjectName)\ + $(RepoRootPath)bin\$(MSBuildProjectName)\ + $(RepoRootPath)bin\Packages\$(Configuration)\ 7.3 true @@ -22,11 +23,11 @@ - - - + + + diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj index fc8854183..b5f05f5fe 100644 --- a/src/Library.Tests/Library.Tests.csproj +++ b/src/Library.Tests/Library.Tests.csproj @@ -14,16 +14,10 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + + - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + From 835ffb69827c68498e96caf0e27640eb939a48b2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 07:34:44 -0600 Subject: [PATCH 010/641] Drop .NET Core 2.0 targeting in test project (#13) Microsoft's long-term support for .NET Core 1.x and 2.0 [are over][LTS]. Customers targeting these versions are in a really bad place due to no security patches being offered and thus there are likely few to none out there. [LTS]: https://github.com/dotnet/core/blob/e2f22a7106860c0e5dc98bb36dc648a779944ad5/microsoft-support.md#net-core-releases --- azure-pipelines/dotnet.yml | 8 -------- src/Library.Tests/CalculatorTests.cs | 4 ++-- src/Library.Tests/Library.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 72f3b5a24..fe055ef7a 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -20,14 +20,6 @@ steps: workingDirectory: src condition: eq(variables['Agent.OS'], 'Windows_NT') -- task: DotNetCoreCLI@2 - displayName: dotnet test -f netcoreapp2.0 - inputs: - command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true - testRunTitle: netcoreapp2.0-$(Agent.JobName) - workingDirectory: src - - task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp2.1 inputs: diff --git a/src/Library.Tests/CalculatorTests.cs b/src/Library.Tests/CalculatorTests.cs index 2166fb1fb..84fe9a97c 100644 --- a/src/Library.Tests/CalculatorTests.cs +++ b/src/Library.Tests/CalculatorTests.cs @@ -18,8 +18,8 @@ public CalculatorTests(ITestOutputHelper logger) [Fact] public void AddOrSubtract() { - // This tests aggregation of code coverage. -#if NETCOREAPP2_0 + // This tests aggregation of code coverage across test runs. +#if NETCOREAPP2_1 Assert.Equal(3, Calculator.Add(1, 2)); #else Assert.Equal(-1, Calculator.Subtract(1, 2)); diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj index b5f05f5fe..7323c8d96 100644 --- a/src/Library.Tests/Library.Tests.csproj +++ b/src/Library.Tests/Library.Tests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2 + net472;netcoreapp2.1;netcoreapp2.2 false $(NoWarn);CS1591 true From 720653e55004b99971cf095cac2ade5748f41fed Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 08:35:27 -0600 Subject: [PATCH 011/641] Merge test results even on build/test failure --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a41bc3369..79cc4269d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -69,6 +69,7 @@ jobs: - macOS pool: vmImage: Ubuntu 16.04 + condition: succeededOrFailed() steps: - template: azure-pipelines/install-dependencies.yml - template: azure-pipelines/publish-codecoverage.yml From 5806251694796175fbfa806406d27e8018c64eed Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 08:39:17 -0600 Subject: [PATCH 012/641] dotnet tool install resilience against authenticated feeds --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 79cc4269d..5d87afbe6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,7 +24,7 @@ jobs: - template: azure-pipelines/install-dependencies.yml - powershell: | - dotnet tool install --tool-path .. nbgv + dotnet tool install --tool-path .. nbgv --ignore-failed-sources ../nbgv cloud displayName: Set build number workingDirectory: src From 3367e54100fa8ba0b58c7d394fa3b5c1dca03d3c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 17:37:37 -0600 Subject: [PATCH 013/641] Switch artifact collection and some variables to ps1 scripts --- .gitignore | 7 +-- azure-pipelines.yml | 6 +-- azure-pipelines/artifacts/Variables.ps1 | 40 ++++++++++++++ azure-pipelines/artifacts/_all.ps1 | 45 ++++++++++++++++ azure-pipelines/artifacts/_pipelines.ps1 | 52 +++++++++++++++++++ azure-pipelines/artifacts/build_logs.ps1 | 10 ++++ azure-pipelines/artifacts/coverageResults.ps1 | 20 +++++++ azure-pipelines/artifacts/deployables.ps1 | 11 ++++ .../artifacts/projectAssetsJson.ps1 | 7 +++ azure-pipelines/collect-deployables.yml | 15 ------ azure-pipelines/collect-logs.yml | 9 ---- azure-pipelines/dotnet.yml | 44 +++------------- azure-pipelines/install-dependencies.yml | 10 +++- .../variables/DotNetSdkVersion.ps1 | 2 + azure-pipelines/variables/_all.ps1 | 10 ++++ azure-pipelines/variables/_pipelines.ps1 | 15 ++++++ 16 files changed, 230 insertions(+), 73 deletions(-) create mode 100644 azure-pipelines/artifacts/Variables.ps1 create mode 100644 azure-pipelines/artifacts/_all.ps1 create mode 100644 azure-pipelines/artifacts/_pipelines.ps1 create mode 100644 azure-pipelines/artifacts/build_logs.ps1 create mode 100644 azure-pipelines/artifacts/coverageResults.ps1 create mode 100644 azure-pipelines/artifacts/deployables.ps1 create mode 100644 azure-pipelines/artifacts/projectAssetsJson.ps1 delete mode 100644 azure-pipelines/collect-deployables.yml delete mode 100644 azure-pipelines/collect-logs.yml create mode 100644 azure-pipelines/variables/DotNetSdkVersion.ps1 create mode 100644 azure-pipelines/variables/_all.ps1 create mode 100644 azure-pipelines/variables/_pipelines.ps1 diff --git a/.gitignore b/.gitignore index 846c8c0a3..fc1d26fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -55,11 +55,6 @@ dlldata.c # Benchmark Results BenchmarkDotNet.Artifacts/ -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - # StyleCop StyleCopReport.xml @@ -346,4 +341,4 @@ ASALocalRun/ healthchecksdb # Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ \ No newline at end of file +MigrationBackup/ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d87afbe6..52451bc17 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,15 +30,13 @@ jobs: workingDirectory: src - template: azure-pipelines/dotnet.yml - - template: azure-pipelines/collect-deployables.yml - - template: azure-pipelines/collect-logs.yml - template: azure-pipelines/expand-template.yml - task: NuGetCommand@2 displayName: Push packages to CI feed inputs: command: push - packagesToPush: $(Build.ArtifactStagingDirectory)/deployables/*.nupkg;$(Build.ArtifactStagingDirectory)/deployables/*.snupkg + packagesToPush: $(Build.ArtifactStagingDirectory)/deployables-Windows/*.nupkg;$(Build.ArtifactStagingDirectory)/deployables-Windows/*.snupkg nuGetFeedType: internal publishVstsFeed: $(ci_feed) allowPackageConflicts: true @@ -50,7 +48,6 @@ jobs: steps: - template: azure-pipelines/install-dependencies.yml - template: azure-pipelines/dotnet.yml - - template: azure-pipelines/collect-logs.yml - template: azure-pipelines/expand-template.yml - job: macOS @@ -59,7 +56,6 @@ jobs: steps: - template: azure-pipelines/install-dependencies.yml - template: azure-pipelines/dotnet.yml - - template: azure-pipelines/collect-logs.yml - template: azure-pipelines/expand-template.yml - job: MergeCoverage diff --git a/azure-pipelines/artifacts/Variables.ps1 b/azure-pipelines/artifacts/Variables.ps1 new file mode 100644 index 000000000..cfcb7df52 --- /dev/null +++ b/azure-pipelines/artifacts/Variables.ps1 @@ -0,0 +1,40 @@ +# This artifact captures all variables defined in the ..\variables folder. +# It "snaps" the values of these variables where we can compute them during the build, +# and otherwise captures the scripts to run later during an Azure Pipelines environment release. + +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") +$ArtifactBasePath = "$RepoRoot\obj\_artifacts" +$VariablesArtifactPath = "$ArtifactBasePath\variables" +if (-not (Test-Path $VariablesArtifactPath)) { New-Item -ItemType Directory -Path $VariablesArtifactPath | Out-Null } + +# Copy variables, either by value if the value is calculable now, or by script +Get-ChildItem -Path "$PSScriptRoot\..\variables" |% { + $value = $null + if (-not $_.BaseName.StartsWith('_')) { # Skip trying to interpret special scripts + # First check the environment variables in case the variable was set in a queued build + if (Test-Path env:$($_.BaseName)) { + $value = Get-Content "env:$($_.BaseName)" + } + + # If that didn't give us anything, try executing the script right now from its original position + if (-not $value) { + $value = & $_.FullName + } + + if ($value) { + # We got something, so wrap it with quotes so it's treated like a literal value. + $value = "'$value'" + } + } + + # If that didn't get us anything, just copy the script itself + if (-not $value) { + $value = Get-Content -Path $_.FullName + } + + Set-Content -Path "$VariablesArtifactPath\$($_.Name)" -Value $value +} + +@{ + "$VariablesArtifactPath" = (Get-ChildItem $VariablesArtifactPath -Recurse); +} diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 new file mode 100644 index 000000000..bd5e9d34c --- /dev/null +++ b/azure-pipelines/artifacts/_all.ps1 @@ -0,0 +1,45 @@ +# This script returns all the artifacts that should be collected after a build. +# +# Each powershell artifact is expressed as an object with these properties: +# Source - the full path to the source file +# ArtifactName - the name of the artifact to upload to +# ContainerFolder - the relative path within the artifact in which the file should appear +# +# Each artifact aggregating .ps1 script should return a hashtable: +# Key = path to the directory from which relative paths within the artifact should be calculated +# Value = an array of paths (absolute or relative to the BaseDirectory) to files to include in the artifact. +# FileInfo objects are also allowed. + +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") + +Function EnsureTrailingSlash($path) { + if ($path.length -gt 0 -and !$path.EndsWith('\') -and !$path.EndsWith('/')) { + $path = $path + [IO.Path]::DirectorySeparatorChar + } + + $path.Replace('\', [IO.Path]::DirectorySeparatorChar) +} + +Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% { + $ArtifactName = $_.BaseName + + (& $_).GetEnumerator() |% { + $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute) + $_.Value |% { + if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) { + $_ = $_.FullName + } + + $artifact = New-Object -TypeName PSObject + Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName + + $SourceFullPath = New-Object Uri ($BaseDirectory, $_) + Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath + + $RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath)) + Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath) + + Write-Output $artifact + } + } +} diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 new file mode 100644 index 000000000..59dd2cf20 --- /dev/null +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -0,0 +1,52 @@ +# This script translates all the artifacts described by _all.ps1 +# into commands that instruct VSTS to actually collect those artifacts. + +param ( + [string]$ArtifactNameSuffix +) + +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") +if (!$env:BUILDCONFIGURATION) { throw "BUILDCONFIGURATION environment variable must be set." } +if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { + $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY +} else { + $ArtifactStagingFolder = "$RepoRoot\obj\_artifacts" + if (Test-Path $ArtifactStagingFolder) { + Remove-Item $ArtifactStagingFolder -Recurse -Force + } +} + +function Create-SymbolicLink { + param ( + $Link, + $Target + ) + + if ($Link -eq $Target) { + return + } + + if (Test-Path $Link) { Remove-Item $Link } + $LinkContainer = Split-Path $Link -Parent + if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer } + Write-Verbose "Linking $Link to $Target" + ln $Target $Link +} + +# Stage all artifacts +$Artifacts = & "$PSScriptRoot\_all.ps1" +$Artifacts |% { + $DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\') + $Name = "$(Split-Path $_.Source -Leaf)" + + #Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow + + if (-not (Test-Path $DestinationFolder)) { New-Item -ItemType Directory -Path $DestinationFolder | Out-Null } + if (Test-Path -PathType Leaf $_.Source) { # skip folders + Create-SymbolicLink -Link "$DestinationFolder\$Name" -Target $_.Source + } +} + +$Artifacts |% { $_.ArtifactName } | Get-Unique |% { + Write-Host "##vso[artifact.upload containerfolder=$_$ArtifactNameSuffix;artifactname=$_$ArtifactNameSuffix;]$ArtifactStagingFolder/$_$ArtifactNameSuffix" +} diff --git a/azure-pipelines/artifacts/build_logs.ps1 b/azure-pipelines/artifacts/build_logs.ps1 new file mode 100644 index 000000000..5ba801c5f --- /dev/null +++ b/azure-pipelines/artifacts/build_logs.ps1 @@ -0,0 +1,10 @@ +if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { + $artifactsRoot = $env:BUILD_ARTIFACTSTAGINGDIRECTORY +} else { + $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") + $artifactsRoot = "$RepoRoot\bin" +} + +@{ + "$artifactsRoot/build_logs" = (Get-ChildItem -Recurse "$artifactsRoot/build_logs") +} diff --git a/azure-pipelines/artifacts/coverageResults.ps1 b/azure-pipelines/artifacts/coverageResults.ps1 new file mode 100644 index 000000000..36189f334 --- /dev/null +++ b/azure-pipelines/artifacts/coverageResults.ps1 @@ -0,0 +1,20 @@ +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") + +# Prepare code coverage reports for merging on another machine +if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { + Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`"" + $reports = Get-ChildItem "$RepoRoot/bin/coverage.cobertura.xml" -Recurse + $reports |% { + $content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" } + Set-Content -Path $_ -Value $content -Encoding UTF8 + } +} else { + Write-Warning "Azure Pipelines not detected. Machine-neutral token replacement skipped." +} + +@{ + $RepoRoot = ( + (Get-ChildItem "$RepoRoot\bin\coverage.cobertura.xml" -Recurse) + + (Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse) + ); +} diff --git a/azure-pipelines/artifacts/deployables.ps1 b/azure-pipelines/artifacts/deployables.ps1 new file mode 100644 index 000000000..893df6dd0 --- /dev/null +++ b/azure-pipelines/artifacts/deployables.ps1 @@ -0,0 +1,11 @@ +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") +$BuildConfiguration = $env:BUILDCONFIGURATION +if (!$BuildConfiguration) { + $BuildConfiguration = 'Debug' +} + +$PackagesRoot = "$RepoRoot/bin/Packages/$BuildConfiguration" + +@{ + "$PackagesRoot" = (Get-ChildItem $PackagesRoot -Recurse) +} diff --git a/azure-pipelines/artifacts/projectAssetsJson.ps1 b/azure-pipelines/artifacts/projectAssetsJson.ps1 new file mode 100644 index 000000000..5e9217bde --- /dev/null +++ b/azure-pipelines/artifacts/projectAssetsJson.ps1 @@ -0,0 +1,7 @@ +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") + +@{ + "$RepoRoot\obj" = ( + (Get-ChildItem "$RepoRoot\obj\project.assets.json" -Recurse) + ); +} diff --git a/azure-pipelines/collect-deployables.yml b/azure-pipelines/collect-deployables.yml deleted file mode 100644 index 5d77acfca..000000000 --- a/azure-pipelines/collect-deployables.yml +++ /dev/null @@ -1,15 +0,0 @@ -steps: -- task: CopyFiles@1 - inputs: - Contents: | - bin/Packages/$(BuildConfiguration)/* - TargetFolder: $(Build.ArtifactStagingDirectory)/deployables - flattenFolders: true - displayName: Collecting deployable artifacts - -- task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: $(Build.ArtifactStagingDirectory)/deployables - ArtifactName: deployables - ArtifactType: Container - displayName: Publish deployables artifacts diff --git a/azure-pipelines/collect-logs.yml b/azure-pipelines/collect-logs.yml deleted file mode 100644 index ab39d91f0..000000000 --- a/azure-pipelines/collect-logs.yml +++ /dev/null @@ -1,9 +0,0 @@ -steps: - -- task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: $(Build.ArtifactStagingDirectory)/build_logs - ArtifactName: build_logs-$(Agent.JobName) - ArtifactType: Container - displayName: Publish build_logs artifacts - condition: succeededOrFailed() diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index fe055ef7a..668083e76 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -36,48 +36,20 @@ steps: testRunTitle: netcoreapp2.2-$(Agent.JobName) workingDirectory: src -- task: CopyFiles@1 +- task: PowerShell@2 inputs: - Contents: | - bin/**/coverage.cobertura.xml - obj/**/*.cs - TargetFolder: $(Build.ArtifactStagingDirectory)/coverageResults - displayName: Collecting coverage.cobertura.xml artifacts + filePath: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true + displayName: Update pipeline variables based on build outputs condition: succeededOrFailed() -- powershell: | - Write-Host "Substituting $(System.DefaultWorkingDirectory) with {reporoot}" - $reports = Get-ChildItem "$(Build.ArtifactStagingDirectory)/coverageResults/coverage.cobertura.xml" -Recurse - $reports |% { - $content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape("$(System.DefaultWorkingDirectory)"), "{reporoot}" } - Set-Content -Path $_ -Value $content -Encoding UTF8 - } - displayName: Preparing code coverage reports for merging on another machine - -- task: PublishBuildArtifacts@1 +- task: PowerShell@2 inputs: - PathtoPublish: $(Build.ArtifactStagingDirectory)/coverageResults - ArtifactName: coverageResults-$(Agent.JobName) - ArtifactType: Container - displayName: Publish coverageResults artifacts + filePath: azure-pipelines/artifacts/_pipelines.ps1 + arguments: -ArtifactNameSuffix "-$(Agent.JobName)" + displayName: Publish artifacts condition: succeededOrFailed() - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') - -- task: CopyFiles@1 - inputs: - Contents: | - obj/**/project.assets.json - TargetFolder: $(Build.ArtifactStagingDirectory)/projectAssetsJson - displayName: Collecting project.assets.json artifacts - condition: succeededOrFailed() - -- task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: $(Build.ArtifactStagingDirectory)/projectAssetsJson - ArtifactName: projectAssetsJson-$(Agent.JobName) - ArtifactType: Container - displayName: Publish projectAssetsJson artifacts - condition: succeededOrFailed() diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 80830cc7f..5b0b8c3af 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -1,13 +1,19 @@ steps: +- task: PowerShell@2 + inputs: + filePath: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true + displayName: Set pipeline variables based on source + - script: dotnet --info displayName: .NET Core SDK/runtimes (on host) workingDirectory: $(Agent.HomeDirectory) - task: UseDotNet@2 - displayName: Install .NET Core SDK 2.2.300 + displayName: Install .NET Core SDK inputs: packageType: sdk - version: 2.2.300 + version: $(DotNetSdkVersion) - task: UseDotNet@2 displayName: Install .NET Core runtime 2.0.x diff --git a/azure-pipelines/variables/DotNetSdkVersion.ps1 b/azure-pipelines/variables/DotNetSdkVersion.ps1 new file mode 100644 index 000000000..b213fbc27 --- /dev/null +++ b/azure-pipelines/variables/DotNetSdkVersion.ps1 @@ -0,0 +1,2 @@ +$globalJson = Get-Content -Path "$PSScriptRoot\..\..\global.json" | ConvertFrom-Json +$globalJson.sdk.version diff --git a/azure-pipelines/variables/_all.ps1 b/azure-pipelines/variables/_all.ps1 new file mode 100644 index 000000000..680a3398e --- /dev/null +++ b/azure-pipelines/variables/_all.ps1 @@ -0,0 +1,10 @@ +# This script returns a hashtable of build variables that should be set +# at the start of a build or release definition's execution. + +$vars = @{} + +Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" |% { + $vars[$_.BaseName] = & $_ +} + +$vars diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 new file mode 100644 index 000000000..b3fde25da --- /dev/null +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -0,0 +1,15 @@ +# This script translates the variables returned by the _all.ps1 script +# into commands that instruct VSTS to actually set those variables for other VSTS tasks to consume. + +# The build or release definition may have set these variables to override +# what the build would do. So only set them if they have not already been set. + +(& "$PSScriptRoot\_all.ps1").GetEnumerator() |% { + if (Test-Path -Path "env:$($_.Key.ToUpper())") { + Write-Host "Skipping setting $($_.Key) because variable is already set." -ForegroundColor Cyan + } else { + Write-Host "$($_.Key)=$($_.Value)" -ForegroundColor Yellow + Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" + Set-Item -Path "env:$($_.Key)" -Value $_.Value + } +} From baea971aa13cdb2d7e56ae7ab643b96613972894 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 23:01:20 -0600 Subject: [PATCH 014/641] Publish merged code coverage even when some inputs fail --- azure-pipelines/publish-codecoverage.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index fc5307817..b9b7b72af 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -4,16 +4,19 @@ steps: inputs: artifactName: coverageResults-Windows downloadPath: $(System.DefaultWorkingDirectory)/bin + continueOnError: true - task: DownloadBuildArtifacts@0 displayName: Download Linux code coverage results inputs: artifactName: coverageResults-Linux downloadPath: $(System.DefaultWorkingDirectory)/bin + continueOnError: true - task: DownloadBuildArtifacts@0 displayName: Download macOS code coverage results inputs: artifactName: coverageResults-macOS downloadPath: $(System.DefaultWorkingDirectory)/bin + continueOnError: true - powershell: | dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 Copy-Item -Recurse $(System.DefaultWorkingDirectory)/bin/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj From 70c8febd704082f5f235a36d112ca4b78f082804 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 23:01:47 -0600 Subject: [PATCH 015/641] Push nuget package to CI only if all agents succeed --- azure-pipelines.yml | 13 ++----------- azure-pipelines/publish-deployables.yml | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 azure-pipelines/publish-deployables.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 52451bc17..8bff4e894 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,16 +32,6 @@ jobs: - template: azure-pipelines/dotnet.yml - template: azure-pipelines/expand-template.yml - - task: NuGetCommand@2 - displayName: Push packages to CI feed - inputs: - command: push - packagesToPush: $(Build.ArtifactStagingDirectory)/deployables-Windows/*.nupkg;$(Build.ArtifactStagingDirectory)/deployables-Windows/*.snupkg - nuGetFeedType: internal - publishVstsFeed: $(ci_feed) - allowPackageConflicts: true - condition: ne(variables['ci_feed'], '') - - job: Linux pool: vmImage: Ubuntu 16.04 @@ -58,7 +48,7 @@ jobs: - template: azure-pipelines/dotnet.yml - template: azure-pipelines/expand-template.yml -- job: MergeCoverage +- job: WrapUp dependsOn: - Windows - Linux @@ -69,3 +59,4 @@ jobs: steps: - template: azure-pipelines/install-dependencies.yml - template: azure-pipelines/publish-codecoverage.yml + - template: azure-pipelines/publish-deployables.yml diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml new file mode 100644 index 000000000..85c76e7b5 --- /dev/null +++ b/azure-pipelines/publish-deployables.yml @@ -0,0 +1,15 @@ +steps: +- task: DownloadBuildArtifacts@0 + displayName: Download deployables + inputs: + artifactName: deployables-Windows + downloadPath: $(System.DefaultWorkingDirectory)/bin +- task: DotNetCoreCLI@2 + displayName: Push packages to CI feed + inputs: + command: push + packagesToPush: $(System.DefaultWorkingDirectory)/bin/deployables-Windows/*.nupkg + nuGetFeedType: internal + publishVstsFeed: $(ci_feed) + allowPackageConflicts: true + condition: and(succeeded(), ne(variables['ci_feed'], '')) From e4cbe719a90f11a3b7545ffe90a56607322e8771 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 7 Jul 2019 21:42:35 -0600 Subject: [PATCH 016/641] Add init.ps1 and Install-DotNetSdk.ps1 scripts Closes #12 --- .gitattributes | 3 +++ CONTRIBUTING.md | 5 ++++ init.ps1 | 9 +++++++ tools/Install-DotNetSdk.ps1 | 54 +++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 init.ps1 create mode 100644 tools/Install-DotNetSdk.ps1 diff --git a/.gitattributes b/.gitattributes index 1ff0c4230..9b6ea6248 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,9 @@ ############################################################################### * text=auto +# Ensure bash shell scripts use LF line endings +*.sh eol=lf + ############################################################################### # Set default behavior for command prompt diff. # diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2f36ba668..4834cebfe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,8 +17,13 @@ For example if 2.2.300 is specified, you may install 2.2.300, 2.2.301, or 2.2.31 while the 2.2.400 version would not be considered compatible by .NET SDK. See [.NET Core Versioning](https://docs.microsoft.com/en-us/dotnet/core/versions/) for more information. +All dependencies can be installed by running the `init.ps1` script at the root of the repository +using Windows PowerShell or [PowerShell Core][pwsh] (on any OS). + This repository can be built on Windows, Linux, and OSX. ## Building Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.). + +[pwsh]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 diff --git a/init.ps1 b/init.ps1 new file mode 100644 index 000000000..6f0a07761 --- /dev/null +++ b/init.ps1 @@ -0,0 +1,9 @@ +<# +.SYNOPSIS +Installs dependencies required to build and test the projects in this repository. +#> +[CmdletBinding(SupportsShouldProcess=$true)] +Param ( +) + +& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 new file mode 100644 index 000000000..ca73cb760 --- /dev/null +++ b/tools/Install-DotNetSdk.ps1 @@ -0,0 +1,54 @@ +<# +.SYNOPSIS +Installs the .NET SDK specified in the global.json file at the root of this repository, +along with supporting .NET Core runtimes used for testing. +#> +[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] +Param ( +) + +$DotNetInstallScriptRoot = Resolve-Path $PSScriptRoot\..\obj +$sdkVersion = & "$PSScriptRoot\..\azure-pipelines\variables\DotNetSdkVersion.ps1" + +if ($IsMacOS -or $IsLinux) { + $DownloadUri = "https://dot.net/v1/dotnet-install.sh" + $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" +} else { + $DownloadUri = "https://dot.net/v1/dotnet-install.ps1" + $DotNetInstallScriptPath = "$DotNetInstallScriptRoot\dotnet-install.ps1" +} + +if (-not (Test-Path $DotNetInstallScriptPath)) { + Invoke-WebRequest -Uri $DownloadUri -OutFile $DotNetInstallScriptPath + chmod +x $DotNetInstallScriptPath +} + +if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + & $DotNetInstallScriptPath -Version $sdkVersion -Architecture x64 +} else { + & $DotNetInstallScriptPath -Version $sdkVersion -Architecture x64 -DryRun +} + +# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. +$runtimeVersions = @() +Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% { + $projXml = [xml](Get-Content -Path $_) + $targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework + if (!$targetFrameworks) { + $targetFrameworks = $projXml.Project.PropertyGroup.TargetFrameworks + if ($targetFrameworks) { + $targetFrameworks = $targetFrameworks.Split(';') + } + } + $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% { + $runtimeVersions += $Matches[1] + } +} + +$runtimeVersions | Get-Unique |% { + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + & $DotNetInstallScriptPath -Channel $_ -Runtime dotnet -Architecture x64 + } else { + & $DotNetInstallScriptPath -Channel $_ -Runtime dotnet -Architecture x64 -DryRun + } +} From 45cb59eadbda46815ca7ee052c5d8a113d9560fc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 8 Jul 2019 08:50:38 -0600 Subject: [PATCH 017/641] install-dependencies.yml now shares init.ps1 script --- CONTRIBUTING.md | 5 ++ azure-pipelines/expand-template.yml | 4 +- azure-pipelines/install-dependencies.yml | 26 +------- init.ps1 | 12 +++- tools/Install-DotNetSdk.ps1 | 82 +++++++++++++++++++++--- 5 files changed, 95 insertions(+), 34 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4834cebfe..f2f4a8ca5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,6 +7,11 @@ FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +## Best practices + +* Use Windows PowerShell or [PowerShell Core][pwsh] (including on Linux/OSX) to run .ps1 scripts. + Some scripts set environment variables to help you, but they are only retained if you use PowerShell as your shell. + ## Prerequisites The only prerequisite for building, testing, and deploying from this repository diff --git a/azure-pipelines/expand-template.yml b/azure-pipelines/expand-template.yml index 74960e566..708534d5d 100644 --- a/azure-pipelines/expand-template.yml +++ b/azure-pipelines/expand-template.yml @@ -1,5 +1,7 @@ steps: -- script: git clean -fdx +- script: | + dotnet build-server shutdown + git clean -fdx displayName: Cleaning repo for template expansion - powershell: ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott" displayName: Expanding template diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 5b0b8c3af..38fa5c08e 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -5,27 +5,5 @@ steps: failOnStderr: true displayName: Set pipeline variables based on source -- script: dotnet --info - displayName: .NET Core SDK/runtimes (on host) - workingDirectory: $(Agent.HomeDirectory) - -- task: UseDotNet@2 - displayName: Install .NET Core SDK - inputs: - packageType: sdk - version: $(DotNetSdkVersion) - -- task: UseDotNet@2 - displayName: Install .NET Core runtime 2.0.x - inputs: - packageType: runtime - version: 2.0.x - -- task: UseDotNet@2 - displayName: Install .NET Core runtime 2.1.x - inputs: - packageType: runtime - version: 2.1.x - -- script: dotnet --info - displayName: .NET Core SDK/runtimes (explicitly installed) +- powershell: .\init.ps1 + displayName: Install prerequisites diff --git a/init.ps1 b/init.ps1 index 6f0a07761..41e5556bc 100644 --- a/init.ps1 +++ b/init.ps1 @@ -1,9 +1,19 @@ <# .SYNOPSIS Installs dependencies required to build and test the projects in this repository. +.DESCRIPTION +This does not require elevation, as the dependencies are installed in per-user locations. +.PARAMETER InstallLocality +A value indicating whether dependencies should be installed locally to the repo or at a per-user location. +Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. +Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. +When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. +Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. #> [CmdletBinding(SupportsShouldProcess=$true)] Param ( + [ValidateSet('repo','user')] + [string]$InstallLocality='user' ) -& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" +& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index ca73cb760..9db8558f2 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -2,20 +2,56 @@ .SYNOPSIS Installs the .NET SDK specified in the global.json file at the root of this repository, along with supporting .NET Core runtimes used for testing. +.DESCRIPTION +This does not require elevation, as the SDK and runtimes are installed locally to this repo location. +.PARAMETER InstallLocality +A value indicating whether dependencies should be installed locally to the repo or at a per-user location. +Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. +Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. +When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. +Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] Param ( + [ValidateSet('repo','user')] + [string]$InstallLocality='user' ) -$DotNetInstallScriptRoot = Resolve-Path $PSScriptRoot\..\obj -$sdkVersion = & "$PSScriptRoot\..\azure-pipelines\variables\DotNetSdkVersion.ps1" +$DotNetInstallScriptRoot = "$PSScriptRoot/../obj" +if (!(Test-Path $DotNetInstallScriptRoot)) { mkdir $DotNetInstallScriptRoot | Out-Null } + +$switches = @( + '-Architecture','x64' +) +$envVars = @{ + # For locally installed dotnet, skip first time experience which takes a long time + 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true'; +} + +$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot +if ($InstallLocality -eq 'repo') { + $DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet" +} elseif ($env:AGENT_TOOLSDIRECTORY) { + $DotNetInstallDir = "$env:AGENT_TOOLSDIRECTORY/dotnet" +} else { + $DotNetInstallDir = Join-Path $HOME .dotnet +} + +Write-Host "Installing .NET Core SDK and runtimes to $DotNetInstallDir" -ForegroundColor Blue + +if ($DotNetInstallDir) { + $switches += '-InstallDir',$DotNetInstallDir + $envVars['DOTNET_MULTILEVEL_LOOKUP'] = '0' + $envVars['DOTNET_ROOT'] = $DotNetInstallDir +} +$sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1" if ($IsMacOS -or $IsLinux) { $DownloadUri = "https://dot.net/v1/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { $DownloadUri = "https://dot.net/v1/dotnet-install.ps1" - $DotNetInstallScriptPath = "$DotNetInstallScriptRoot\dotnet-install.ps1" + $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } if (-not (Test-Path $DotNetInstallScriptPath)) { @@ -24,9 +60,9 @@ if (-not (Test-Path $DotNetInstallScriptPath)) { } if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { - & $DotNetInstallScriptPath -Version $sdkVersion -Architecture x64 + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" } else { - & $DotNetInstallScriptPath -Version $sdkVersion -Architecture x64 -DryRun + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" } # Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. @@ -37,7 +73,7 @@ Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% { if (!$targetFrameworks) { $targetFrameworks = $projXml.Project.PropertyGroup.TargetFrameworks if ($targetFrameworks) { - $targetFrameworks = $targetFrameworks.Split(';') + $targetFrameworks = $targetFrameworks -Split ';' } } $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% { @@ -45,10 +81,40 @@ Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% { } } +$switches += '-Runtime','dotnet' + $runtimeVersions | Get-Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - & $DotNetInstallScriptPath -Channel $_ -Runtime dotnet -Architecture x64 + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" } else { - & $DotNetInstallScriptPath -Channel $_ -Runtime dotnet -Architecture x64 -DryRun + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" + } +} + +Write-Host "Environment variables to be set:" -ForegroundColor Blue +$envVars + +if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) { + if ($env:TF_BUILD) { + Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path." + } + + $envVars.GetEnumerator() |% { + Set-Item -Path env:$($_.Key) -Value $_.Value + + # If we're running in Azure Pipelines, set these environment variables + if ($env:TF_BUILD) { + Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" + } + } + + if ($IsMacOS -or $IsLinux) { + $env:PATH = "${DotNetInstallDir}:$env:PATH" + } else { + $env:PATH = "$DotNetInstallDir;$env:PATH" + } + + if ($env:TF_BUILD) { + Write-Host "##vso[task.prependpath]$DotNetInstallDir" } } From e4753b7b235a6969dc2be8d6b1d8bda7fafb8adc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 9 Jul 2019 21:45:34 -0600 Subject: [PATCH 018/641] Add -Squash switch to Expand-Template.ps1 --- Expand-Template.ps1 | 14 +++++++++++++- azure-pipelines/expand-template.yml | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index c1447d4c9..7558ca51a 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -10,6 +10,8 @@ A token obtained from codecov.io for your repo. If not specified, code coverage but can be added later by editing the Azure Pipelines YAML file. .PARAMETER CIFeed The `/{guid}` path to the Azure Pipelines artifact feed to push your nuget package to as part of your CI. +.PARAMETER Squash +A switch that causes all of git history to be squashed to just one initial commit for the template, and one for its expansion. #> [CmdletBinding()] Param( @@ -20,7 +22,9 @@ Param( [Parameter()] [string]$CodeCovToken, [Parameter()] - [string]$CIFeed + [string]$CIFeed, + [Parameter()] + [switch]$Squash ) function Replace-Placeholders { @@ -69,6 +73,11 @@ if (-not $sn) { Push-Location $PSScriptRoot try { + if ($Squash) { + git reset --soft $(git rev-list --max-parents=0 HEAD) + git commit --amend -qm "Initial template from https://github.com/AArnott/Library.Template" + } + # Rename project directories and solution Set-Location src git mv Library.sln "$LibraryName.sln" @@ -147,6 +156,9 @@ try { Write-Error "PLACEHOLDER discovered in $($_.FullName)" } } + + # Commit the changes + git commit -qm "Expanded template for $LibraryName" -m "This expansion done by the (now removed) Expand-Template.ps1 script." } finally { Pop-Location } diff --git a/azure-pipelines/expand-template.yml b/azure-pipelines/expand-template.yml index 708534d5d..2d9ea7b30 100644 --- a/azure-pipelines/expand-template.yml +++ b/azure-pipelines/expand-template.yml @@ -3,7 +3,10 @@ steps: dotnet build-server shutdown git clean -fdx displayName: Cleaning repo for template expansion -- powershell: ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott" +- powershell: | + git config user.name "test user" + git config user.email "andrewarnott@gmail.com" + ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott" displayName: Expanding template failOnStderr: true # TODO: Verify that all changes are staged to the git index From 18164cfa4ecefc40d937a652c98dda68ff22ddc8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 10 Jul 2019 15:25:10 -0600 Subject: [PATCH 019/641] Add timeout to codecov publish step I saw this hang for a long time once, presumably when codecov.io was down. --- azure-pipelines/dotnet.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 668083e76..1ca019a08 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -53,3 +53,4 @@ steps: - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') + timeoutInMinutes: 3 From f4b75c2ffb7394ee4661f333c565d7446b70ffb5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Jul 2019 09:39:31 -0600 Subject: [PATCH 020/641] Tests ruleset inherits from shipping one --- src/tests.ruleset | 72 ++--------------------------------------------- 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/src/tests.ruleset b/src/tests.ruleset index c74c6ed34..4b4708a12 100644 --- a/src/tests.ruleset +++ b/src/tests.ruleset @@ -1,75 +1,7 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - @@ -80,4 +12,4 @@ - \ No newline at end of file + From 26871ccaeafb1ce4d0c26ee08137bf39883c47ff Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Jul 2019 13:17:52 -0600 Subject: [PATCH 021/641] Move jobs into build.yml --- Expand-Template.ps1 | 6 +++-- azure-pipelines.yml | 43 +----------------------------------- azure-pipelines/build.yml | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 44 deletions(-) create mode 100644 azure-pipelines/build.yml diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 7558ca51a..c050aba3f 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -128,10 +128,12 @@ try { "(?m)^.*\[codecov\].*`r?`n"="" } - # Specially handle azure-pipelines.yml edits - $YmlReplacements = @{ + # Specially handle azure-pipelines .yml edits + Replace-Placeholders -Path "azure-pipelines/build.yml" -Replacements @{ "(?m).*expand-template\.yml(?:\r)?\n" = "" } + + $YmlReplacements = @{} if ($CodeCovToken) { $YmlReplacements['(codecov_token: ).*(#.*)'] = "`$1$CodeCovToken" } else { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8bff4e894..f158ff523 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,45 +18,4 @@ variables: ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed jobs: -- job: Windows - pool: Hosted Windows 2019 with VS2019 - steps: - - template: azure-pipelines/install-dependencies.yml - - - powershell: | - dotnet tool install --tool-path .. nbgv --ignore-failed-sources - ../nbgv cloud - displayName: Set build number - workingDirectory: src - - - template: azure-pipelines/dotnet.yml - - template: azure-pipelines/expand-template.yml - -- job: Linux - pool: - vmImage: Ubuntu 16.04 - steps: - - template: azure-pipelines/install-dependencies.yml - - template: azure-pipelines/dotnet.yml - - template: azure-pipelines/expand-template.yml - -- job: macOS - pool: - vmImage: macOS 10.13 - steps: - - template: azure-pipelines/install-dependencies.yml - - template: azure-pipelines/dotnet.yml - - template: azure-pipelines/expand-template.yml - -- job: WrapUp - dependsOn: - - Windows - - Linux - - macOS - pool: - vmImage: Ubuntu 16.04 - condition: succeededOrFailed() - steps: - - template: azure-pipelines/install-dependencies.yml - - template: azure-pipelines/publish-codecoverage.yml - - template: azure-pipelines/publish-deployables.yml +- template: azure-pipelines/build.yml diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml new file mode 100644 index 000000000..75b7e0c3c --- /dev/null +++ b/azure-pipelines/build.yml @@ -0,0 +1,46 @@ +parameters: + windowsPool: Hosted Windows 2019 with VS2019 + +jobs: +- job: Windows + pool: ${{ parameters.windowsPool }} + steps: + - template: install-dependencies.yml + + - powershell: | + dotnet tool install --tool-path .. nbgv --ignore-failed-sources + ../nbgv cloud + displayName: Set build number + workingDirectory: src + + - template: dotnet.yml + - template: expand-template.yml + +- job: Linux + pool: + vmImage: Ubuntu 16.04 + steps: + - template: install-dependencies.yml + - template: dotnet.yml + - template: expand-template.yml + +- job: macOS + pool: + vmImage: macOS 10.13 + steps: + - template: install-dependencies.yml + - template: dotnet.yml + - template: expand-template.yml + +- job: WrapUp + dependsOn: + - Windows + - Linux + - macOS + pool: + vmImage: Ubuntu 16.04 + condition: succeededOrFailed() + steps: + - template: install-dependencies.yml + - template: publish-codecoverage.yml + - template: publish-deployables.yml From 1263ef34db6d2d749f4cdd33696f1bae4ec27fb6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Jul 2019 13:32:27 -0600 Subject: [PATCH 022/641] Move nbgv installation in azp outside the src dir The Agent.ToolsDirectory is a popular place to put versioned tools like this. --- .gitignore | 3 +++ azure-pipelines/build.yml | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fc1d26fa8..e353101db 100644 --- a/.gitignore +++ b/.gitignore @@ -342,3 +342,6 @@ healthchecksdb # Backup folder for Package Reference Convert tool in Visual Studio 2017 MigrationBackup/ + +# dotnet tool local install directory +.store/ diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 75b7e0c3c..3ee5b0b9d 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -8,10 +8,9 @@ jobs: - template: install-dependencies.yml - powershell: | - dotnet tool install --tool-path .. nbgv --ignore-failed-sources - ../nbgv cloud + dotnet tool install --tool-path $(Agent.ToolsDirectory) nbgv --ignore-failed-sources + $(Agent.ToolsDirectory)/nbgv cloud displayName: Set build number - workingDirectory: src - template: dotnet.yml - template: expand-template.yml From ecb32a2ad6a0625bcaebec9bfcf44945cc63258d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Jul 2019 13:33:09 -0600 Subject: [PATCH 023/641] Don't deploy packages to CI feed on PR builds --- azure-pipelines/publish-deployables.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml index 85c76e7b5..cdd852920 100644 --- a/azure-pipelines/publish-deployables.yml +++ b/azure-pipelines/publish-deployables.yml @@ -4,6 +4,7 @@ steps: inputs: artifactName: deployables-Windows downloadPath: $(System.DefaultWorkingDirectory)/bin + - task: DotNetCoreCLI@2 displayName: Push packages to CI feed inputs: @@ -12,4 +13,4 @@ steps: nuGetFeedType: internal publishVstsFeed: $(ci_feed) allowPackageConflicts: true - condition: and(succeeded(), ne(variables['ci_feed'], '')) + condition: and(succeeded(), ne(variables['ci_feed'], ''), ne(variables['Build.Reason'], 'PullRequest')) From 13ab120e7f6f448092bffbff7d5ffc39b475ef70 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Jul 2019 13:33:44 -0600 Subject: [PATCH 024/641] Make azp/artifacts only warn when they can't find files --- azure-pipelines/artifacts/_all.ps1 | 37 +++++++++++-------- azure-pipelines/artifacts/build_logs.ps1 | 2 + azure-pipelines/artifacts/coverageResults.ps1 | 4 +- azure-pipelines/artifacts/deployables.ps1 | 2 + .../artifacts/projectAssetsJson.ps1 | 8 ++-- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index bd5e9d34c..6f62be5c3 100644 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -23,23 +23,28 @@ Function EnsureTrailingSlash($path) { Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% { $ArtifactName = $_.BaseName - (& $_).GetEnumerator() |% { - $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute) - $_.Value |% { - if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) { - $_ = $_.FullName + $fileGroups = & $_ + if (!$fileGroups -or $fileGroups.Count -eq 0) { + Write-Warning "No files found for the `"$ArtifactName`" artifact." + } else { + $fileGroups.GetEnumerator() | % { + $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute) + $_.Value | % { + if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) { + $_ = $_.FullName + } + + $artifact = New-Object -TypeName PSObject + Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName + + $SourceFullPath = New-Object Uri ($BaseDirectory, $_) + Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath + + $RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath)) + Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath) + + Write-Output $artifact } - - $artifact = New-Object -TypeName PSObject - Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName - - $SourceFullPath = New-Object Uri ($BaseDirectory, $_) - Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath - - $RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath)) - Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath) - - Write-Output $artifact } } } diff --git a/azure-pipelines/artifacts/build_logs.ps1 b/azure-pipelines/artifacts/build_logs.ps1 index 5ba801c5f..b55ba48f3 100644 --- a/azure-pipelines/artifacts/build_logs.ps1 +++ b/azure-pipelines/artifacts/build_logs.ps1 @@ -5,6 +5,8 @@ if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { $artifactsRoot = "$RepoRoot\bin" } +if (!(Test-Path $artifactsRoot/build_logs)) { return } + @{ "$artifactsRoot/build_logs" = (Get-ChildItem -Recurse "$artifactsRoot/build_logs") } diff --git a/azure-pipelines/artifacts/coverageResults.ps1 b/azure-pipelines/artifacts/coverageResults.ps1 index 36189f334..619ac0f3a 100644 --- a/azure-pipelines/artifacts/coverageResults.ps1 +++ b/azure-pipelines/artifacts/coverageResults.ps1 @@ -9,9 +9,11 @@ if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { Set-Content -Path $_ -Value $content -Encoding UTF8 } } else { - Write-Warning "Azure Pipelines not detected. Machine-neutral token replacement skipped." + Write-Warning "coverageResults: Azure Pipelines not detected. Machine-neutral token replacement skipped." } +if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return } + @{ $RepoRoot = ( (Get-ChildItem "$RepoRoot\bin\coverage.cobertura.xml" -Recurse) + diff --git a/azure-pipelines/artifacts/deployables.ps1 b/azure-pipelines/artifacts/deployables.ps1 index 893df6dd0..94c48cdd9 100644 --- a/azure-pipelines/artifacts/deployables.ps1 +++ b/azure-pipelines/artifacts/deployables.ps1 @@ -6,6 +6,8 @@ if (!$BuildConfiguration) { $PackagesRoot = "$RepoRoot/bin/Packages/$BuildConfiguration" +if (!(Test-Path $PackagesRoot)) { return } + @{ "$PackagesRoot" = (Get-ChildItem $PackagesRoot -Recurse) } diff --git a/azure-pipelines/artifacts/projectAssetsJson.ps1 b/azure-pipelines/artifacts/projectAssetsJson.ps1 index 5e9217bde..d2e85ffbe 100644 --- a/azure-pipelines/artifacts/projectAssetsJson.ps1 +++ b/azure-pipelines/artifacts/projectAssetsJson.ps1 @@ -1,7 +1,9 @@ -$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") +$ObjRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\obj") + +if (!(Test-Path $ObjRoot)) { return } @{ - "$RepoRoot\obj" = ( - (Get-ChildItem "$RepoRoot\obj\project.assets.json" -Recurse) + "$ObjRoot" = ( + (Get-ChildItem "$ObjRoot\project.assets.json" -Recurse) ); } From 3731857e1e4baa0782fedcd803fc7b5424598f9b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Jul 2019 13:58:00 -0600 Subject: [PATCH 025/641] Collect symbols artifact and publish to ADO --- azure-pipelines/Convert-PDB.ps1 | 37 ++++++++++++++++ azure-pipelines/Get-NuGetTool.ps1 | 21 +++++++++ azure-pipelines/artifacts/symbols.ps1 | 64 +++++++++++++++++++++++++++ azure-pipelines/dotnet.yml | 9 ++++ 4 files changed, 131 insertions(+) create mode 100644 azure-pipelines/Convert-PDB.ps1 create mode 100644 azure-pipelines/Get-NuGetTool.ps1 create mode 100644 azure-pipelines/artifacts/symbols.ps1 diff --git a/azure-pipelines/Convert-PDB.ps1 b/azure-pipelines/Convert-PDB.ps1 new file mode 100644 index 000000000..00549f713 --- /dev/null +++ b/azure-pipelines/Convert-PDB.ps1 @@ -0,0 +1,37 @@ +<# +.SYNOPSIS + Builds all projects in this repo. +.PARAMETER DllPath + The path to the DLL whose PDB is to be converted. +.PARAMETER PdbPath + The path to the PDB to convert. May be omitted if the DLL was compiled on this machine and the PDB is still at its original path. +.PARAMETER OutputPath + The path of the output PDB to write. +#> +#Function Convert-PortableToWindowsPDB() { + Param( + [Parameter(Mandatory=$true,Position=0)] + [string]$DllPath, + [Parameter()] + [string]$PdbPath, + [Parameter(Mandatory=$true,Position=1)] + [string]$OutputPath + ) + + $version = '1.1.0-beta1-64128-01' + $baseDir = "$PSScriptRoot\..\obj\tools" + $pdb2pdbpath = "$baseDir\pdb2pdb.$version\tools\Pdb2Pdb.exe" + if (-not (Test-Path $pdb2pdbpath)) { + if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } + $baseDir = (Resolve-Path $baseDir).Path # Normalize it + & (& $PSScriptRoot\Get-NuGetTool.ps1) install pdb2pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://dotnet.myget.org/F/symreader-converter/api/v3/index.json | Out-Null + } + + $args = $DllPath,'/out',$OutputPath,'/nowarn','0021' + if ($PdbPath) { + $args += '/pdb',$PdbPath + } + + Write-Verbose "$pdb2pdbpath $args" + & $pdb2pdbpath $args +#} diff --git a/azure-pipelines/Get-NuGetTool.ps1 b/azure-pipelines/Get-NuGetTool.ps1 new file mode 100644 index 000000000..59d6187a6 --- /dev/null +++ b/azure-pipelines/Get-NuGetTool.ps1 @@ -0,0 +1,21 @@ +<# +.SYNOPSIS + Downloads the NuGet.exe tool and returns the path to it. +.PARAMETER NuGetVersion + The version of the NuGet tool to acquire. +#> +Param( + [Parameter()] + [string]$NuGetVersion='5.0.2' +) + +$binaryToolsPath = "$PSScriptRoot\..\obj\tools\nuget.$NuGetVersion" +if (!(Test-Path $binaryToolsPath)) { $null = New-Item -Type Directory -Path $binaryToolsPath } +$nugetPath = "$binaryToolsPath\nuget.exe" + +if (!(Test-Path $nugetPath)) { + Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow + Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe" -OutFile $nugetPath | Out-Null +} + +Write-Output (Resolve-Path $nugetPath).Path diff --git a/azure-pipelines/artifacts/symbols.ps1 b/azure-pipelines/artifacts/symbols.ps1 new file mode 100644 index 000000000..504913689 --- /dev/null +++ b/azure-pipelines/artifacts/symbols.ps1 @@ -0,0 +1,64 @@ +Function Get-SymbolFiles { + [CmdletBinding()] + param ( + [parameter(Mandatory=$true)] + [string]$Path + ) + + $WindowsPdbSubDirName = "symstore" + + $ActivityName = "Collecting symbols from $Path" + Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files" + $PDBs = Get-ChildItem -rec "$Path\*.pdb" |? { $_.FullName -notmatch "unittest|tests|\W$WindowsPdbSubDirName\W" } + Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" + $PDBsByHash = @{} + $i = 0 + $PDBs |% { + Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" -PercentComplete (100 * $i / $PDBs.Length) + $hash = Get-FileHash $_ + $i++ + Add-Member -InputObject $_ -MemberType NoteProperty -Name Hash -Value $hash.Hash + Write-Output $_ + } | Sort-Object CreationTime |% { + # De-dupe based on hash. Prefer the first match so we take the first built copy. + if (-not $PDBsByHash.ContainsKey($_.Hash)) { + $PDBsByHash.Add($_.Hash, $_.FullName) + Write-Output $_ + } + } |% { + # Collect the DLLs/EXEs as well. + $dllPath = "$($_.Directory)\$($_.BaseName).dll" + $exePath = "$($_.Directory)\$($_.BaseName).exe" + if (Test-Path $dllPath) { + $BinaryImagePath = $dllPath + } elseif (Test-Path $exePath) { + $BinaryImagePath = $exePath + } + + Write-Output $BinaryImagePath + + # Convert the PDB to legacy Windows PDBs + Write-Host "Converting PDB for $_" -ForegroundColor DarkGray + $WindowsPdbDir = "$($_.Directory.FullName)\$WindowsPdbSubDirName" + if (!(Test-Path $WindowsPdbDir)) { mkdir $WindowsPdbDir | Out-Null } + & "$PSScriptRoot\..\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath "$WindowsPdbDir\$($_.BaseName).pdb" + if ($LASTEXITCODE -ne 0) { + Write-Warning "PDB conversion of `"$_`" failed." + } + + Write-Output "$WindowsPdbDir\$($_.BaseName).pdb" + } +} + +# This doesn't work off Windows, nor do we need to convert symbols on multiple OS agents +if ($IsMacOS -or $IsLinux) { + return; +} + +$BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\bin") +if (!(Test-Path $BinPath)) { return } +$symbolfiles = Get-SymbolFiles -Path $BinPath | Get-Unique + +@{ + "$BinPath" = $SymbolFiles; +} diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 1ca019a08..e14c1bbbf 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -50,6 +50,15 @@ steps: displayName: Publish artifacts condition: succeededOrFailed() +- task: PublishSymbols@2 + inputs: + SymbolsFolder: $(Build.ArtifactStagingDirectory)/symbols-Windows + SearchPattern: '**/*.pdb' + IndexSources: false + SymbolServerType: TeamServices + displayName: Publish symbols to symbol server + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Agent.OS'], 'Windows_NT')) + - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') From 46d8abc111c18c3ffba75a3ab8e4f379eda2cef2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Jul 2019 22:03:09 -0600 Subject: [PATCH 026/641] Don't fail build when codecov.io is down --- azure-pipelines/dotnet.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index e14c1bbbf..6641ebb9f 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -63,3 +63,4 @@ steps: displayName: Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') timeoutInMinutes: 3 + continueOnError: true From 1ae312b50b3247ef07ae48a9b98f0c897b40ef2b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 13 Jul 2019 01:25:59 -0600 Subject: [PATCH 027/641] Stop calling chmod on Windows Not all custom Windows agents have this available. --- tools/Install-DotNetSdk.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 9db8558f2..3061edf8c 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -56,7 +56,9 @@ if ($IsMacOS -or $IsLinux) { if (-not (Test-Path $DotNetInstallScriptPath)) { Invoke-WebRequest -Uri $DownloadUri -OutFile $DotNetInstallScriptPath - chmod +x $DotNetInstallScriptPath + if ($IsMacOS -or $IsLinux) { + chmod +x $DotNetInstallScriptPath + } } if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { From 8bd008e9cef9a7499a767bb30c9fd14f78f97f73 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 13 Jul 2019 01:42:22 -0600 Subject: [PATCH 028/641] Avoid ln on Windows Some custom Windows agents don't have this --- azure-pipelines/artifacts/_pipelines.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 index 59dd2cf20..dce2d5a82 100644 --- a/azure-pipelines/artifacts/_pipelines.ps1 +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -30,7 +30,11 @@ function Create-SymbolicLink { $LinkContainer = Split-Path $Link -Parent if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer } Write-Verbose "Linking $Link to $Target" - ln $Target $Link + if ($IsMacOS -or $IsLinux) { + ln $Target $Link + } else { + cmd /c mklink $Link $Target + } } # Stage all artifacts From 354c7db5d602f3e7e6436b3b8cd28e00193e1685 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 13 Jul 2019 01:46:28 -0600 Subject: [PATCH 029/641] Install nbgv to Agent.TempDirectory Avoids errors when nbgv is already installed on a custom agent --- azure-pipelines/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 3ee5b0b9d..7e18277e8 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -8,8 +8,8 @@ jobs: - template: install-dependencies.yml - powershell: | - dotnet tool install --tool-path $(Agent.ToolsDirectory) nbgv --ignore-failed-sources - $(Agent.ToolsDirectory)/nbgv cloud + dotnet tool install --tool-path $(Agent.TempDirectory) nbgv --ignore-failed-sources + $(Agent.TempDirectory)/nbgv cloud displayName: Set build number - template: dotnet.yml From 2da189df18af52ab540789cd9f1a0430feb87d4a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 13 Jul 2019 01:49:37 -0600 Subject: [PATCH 030/641] Display dotnet --info after prereq installation --- azure-pipelines/install-dependencies.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 38fa5c08e..2e6a32346 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -5,5 +5,7 @@ steps: failOnStderr: true displayName: Set pipeline variables based on source -- powershell: .\init.ps1 +- powershell: | + .\init.ps1 + dotnet --info displayName: Install prerequisites From 00bcb28bfc4095207bab694ca2ae8a71810733be Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 15 Jul 2019 10:35:04 -0600 Subject: [PATCH 031/641] Add init.cmd, nbgv tool improvements, etc. --- azure-pipelines/Get-nbgv.ps1 | 29 +++++++++++++++++++++++ azure-pipelines/artifacts/_pipelines.ps1 | 1 - azure-pipelines/build.yml | 10 +++++--- azure-pipelines/install-dependencies.yml | 11 +++++---- azure-pipelines/nbgv.nuget.config | 7 ++++++ azure-pipelines/variables/_all.ps1 | 1 + init.cmd | 3 +++ tools/Install-DotNetSdk.ps1 | 30 +++++++++++++++++------- 8 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 azure-pipelines/Get-nbgv.ps1 create mode 100644 azure-pipelines/nbgv.nuget.config create mode 100644 init.cmd diff --git a/azure-pipelines/Get-nbgv.ps1 b/azure-pipelines/Get-nbgv.ps1 new file mode 100644 index 000000000..bc9c11c88 --- /dev/null +++ b/azure-pipelines/Get-nbgv.ps1 @@ -0,0 +1,29 @@ +<# +.SYNOPSIS + Gets the path to the nbgv CLI tool, installing it if necessary. +#> +Param( +) + +$existingTool = Get-Command "nbgv" -ErrorAction SilentlyContinue +if ($existingTool) { + return $existingTool.Path +} + +if ($env:AGENT_TEMPDIRECTORY) { + $toolInstallDir = "$env:AGENT_TEMPDIRECTORY/$env:BUILD_BUILDID" +} else { + $toolInstallDir = "$PSScriptRoot/obj/tools" +} + +$toolPath = "$toolInstallDir/nbgv" +if (!(Test-Path $toolPath)) { New-Item -Path $toolPath -ItemType Directory | Out-Null } +$toolPath = (Resolve-Path $toolPath).Path + +if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) { + Write-Host "Installing nbgv to $toolInstallDir" + dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot\nbgv.nuget.config" | Out-Null +} + +# Normalize the path on the way out. +return (Get-Command $toolPath).Path diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 index dce2d5a82..270a96043 100644 --- a/azure-pipelines/artifacts/_pipelines.ps1 +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -6,7 +6,6 @@ param ( ) $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") -if (!$env:BUILDCONFIGURATION) { throw "BUILDCONFIGURATION environment variable must be set." } if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY } else { diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 7e18277e8..6eeca905f 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -5,11 +5,11 @@ jobs: - job: Windows pool: ${{ parameters.windowsPool }} steps: + - checkout: self + clean: true # "all" doesn't work, but "true" does, despite YAML docs - template: install-dependencies.yml - - powershell: | - dotnet tool install --tool-path $(Agent.TempDirectory) nbgv --ignore-failed-sources - $(Agent.TempDirectory)/nbgv cloud + - powershell: '& (azure-pipelines\Get-nbgv.ps1) cloud' displayName: Set build number - template: dotnet.yml @@ -19,6 +19,8 @@ jobs: pool: vmImage: Ubuntu 16.04 steps: + - checkout: self + clean: true # "all" doesn't work, but "true" does, despite YAML docs - template: install-dependencies.yml - template: dotnet.yml - template: expand-template.yml @@ -40,6 +42,8 @@ jobs: vmImage: Ubuntu 16.04 condition: succeededOrFailed() steps: + - checkout: self + clean: true # "all" doesn't work, but "true" does, despite YAML docs - template: install-dependencies.yml - template: publish-codecoverage.yml - template: publish-deployables.yml diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 2e6a32346..beacc44d9 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -1,11 +1,12 @@ steps: -- task: PowerShell@2 - inputs: - filePath: azure-pipelines/variables/_pipelines.ps1 - failOnStderr: true - displayName: Set pipeline variables based on source - powershell: | .\init.ps1 dotnet --info displayName: Install prerequisites + +- task: PowerShell@2 + inputs: + filePath: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true + displayName: Set pipeline variables based on source diff --git a/azure-pipelines/nbgv.nuget.config b/azure-pipelines/nbgv.nuget.config new file mode 100644 index 000000000..765346e53 --- /dev/null +++ b/azure-pipelines/nbgv.nuget.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/azure-pipelines/variables/_all.ps1 b/azure-pipelines/variables/_all.ps1 index 680a3398e..ed0997922 100644 --- a/azure-pipelines/variables/_all.ps1 +++ b/azure-pipelines/variables/_all.ps1 @@ -4,6 +4,7 @@ $vars = @{} Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" |% { + Write-Host "Computing $($_.BaseName) variable" $vars[$_.BaseName] = & $_ } diff --git a/init.cmd b/init.cmd new file mode 100644 index 000000000..5bef08da3 --- /dev/null +++ b/init.cmd @@ -0,0 +1,3 @@ +@set PS1UnderCmd=1 +powershell.exe -ExecutionPolicy bypass -Command "& '%~dpn0.ps1'" %* +@set PS1UnderCmd= diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 3061edf8c..2eccce41f 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -93,14 +93,17 @@ $runtimeVersions | Get-Unique |% { } } -Write-Host "Environment variables to be set:" -ForegroundColor Blue -$envVars - if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) { if ($env:TF_BUILD) { Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path." } + if ($IsMacOS -or $IsLinux) { + $envVars['PATH'] = "${DotNetInstallDir}:$env:PATH" + } else { + $envVars['PATH'] = "$DotNetInstallDir;$env:PATH" + } + $envVars.GetEnumerator() |% { Set-Item -Path env:$($_.Key) -Value $_.Value @@ -110,13 +113,22 @@ if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these } } - if ($IsMacOS -or $IsLinux) { - $env:PATH = "${DotNetInstallDir}:$env:PATH" - } else { - $env:PATH = "$DotNetInstallDir;$env:PATH" - } - if ($env:TF_BUILD) { Write-Host "##vso[task.prependpath]$DotNetInstallDir" } } + +if ($env:PS1UnderCmd -eq '1') { + Write-Warning "Environment variable changes will be lost because you're running under cmd.exe. Run these commands manually:" + $envVars.GetEnumerator() |% { + if ($_.Key -eq 'PATH') { + # Special case this one for readability + Write-Host "SET PATH=$DotNetInstallDir;%PATH%" + } else { + Write-Host "SET $($_.Key)=$($_.Value)" + } + } +} else { + Write-Host "Environment variables set:" -ForegroundColor Blue + $envVars +} From 0691c8d0a1fda51e45e6d21bb9e73eefe74b3e0c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 16 Jul 2019 12:32:54 -0600 Subject: [PATCH 032/641] Avoid error when exactly one coverage.cobertura.xml file is found --- azure-pipelines/artifacts/coverageResults.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/artifacts/coverageResults.ps1 b/azure-pipelines/artifacts/coverageResults.ps1 index 619ac0f3a..7d1e9a35f 100644 --- a/azure-pipelines/artifacts/coverageResults.ps1 +++ b/azure-pipelines/artifacts/coverageResults.ps1 @@ -16,7 +16,7 @@ if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return } @{ $RepoRoot = ( - (Get-ChildItem "$RepoRoot\bin\coverage.cobertura.xml" -Recurse) + + @(Get-ChildItem "$RepoRoot\bin\coverage.cobertura.xml" -Recurse) + (Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse) ); } From 5e96a0b15c66226b05727ae79b1595936ff30f04 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 16 Jul 2019 14:51:24 -0600 Subject: [PATCH 033/641] Fix feed auth failure when merging reports It's important to always explicitly specify a nuget.config file when using dotnet tool install so that if a nuget.config file is present with feeds that require authentication, they are not tried. --- azure-pipelines/Get-nbgv.ps1 | 2 +- .../{nbgv.nuget.config => justnugetorg.nuget.config} | 0 azure-pipelines/publish-codecoverage.yml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename azure-pipelines/{nbgv.nuget.config => justnugetorg.nuget.config} (100%) diff --git a/azure-pipelines/Get-nbgv.ps1 b/azure-pipelines/Get-nbgv.ps1 index bc9c11c88..8459995f5 100644 --- a/azure-pipelines/Get-nbgv.ps1 +++ b/azure-pipelines/Get-nbgv.ps1 @@ -22,7 +22,7 @@ $toolPath = (Resolve-Path $toolPath).Path if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) { Write-Host "Installing nbgv to $toolInstallDir" - dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot\nbgv.nuget.config" | Out-Null + dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot\justnugetorg.nuget.config" | Out-Null } # Normalize the path on the way out. diff --git a/azure-pipelines/nbgv.nuget.config b/azure-pipelines/justnugetorg.nuget.config similarity index 100% rename from azure-pipelines/nbgv.nuget.config rename to azure-pipelines/justnugetorg.nuget.config diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index b9b7b72af..5d987c83e 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -18,7 +18,7 @@ steps: downloadPath: $(System.DefaultWorkingDirectory)/bin continueOnError: true - powershell: | - dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 + dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(System.DefaultWorkingDirectory)/bin/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" $reports = Get-ChildItem -Recurse "$(System.DefaultWorkingDirectory)/bin/coverage.cobertura.xml" From 5ee62bfe3556f392e9e1bfddcf2b25fd640e2b9e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 22 Jul 2019 09:48:42 -0600 Subject: [PATCH 034/641] Add support for Azure Artifact authenticated feeds --- CONTRIBUTING.md | 6 +++ azure-pipelines/Get-NuGetTool.ps1 | 9 ++-- azure-pipelines/Get-TempToolsPath.ps1 | 13 +++++ azure-pipelines/Set-EnvVars.ps1 | 39 +++++++++++++++ azure-pipelines/build.yml | 2 + azure-pipelines/dotnet.yml | 3 -- azure-pipelines/install-dependencies.yml | 5 +- init.ps1 | 39 ++++++++++++++- nuget.config | 2 +- tools/Install-NuGetCredProvider.ps1 | 62 ++++++++++++++++++++++++ 10 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 azure-pipelines/Get-TempToolsPath.ps1 create mode 100644 azure-pipelines/Set-EnvVars.ps1 create mode 100644 tools/Install-NuGetCredProvider.ps1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f2f4a8ca5..0893b308e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,6 +27,12 @@ using Windows PowerShell or [PowerShell Core][pwsh] (on any OS). This repository can be built on Windows, Linux, and OSX. +## Package restore + +The easiest way to restore packages may be to run `init.ps1` which automatically authenticates +to the feeds that packages for this repo come from, if any. +`dotnet restore` or `nuget restore` also work but may require extra steps to authenticate to any applicable feeds. + ## Building Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.). diff --git a/azure-pipelines/Get-NuGetTool.ps1 b/azure-pipelines/Get-NuGetTool.ps1 index 59d6187a6..fdf3ed55e 100644 --- a/azure-pipelines/Get-NuGetTool.ps1 +++ b/azure-pipelines/Get-NuGetTool.ps1 @@ -9,13 +9,14 @@ Param( [string]$NuGetVersion='5.0.2' ) -$binaryToolsPath = "$PSScriptRoot\..\obj\tools\nuget.$NuGetVersion" -if (!(Test-Path $binaryToolsPath)) { $null = New-Item -Type Directory -Path $binaryToolsPath } -$nugetPath = "$binaryToolsPath\nuget.exe" +$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1" +$binaryToolsPath = Join-Path $toolsPath $NuGetVersion +if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath } +$nugetPath = Join-Path $binaryToolsPath nuget.exe if (!(Test-Path $nugetPath)) { Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe" -OutFile $nugetPath | Out-Null } -Write-Output (Resolve-Path $nugetPath).Path +return (Resolve-Path $nugetPath).Path diff --git a/azure-pipelines/Get-TempToolsPath.ps1 b/azure-pipelines/Get-TempToolsPath.ps1 new file mode 100644 index 000000000..97c552c06 --- /dev/null +++ b/azure-pipelines/Get-TempToolsPath.ps1 @@ -0,0 +1,13 @@ +if ($env:AGENT_TOOLSDIRECTORY) { + $path = "$env:AGENT_TOOLSDIRECTORY\vs-platform\tools" +} elseif ($env:localappdata) { + $path = "$env:localappdata\vs-platform\tools" +} else { + $path = "$PSScriptRoot\..\obj\tools" +} + +if (!(Test-Path $path)) { + New-Item -ItemType Directory -Path $Path | Out-Null +} + +(Resolve-Path $path).Path diff --git a/azure-pipelines/Set-EnvVars.ps1 b/azure-pipelines/Set-EnvVars.ps1 new file mode 100644 index 000000000..313cecff1 --- /dev/null +++ b/azure-pipelines/Set-EnvVars.ps1 @@ -0,0 +1,39 @@ +<# +.SYNOPSIS + Set environment variables in the environment. + Azure Pipeline and CMD environments are considered. +.PARAMETER Variables + A hashtable of variables to be set. +.OUTPUTS + A boolean indicating whether the environment variables can be expected to propagate to the caller's environment. +#> +[CmdletBinding(SupportsShouldProcess=$true)] +Param( + [Parameter(Mandatory=$true, Position=1)] + $Variables +) + +if ($Variables.Count -eq 0) { + return $true +} + +$cmdInstructions = !$env:TF_BUILD -and $env:PS1UnderCmd -eq '1' +if ($cmdInstructions) { + Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe" + Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue +} + +$Variables.GetEnumerator() |% { + Set-Item -Path env:$($_.Key) -Value $_.Value + + # If we're running in Azure Pipelines, set these environment variables + if ($env:TF_BUILD) { + Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" + } + + if ($cmdInstructions) { + Write-Host "SET $($_.Key)=$($_.Value)" + } +} + +return !$cmdInstructions diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 6eeca905f..f81d7f14d 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -45,5 +45,7 @@ jobs: - checkout: self clean: true # "all" doesn't work, but "true" does, despite YAML docs - template: install-dependencies.yml + parameters: + initArgs: -NoRestore - template: publish-codecoverage.yml - template: publish-deployables.yml diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 6641ebb9f..96569224a 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -1,7 +1,4 @@ steps: -- script: dotnet restore /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/restore.binlog" - displayName: dotnet restore - workingDirectory: src - script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: dotnet build diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index beacc44d9..8da07957b 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -1,7 +1,10 @@ +parameters: + initArgs: + steps: - powershell: | - .\init.ps1 + .\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} dotnet --info displayName: Install prerequisites diff --git a/init.ps1 b/init.ps1 index 41e5556bc..17389cbc6 100644 --- a/init.ps1 +++ b/init.ps1 @@ -9,11 +9,46 @@ Per-user allows sharing the installed dependencies across repositories and allow Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. +.PARAMETER NoPrerequisites +Skips the installation of prerequisite software (e.g. SDKs, tools). +.PARAMETER NoRestore +Skips the package restore step. +.PARAMETER AccessToken +An optional access token for authenticating to Azure Artifacts authenticated feeds. #> [CmdletBinding(SupportsShouldProcess=$true)] Param ( [ValidateSet('repo','user')] - [string]$InstallLocality='user' + [string]$InstallLocality='user', + [Parameter()] + [switch]$NoPrerequisites, + [Parameter()] + [switch]$NoRestore, + [Parameter()] + [string]$AccessToken ) -& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality +if (!$NoPrerequisites) { + & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken + & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality +} + +Push-Location $PSScriptRoot +try { + $HeaderColor = 'Green' + + if (!$NoRestore) { + Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor + dotnet restore src + if ($lastexitcode -ne 0) { + throw "Failure while restoring packages." + } + } +} +catch { + Write-Error $error[0] + exit $lastexitcode +} +finally { + Pop-Location +} diff --git a/nuget.config b/nuget.config index 4941d22b8..d068efcf6 100644 --- a/nuget.config +++ b/nuget.config @@ -3,6 +3,6 @@ - + diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 new file mode 100644 index 000000000..df450dc79 --- /dev/null +++ b/tools/Install-NuGetCredProvider.ps1 @@ -0,0 +1,62 @@ +<# +.SYNOPSIS + Downloads and installs the Microsoft Artifacts Credential Provider + from https://github.com/microsoft/artifacts-credprovider + to assist in authenticating to Azure Artifact feeds in interactive development + or unattended build agents. +.PARAMETER AccessToken + An optional access token for authenticating to Azure Artifacts authenticated feeds. +#> +[CmdletBinding()] +Param ( + [Parameter()] + [string]$AccessToken +) + +$toolsPath = & "$PSScriptRoot\..\azure-pipelines\Get-TempToolsPath.ps1" + +if ($IsMacOS -or $IsLinux) { + $installerScript = "installcredprovider.sh" + $sourceUrl = "https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh" +} else { + $installerScript = "installcredprovider.ps1" + $sourceUrl = "https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1" +} + +$installerScript = Join-Path $toolsPath $installerScript + +if (!(Test-Path $installerScript)) { + Invoke-WebRequest $sourceUrl -OutFile $installerScript +} + +$installerScript = (Resolve-Path $installerScript).Path + +if ($IsMacOS -or $IsLinux) { + chmod u+x $installerScript +} + +& $installerScript + +if ($AccessToken) { + $endpoints = @() + + $nugetConfig = [xml](Get-Content -Path "$PSScriptRoot\..\nuget.config") + + $nugetConfig.configuration.packageSources.add |? { $_.value -match '^https://pkgs\.dev\.azure\.com/' } |% { + $endpoint = New-Object -TypeName PSObject + Add-Member -InputObject $endpoint -MemberType NoteProperty -Name endpoint -Value $_.value + Add-Member -InputObject $endpoint -MemberType NoteProperty -Name username -Value ado + Add-Member -InputObject $endpoint -MemberType NoteProperty -Name password -Value $AccessToken + $endpoints += $endpoint + } + + $auth = New-Object -TypeName PSObject + Add-Member -InputObject $auth -MemberType NoteProperty -Name endpointCredentials -Value $endpoints + + $authJson = ConvertTo-Json -InputObject $auth + $envVars = @{ + 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS'=$authJson; + } + + & "$PSScriptRoot\..\azure-pipelines\Set-EnvVars.ps1" -Variables $envVars | Out-Null +} From a7959d73f580b59b62b49b5fb526e1d4d0bc0115 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 28 Jul 2019 17:07:53 -0600 Subject: [PATCH 035/641] Add option to install SDKs machine-wide --- init.ps1 | 7 ++- tools/Install-DotNetSdk.ps1 | 106 ++++++++++++++++++++++++++++-------- 2 files changed, 89 insertions(+), 24 deletions(-) diff --git a/init.ps1 b/init.ps1 index 17389cbc6..599cfb47b 100644 --- a/init.ps1 +++ b/init.ps1 @@ -2,13 +2,16 @@ .SYNOPSIS Installs dependencies required to build and test the projects in this repository. .DESCRIPTION -This does not require elevation, as the dependencies are installed in per-user locations. +This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location, +unless `-InstallLocality machine` is specified. .PARAMETER InstallLocality A value indicating whether dependencies should be installed locally to the repo or at a per-user location. Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. +Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. +Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. .PARAMETER NoPrerequisites Skips the installation of prerequisite software (e.g. SDKs, tools). .PARAMETER NoRestore @@ -18,7 +21,7 @@ An optional access token for authenticating to Azure Artifacts authenticated fee #> [CmdletBinding(SupportsShouldProcess=$true)] Param ( - [ValidateSet('repo','user')] + [ValidateSet('repo','user','machine')] [string]$InstallLocality='user', [Parameter()] [switch]$NoPrerequisites, diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 2eccce41f..a5d52eedf 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -3,22 +3,102 @@ Installs the .NET SDK specified in the global.json file at the root of this repository, along with supporting .NET Core runtimes used for testing. .DESCRIPTION -This does not require elevation, as the SDK and runtimes are installed locally to this repo location. +This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location, +unless `-InstallLocality machine` is specified. .PARAMETER InstallLocality A value indicating whether dependencies should be installed locally to the repo or at a per-user location. Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. +Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. +Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] Param ( - [ValidateSet('repo','user')] + [ValidateSet('repo','user','machine')] [string]$InstallLocality='user' ) -$DotNetInstallScriptRoot = "$PSScriptRoot/../obj" -if (!(Test-Path $DotNetInstallScriptRoot)) { mkdir $DotNetInstallScriptRoot | Out-Null } +$DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools" +if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot | Out-Null } +$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot + +# Look up actual required .NET Core SDK version from global.json +$sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1" + +# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. +$runtimeVersions = @() +Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% { + $projXml = [xml](Get-Content -Path $_) + $targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework + if (!$targetFrameworks) { + $targetFrameworks = $projXml.Project.PropertyGroup.TargetFrameworks + if ($targetFrameworks) { + $targetFrameworks = $targetFrameworks -Split ';' + } + } + $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% { + $runtimeVersions += $Matches[1] + } +} + +Function Get-FileFromWeb([Uri]$Uri, $OutDir) { + $OutFile = Join-Path $OutDir $Uri.Segments[-1] + if (!(Test-Path $OutFile)) { + Write-Verbose "Downloading $Uri..." + try { + (New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile) + } finally { + # This try/finally causes the script to abort + } + } + + $OutFile +} + +Function Get-InstallerExe($Version, [switch]$Runtime) { + $sdkOrRuntime = 'Sdk' + if ($Runtime) { $sdkOrRuntime = 'Runtime' } + + # Get the latest/actual version for the specified one + if (([Version]$Version).Build -eq -1) { + $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/latest.version") + $Version = $versionInfo[-1] + } + + Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-x64.exe" -OutDir "$DotNetInstallScriptRoot" +} + +Function Install-DotNet($Version, [switch]$Runtime) { + if ($Runtime) { $sdkSubstring = '' } else { $sdkSubstring = 'SDK ' } + Write-Host "Downloading .NET Core $sdkSubstring$Version..." + $Installer = Get-InstallerExe -Version $Version -Runtime:$Runtime + Write-Host "Installing .NET Core $sdkSubstring$Version..." + cmd /c start /wait $Installer /install /quiet + if ($LASTEXITCODE -ne 0) { + throw "Failure to install .NET Core SDK" + } +} + +if ($InstallLocality -eq 'machine') { + if ($IsMacOS -or $IsLinux) { + Write-Error "Installing the .NET Core SDK or runtime at a machine-wide location is only supported by this script on Windows." + exit 1 + } + + if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + Install-DotNet -Version $sdkVersion + } + + $runtimeVersions |% { + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + Install-DotNet -Version $_ -Runtime + } + } + + return +} $switches = @( '-Architecture','x64' @@ -28,7 +108,6 @@ $envVars = @{ 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true'; } -$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot if ($InstallLocality -eq 'repo') { $DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet" } elseif ($env:AGENT_TOOLSDIRECTORY) { @@ -44,7 +123,6 @@ if ($DotNetInstallDir) { $envVars['DOTNET_MULTILEVEL_LOOKUP'] = '0' $envVars['DOTNET_ROOT'] = $DotNetInstallDir } -$sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1" if ($IsMacOS -or $IsLinux) { $DownloadUri = "https://dot.net/v1/dotnet-install.sh" @@ -67,22 +145,6 @@ if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" } -# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. -$runtimeVersions = @() -Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% { - $projXml = [xml](Get-Content -Path $_) - $targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework - if (!$targetFrameworks) { - $targetFrameworks = $projXml.Project.PropertyGroup.TargetFrameworks - if ($targetFrameworks) { - $targetFrameworks = $targetFrameworks -Split ';' - } - } - $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% { - $runtimeVersions += $Matches[1] - } -} - $switches += '-Runtime','dotnet' $runtimeVersions | Get-Unique |% { From 3ce68babff89107f16755b99e6ef05f96685af15 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 28 Jul 2019 21:07:54 -0600 Subject: [PATCH 036/641] Fix Get-nbgv.ps1 on Mac/Linux --- azure-pipelines/Get-nbgv.ps1 | 7 +++---- azure-pipelines/build.yml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/azure-pipelines/Get-nbgv.ps1 b/azure-pipelines/Get-nbgv.ps1 index 8459995f5..925eecddb 100644 --- a/azure-pipelines/Get-nbgv.ps1 +++ b/azure-pipelines/Get-nbgv.ps1 @@ -13,16 +13,15 @@ if ($existingTool) { if ($env:AGENT_TEMPDIRECTORY) { $toolInstallDir = "$env:AGENT_TEMPDIRECTORY/$env:BUILD_BUILDID" } else { - $toolInstallDir = "$PSScriptRoot/obj/tools" + $toolInstallDir = "$PSScriptRoot/../obj/tools" } $toolPath = "$toolInstallDir/nbgv" -if (!(Test-Path $toolPath)) { New-Item -Path $toolPath -ItemType Directory | Out-Null } -$toolPath = (Resolve-Path $toolPath).Path +if (!(Test-Path $toolInstallDir)) { New-Item -Path $toolInstallDir -ItemType Directory | Out-Null } if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) { Write-Host "Installing nbgv to $toolInstallDir" - dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot\justnugetorg.nuget.config" | Out-Null + dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot/justnugetorg.nuget.config" | Out-Null } # Normalize the path on the way out. diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index f81d7f14d..bc7facfa2 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -9,7 +9,7 @@ jobs: clean: true # "all" doesn't work, but "true" does, despite YAML docs - template: install-dependencies.yml - - powershell: '& (azure-pipelines\Get-nbgv.ps1) cloud' + - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud' displayName: Set build number - template: dotnet.yml From 109cb712d6d68aad3bcaf26209c7ed26b8abc50c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 29 Jul 2019 07:01:49 -0600 Subject: [PATCH 037/641] Clean on mac agent too --- azure-pipelines/build.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index bc7facfa2..05e32a18e 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -6,7 +6,7 @@ jobs: pool: ${{ parameters.windowsPool }} steps: - checkout: self - clean: true # "all" doesn't work, but "true" does, despite YAML docs + clean: true - template: install-dependencies.yml - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud' @@ -20,7 +20,7 @@ jobs: vmImage: Ubuntu 16.04 steps: - checkout: self - clean: true # "all" doesn't work, but "true" does, despite YAML docs + clean: true - template: install-dependencies.yml - template: dotnet.yml - template: expand-template.yml @@ -29,6 +29,8 @@ jobs: pool: vmImage: macOS 10.13 steps: + - checkout: self + clean: true - template: install-dependencies.yml - template: dotnet.yml - template: expand-template.yml @@ -43,7 +45,7 @@ jobs: condition: succeededOrFailed() steps: - checkout: self - clean: true # "all" doesn't work, but "true" does, despite YAML docs + clean: true - template: install-dependencies.yml parameters: initArgs: -NoRestore From bea56a3333705f9c8cd8dd5d0f6e439ea398662d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 29 Jul 2019 08:46:14 -0600 Subject: [PATCH 038/641] Add nuget package copyright metadata --- src/Directory.Build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f4ef32972..475d57b8a 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,5 +1,4 @@ - - + Debug $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\')) @@ -14,6 +13,7 @@ COMPANY-PLACEHOLDER COMPANY-PLACEHOLDER + © COMPANY-PLACEHOLDER. All rights reserved. MIT true true From 2bbbf08ee728b4e72a4224ff94f9854a2150d315 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 29 Jul 2019 08:54:24 -0600 Subject: [PATCH 039/641] Switch to 'download' syntax --- azure-pipelines/publish-codecoverage.yml | 22 ++++++++-------------- azure-pipelines/publish-deployables.yml | 8 +++----- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 5d987c83e..6d367de96 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -1,27 +1,21 @@ steps: -- task: DownloadBuildArtifacts@0 +- download: current + artifact: coverageResults-Windows displayName: Download Windows code coverage results - inputs: - artifactName: coverageResults-Windows - downloadPath: $(System.DefaultWorkingDirectory)/bin continueOnError: true -- task: DownloadBuildArtifacts@0 +- download: current + artifact: coverageResults-Linux displayName: Download Linux code coverage results - inputs: - artifactName: coverageResults-Linux - downloadPath: $(System.DefaultWorkingDirectory)/bin continueOnError: true -- task: DownloadBuildArtifacts@0 +- download: current + artifact: coverageResults-macOS displayName: Download macOS code coverage results - inputs: - artifactName: coverageResults-macOS - downloadPath: $(System.DefaultWorkingDirectory)/bin continueOnError: true - powershell: | dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config - Copy-Item -Recurse $(System.DefaultWorkingDirectory)/bin/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj + Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" - $reports = Get-ChildItem -Recurse "$(System.DefaultWorkingDirectory)/bin/coverage.cobertura.xml" + $reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.cobertura.xml" $reports |% { $content = Get-Content -Path $_ |% { $_.Replace("{reporoot}", "$(System.DefaultWorkingDirectory)") } Set-Content -Path $_ -Value $content -Encoding UTF8 diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml index cdd852920..3f6bb9da5 100644 --- a/azure-pipelines/publish-deployables.yml +++ b/azure-pipelines/publish-deployables.yml @@ -1,15 +1,13 @@ steps: -- task: DownloadBuildArtifacts@0 +- download: current displayName: Download deployables - inputs: - artifactName: deployables-Windows - downloadPath: $(System.DefaultWorkingDirectory)/bin + artifact: deployables-Windows - task: DotNetCoreCLI@2 displayName: Push packages to CI feed inputs: command: push - packagesToPush: $(System.DefaultWorkingDirectory)/bin/deployables-Windows/*.nupkg + packagesToPush: $(Pipeline.Workspace)/deployables-Windows/*.nupkg nuGetFeedType: internal publishVstsFeed: $(ci_feed) allowPackageConflicts: true From c52d5ff380c256be1362a3e7d6da209cf1d80f57 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 1 Aug 2019 12:55:23 -0600 Subject: [PATCH 040/641] Update package references --- src/Directory.Build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 475d57b8a..8f62479f7 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -23,9 +23,9 @@ - + - + From a66b8ad7f5034766b8d876348d550680e9fda596 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 1 Aug 2019 16:06:04 -0600 Subject: [PATCH 041/641] Don't break build when package conflicts happen in CI DotNetCliTool doesn't support the allowPackageConflicts parameter. --- azure-pipelines/publish-deployables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml index 3f6bb9da5..a89f389fd 100644 --- a/azure-pipelines/publish-deployables.yml +++ b/azure-pipelines/publish-deployables.yml @@ -3,7 +3,7 @@ steps: displayName: Download deployables artifact: deployables-Windows -- task: DotNetCoreCLI@2 +- task: NuGetCommand@2 displayName: Push packages to CI feed inputs: command: push From 747490e372cd36a440bcf0c83a0a8bf75d493e1e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 1 Aug 2019 17:18:50 -0600 Subject: [PATCH 042/641] Fix up VSTS references to Azure Pipelines --- azure-pipelines/artifacts/_pipelines.ps1 | 2 +- azure-pipelines/variables/_pipelines.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 index 270a96043..7451ab111 100644 --- a/azure-pipelines/artifacts/_pipelines.ps1 +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -1,5 +1,5 @@ # This script translates all the artifacts described by _all.ps1 -# into commands that instruct VSTS to actually collect those artifacts. +# into commands that instruct Azure Pipelines to actually collect those artifacts. param ( [string]$ArtifactNameSuffix diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index b3fde25da..9fa0c16b7 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -1,5 +1,5 @@ # This script translates the variables returned by the _all.ps1 script -# into commands that instruct VSTS to actually set those variables for other VSTS tasks to consume. +# into commands that instruct Azure Pipelines to actually set those variables for other pipeline tasks to consume. # The build or release definition may have set these variables to override # what the build would do. So only set them if they have not already been set. From 4ed1fa825f5f77ee04a11fab2bef44607b8205ce Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 4 Aug 2019 06:30:58 -0600 Subject: [PATCH 043/641] Add support for nuget feeds using old style URLs --- tools/Install-NuGetCredProvider.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 index df450dc79..ba70f2bd8 100644 --- a/tools/Install-NuGetCredProvider.ps1 +++ b/tools/Install-NuGetCredProvider.ps1 @@ -42,7 +42,7 @@ if ($AccessToken) { $nugetConfig = [xml](Get-Content -Path "$PSScriptRoot\..\nuget.config") - $nugetConfig.configuration.packageSources.add |? { $_.value -match '^https://pkgs\.dev\.azure\.com/' } |% { + $nugetConfig.configuration.packageSources.add |? { ($_.value -match '^https://pkgs\.dev\.azure\.com/') -or ($_.value -match '^https://[\w\-]+\.pkgs\.visualstudio\.com/') } |% { $endpoint = New-Object -TypeName PSObject Add-Member -InputObject $endpoint -MemberType NoteProperty -Name endpoint -Value $_.value Add-Member -InputObject $endpoint -MemberType NoteProperty -Name username -Value ado From 02c4f0bb21a0fa9b57e8321f86118a5f234f35c8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 5 Aug 2019 09:26:04 -0600 Subject: [PATCH 044/641] Skip net472 tests after a build failure --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 96569224a..21b189f2f 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -15,7 +15,7 @@ steps: arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true testRunTitle: net472-$(Agent.JobName) workingDirectory: src - condition: eq(variables['Agent.OS'], 'Windows_NT') + condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp2.1 From 6957e47ebdb45d635db0721353870d49032ef992 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 5 Aug 2019 12:42:53 -0600 Subject: [PATCH 045/641] Update .NET Core SDK to 2.2.401 --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 932387844..3d26ee658 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.2.300" + "version": "2.2.401" } -} \ No newline at end of file +} From fe7fee63e1c044ea141b04418dae57ae7cc847b6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 7 Aug 2019 09:13:36 -0600 Subject: [PATCH 046/641] Fix formatting of xml and json files --- src/.editorconfig => .editorconfig | 0 .vscode/extensions.json | 32 ++++++++++++++---------------- nuget.config | 4 ++-- 3 files changed, 17 insertions(+), 19 deletions(-) rename src/.editorconfig => .editorconfig (100%) diff --git a/src/.editorconfig b/.editorconfig similarity index 100% rename from src/.editorconfig rename to .editorconfig diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f910c6876..8b1c54d64 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,18 +1,16 @@ { - // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. - // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - - // List of extensions which should be recommended for users of this workspace. - "recommendations": [ - "ms-azure-devops.azure-pipelines", - "ms-vscode.csharp", - "k--kato.docomment", - "editorconfig.editorconfig", - "pflannery.vscode-versionlens", - "davidanson.vscode-markdownlint" - ], - // List of extensions recommended by VS Code that should not be recommended for users of this workspace. - "unwantedRecommendations": [ - - ] -} \ No newline at end of file + // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "ms-azure-devops.azure-pipelines", + "ms-vscode.csharp", + "k--kato.docomment", + "editorconfig.editorconfig", + "pflannery.vscode-versionlens", + "davidanson.vscode-markdownlint", + "dotjoshjohnson.xml" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/nuget.config b/nuget.config index d068efcf6..1ee7a2bc9 100644 --- a/nuget.config +++ b/nuget.config @@ -1,8 +1,8 @@ - + - + From 8f108fe64a258c923ab3322fe802c3c50651390b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 9 Aug 2019 10:15:03 -0600 Subject: [PATCH 047/641] Update NB.GV to 3.0.25 --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 8f62479f7..8c3372758 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -26,7 +26,7 @@ - + From 5847f0ae57e1277afff053774a11f7b64bb2b678 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 9 Aug 2019 13:51:24 -0600 Subject: [PATCH 048/641] Use a local package cache This ensures that restore always uses the sources in nuget.config rather than a cache that happens to be on the local box. It helps avoid bugs that are not caught till a build suddenly fails on some machine somewhere because it didn't happen to have a package cached locally from some other source. It also mitigates the risk on private build agents that a package cache is "poisoned" by some build already done on that agent with other package sources where the id/version of a package collides but the contents are not actually identical. --- nuget.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nuget.config b/nuget.config index 1ee7a2bc9..4949867c4 100644 --- a/nuget.config +++ b/nuget.config @@ -1,5 +1,8 @@ + + + From 364dfe9f316b1ed9fb950bdb8dc51c361bb83a99 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 11 Aug 2019 23:15:23 -0600 Subject: [PATCH 049/641] When squashing, record the original commit ID --- Expand-Template.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index c050aba3f..89614a2d4 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -74,8 +74,9 @@ if (-not $sn) { Push-Location $PSScriptRoot try { if ($Squash) { + $originalCommitId = git rev-parse HEAD git reset --soft $(git rev-list --max-parents=0 HEAD) - git commit --amend -qm "Initial template from https://github.com/AArnott/Library.Template" + git commit --amend -qm "Initial template from https://github.com/AArnott/Library.Template" -m "Original commit from template $originalCommitId" } # Rename project directories and solution From 4705734f048b74f2dedb26799b157dcb7d74571e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 16 Aug 2019 16:48:54 -0600 Subject: [PATCH 050/641] Fix nuget install Get packages into a subdirectory and use nuget.exe 5.2.0 so it works with the credential provider. --- azure-pipelines/Get-NuGetTool.ps1 | 2 +- nuget.config | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/Get-NuGetTool.ps1 b/azure-pipelines/Get-NuGetTool.ps1 index fdf3ed55e..623bb6f02 100644 --- a/azure-pipelines/Get-NuGetTool.ps1 +++ b/azure-pipelines/Get-NuGetTool.ps1 @@ -6,7 +6,7 @@ #> Param( [Parameter()] - [string]$NuGetVersion='5.0.2' + [string]$NuGetVersion='5.2.0' ) $toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1" diff --git a/nuget.config b/nuget.config index 4949867c4..385887117 100644 --- a/nuget.config +++ b/nuget.config @@ -2,6 +2,7 @@ + From 4ecab1957dd720fb5110f882475090d8a540aad3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 16 Aug 2019 16:54:28 -0600 Subject: [PATCH 051/641] Redirect Only divert global package cache in Azure Pipelines On local machines, file locks on the global package cache can cause `git clean -fdx` to fail. It also causes package restore times to be longer on local boxes after cleaning. The extra protection afforded by a diverted package cache is good, but is probably sufficient to provide only in Azure Pipelines, or explicitly by the user when they want it. --- azure-pipelines.yml | 1 + nuget.config | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f158ff523..539df93ae 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,6 +16,7 @@ variables: BuildPlatform: Any CPU codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed + NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages jobs: - template: azure-pipelines/build.yml diff --git a/nuget.config b/nuget.config index 385887117..c0173d1ba 100644 --- a/nuget.config +++ b/nuget.config @@ -1,7 +1,6 @@ - From 8931dfb7818bb7e5173cbdd991d8af2c2a6699ca Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 16 Aug 2019 17:03:52 -0600 Subject: [PATCH 052/641] Download nuget.exe much more quickly Invoke-WebRequest is a terribly slow way to download files. --- azure-pipelines/Get-NuGetTool.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/Get-NuGetTool.ps1 b/azure-pipelines/Get-NuGetTool.ps1 index 623bb6f02..4431adb91 100644 --- a/azure-pipelines/Get-NuGetTool.ps1 +++ b/azure-pipelines/Get-NuGetTool.ps1 @@ -16,7 +16,7 @@ $nugetPath = Join-Path $binaryToolsPath nuget.exe if (!(Test-Path $nugetPath)) { Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow - Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe" -OutFile $nugetPath | Out-Null + (New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe", $nugetPath) } return (Resolve-Path $nugetPath).Path From 5cc44c4f2bbfd483104621a636e924a2e0544dc4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 10 Sep 2019 17:19:48 -0600 Subject: [PATCH 053/641] Improve Azure Pipelines build reliability This works around a bug that causes our Windows agent to very frequently fail in the nuget credential provider. --- init.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/init.ps1 b/init.ps1 index 599cfb47b..e01f3aed5 100644 --- a/init.ps1 +++ b/init.ps1 @@ -36,6 +36,10 @@ if (!$NoPrerequisites) { & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality } +# Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines +$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20 +$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20 + Push-Location $PSScriptRoot try { $HeaderColor = 'Green' From 70dcacac07c281ebe1e60ce5acbb5a22e1449df7 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 17 Sep 2019 15:22:46 -0700 Subject: [PATCH 054/641] Use HTTPS URLs wherever possible --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 8b1c54d64..c5b615df4 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,5 @@ { - // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp // List of extensions which should be recommended for users of this workspace. "recommendations": [ From 4641b826b0717b388f241a7eeda281f344d7042a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 21 Sep 2019 21:53:35 -0600 Subject: [PATCH 055/641] Fix auto-build of validate/* branches --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 539df93ae..c4c3f607c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,7 +2,7 @@ trigger: branches: include: - master - - validate/* + - 'validate/*' paths: exclude: - doc/ From a77d264bbc72eb0f201c2fc14db40525746417d9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 25 Sep 2019 06:26:38 -0600 Subject: [PATCH 056/641] Suppress an unreasonable static analysis rule for tests --- src/tests.ruleset | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests.ruleset b/src/tests.ruleset index 4b4708a12..a13659760 100644 --- a/src/tests.ruleset +++ b/src/tests.ruleset @@ -12,4 +12,7 @@ + + + From dfc7dea7c1e5b534a59206b8e9ab5996313c7cd3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 25 Sep 2019 06:26:43 -0600 Subject: [PATCH 057/641] Add a bunch of useful solution items --- src/Library.sln | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Library.sln b/src/Library.sln index 17645391b..09dfb1fe6 100644 --- a/src/Library.sln +++ b/src/Library.sln @@ -1,20 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29322.22 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library.Tests", "Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CE9670B-D5FF-46A7-9D00-24E70E6ED48B}" + ProjectSection(SolutionItems) = preProject + ..\.editorconfig = ..\.editorconfig + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + ..\global.json = ..\global.json + ..\nuget.config = ..\nuget.config + shipping.ruleset = shipping.ruleset + stylecop.json = stylecop.json + tests.ruleset = tests.ruleset + ..\version.json = ..\version.json + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C06D702E-6FC7-453B-BDDF-608F825EC003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C06D702E-6FC7-453B-BDDF-608F825EC003}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -25,4 +35,10 @@ Global {DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}.Release|Any CPU.ActiveCfg = Release|Any CPU {DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E3944F6A-384B-4B0F-B93F-3BD513DC57BD} + EndGlobalSection EndGlobal From 3c52f6060a928ea6a5297bcabdaf927bdc921cf3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 25 Sep 2019 06:26:06 -0600 Subject: [PATCH 058/641] Enable C# 8 nullable features Also update to 3.0 .NET Core SDK as required for the nullable feature. --- global.json | 2 +- src/Directory.Build.props | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 3d26ee658..79422f0cc 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.2.401" + "version": "3.0.100" } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 8c3372758..9c875502c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -5,7 +5,8 @@ $(RepoRootPath)obj\$(MSBuildProjectName)\ $(RepoRootPath)bin\$(MSBuildProjectName)\ $(RepoRootPath)bin\Packages\$(Configuration)\ - 7.3 + 8.0 + enable true true From a2556bf66ce72ef84c33077b94a9c83100d88e37 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Oct 2019 08:35:23 -0600 Subject: [PATCH 059/641] Fix Install-DotNetSdk on machines without IE configured --- tools/Install-DotNetSdk.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index a5d52eedf..50687706e 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -63,7 +63,7 @@ Function Get-InstallerExe($Version, [switch]$Runtime) { # Get the latest/actual version for the specified one if (([Version]$Version).Build -eq -1) { - $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/latest.version") + $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/latest.version" -UseBasicParsing) $Version = $versionInfo[-1] } @@ -133,7 +133,7 @@ if ($IsMacOS -or $IsLinux) { } if (-not (Test-Path $DotNetInstallScriptPath)) { - Invoke-WebRequest -Uri $DownloadUri -OutFile $DotNetInstallScriptPath + Invoke-WebRequest -Uri $DownloadUri -OutFile $DotNetInstallScriptPath -UseBasicParsing if ($IsMacOS -or $IsLinux) { chmod +x $DotNetInstallScriptPath } From f78ee0462a078f4190fa7e811e3a86105f545d61 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Nov 2019 21:43:54 -0700 Subject: [PATCH 060/641] Capture exit codes within init.cmd from ps1 script --- init.cmd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/init.cmd b/init.cmd index 5bef08da3..970285c2f 100644 --- a/init.cmd +++ b/init.cmd @@ -1,3 +1,4 @@ -@set PS1UnderCmd=1 -powershell.exe -ExecutionPolicy bypass -Command "& '%~dpn0.ps1'" %* -@set PS1UnderCmd= +@echo off +SETLOCAL +set PS1UnderCmd=1 +powershell.exe -NoProfile -NoLogo -ExecutionPolicy bypass -Command "try { & '%~dpn0.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }" From 7248b76f71de8ba2afa097d129367d784c371159 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Nov 2019 21:44:06 -0700 Subject: [PATCH 061/641] Add Expand-Template.cmd stub --- Expand-Template.cmd | 4 ++++ Expand-Template.ps1 | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Expand-Template.cmd diff --git a/Expand-Template.cmd b/Expand-Template.cmd new file mode 100644 index 000000000..970285c2f --- /dev/null +++ b/Expand-Template.cmd @@ -0,0 +1,4 @@ +@echo off +SETLOCAL +set PS1UnderCmd=1 +powershell.exe -NoProfile -NoLogo -ExecutionPolicy bypass -Command "try { & '%~dpn0.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }" diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 89614a2d4..5225f8785 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -149,11 +149,11 @@ try { # Self destruct $Invocation = (Get-Variable MyInvocation -Scope 1).Value - git rm Expand-Template.ps1 + git rm Expand-Template.* git rm :/azure-pipelines/expand-template.yml # Self-integrity check - Get-ChildItem -Recurse -File -Exclude bin,obj,README.md,Expand-Template.ps1 |? { -not $_.FullName.Contains("obj") } |% { + Get-ChildItem -Recurse -File -Exclude bin,obj,README.md,Expand-Template.* |? { -not $_.FullName.Contains("obj") } |% { $PLACEHOLDERS = Get-Content -Path $_.FullName |? { $_.Contains('PLACEHOLDER') } if ($PLACEHOLDERS) { Write-Error "PLACEHOLDER discovered in $($_.FullName)" @@ -162,6 +162,15 @@ try { # Commit the changes git commit -qm "Expanded template for $LibraryName" -m "This expansion done by the (now removed) Expand-Template.ps1 script." + + Write-Host -ForegroundColor Green "Template successfully expanded." + + if ($env:PS1UnderCmd) { + # We're running under the Expand-Template.cmd script. + # Since we just deleted it from disk cmd.exe will complain. Just advise the user it's OK. + Write-Host -ForegroundColor Green 'Disregard an error you may see: "The batch file cannot be found." We just cleaned up after ourselves.' + } + } finally { Pop-Location } From 65c7a0b46f10e72cf2f73e169956da9b15170e4c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Nov 2019 22:01:51 -0700 Subject: [PATCH 062/641] Fix synopsis of Convert-PDB.ps1 script Fixes #24 --- azure-pipelines/Convert-PDB.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/Convert-PDB.ps1 b/azure-pipelines/Convert-PDB.ps1 index 00549f713..a3212213b 100644 --- a/azure-pipelines/Convert-PDB.ps1 +++ b/azure-pipelines/Convert-PDB.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Builds all projects in this repo. + Converts between Windows PDB and Portable PDB formats. .PARAMETER DllPath The path to the DLL whose PDB is to be converted. .PARAMETER PdbPath From d6fe2405533b5f5da639dfb65e1ef5e8dfabf4ee Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Nov 2019 22:03:46 -0700 Subject: [PATCH 063/641] Add comment explaining where to get the guid from Fixes #28 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c4c3f607c..2dbb2cbbd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,7 +15,7 @@ variables: BuildConfiguration: Release BuildPlatform: Any CPU codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ - ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed + ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed. Learn more at https://github.com/AArnott/Library.Template/issues/28 NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages jobs: From 51d643cbab57eb43bc15d294e153c7ce40b76e9f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 22 Nov 2019 09:02:44 -0700 Subject: [PATCH 064/641] Avoid restoring packages under -whatif --- init.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.ps1 b/init.ps1 index e01f3aed5..f8ca00a5d 100644 --- a/init.ps1 +++ b/init.ps1 @@ -44,7 +44,7 @@ Push-Location $PSScriptRoot try { $HeaderColor = 'Green' - if (!$NoRestore) { + if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) { Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor dotnet restore src if ($lastexitcode -ne 0) { From 5a6c63701f386823b6e12d4a0052d3ced73ae332 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 4 Dec 2019 13:03:21 -0700 Subject: [PATCH 065/641] Fix and add to the init.ps1 description docs --- init.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init.ps1 b/init.ps1 index f8ca00a5d..9dfb6afb9 100644 --- a/init.ps1 +++ b/init.ps1 @@ -2,8 +2,9 @@ .SYNOPSIS Installs dependencies required to build and test the projects in this repository. .DESCRIPTION -This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location, -unless `-InstallLocality machine` is specified. +This MAY not require elevation, as the SDK and runtimes are installed to a per-user location, +unless the `-InstallLocality` switch is specified directing to a per-repo or per-machine location. +See detailed help on that switch for more information. .PARAMETER InstallLocality A value indicating whether dependencies should be installed locally to the repo or at a per-user location. Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. From b79e0301b39153cbd09dca06767c7264178e274e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 11 Dec 2019 17:13:57 -0700 Subject: [PATCH 066/641] Use AGENT_TEMPDIRECTORY for tools AGENT_TOOLSDIRECTORY may not be cleaned between each build, so AGENT_TEMPDIRECTORY which certainly is cleaned is a better place to put files that might need newer versions downloaded and/or installed each time. --- azure-pipelines/Get-TempToolsPath.ps1 | 6 +++--- azure-pipelines/Get-nbgv.ps1 | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/azure-pipelines/Get-TempToolsPath.ps1 b/azure-pipelines/Get-TempToolsPath.ps1 index 97c552c06..bb3da8e33 100644 --- a/azure-pipelines/Get-TempToolsPath.ps1 +++ b/azure-pipelines/Get-TempToolsPath.ps1 @@ -1,7 +1,7 @@ -if ($env:AGENT_TOOLSDIRECTORY) { - $path = "$env:AGENT_TOOLSDIRECTORY\vs-platform\tools" +if ($env:AGENT_TEMPDIRECTORY) { + $path = "$env:AGENT_TEMPDIRECTORY\$env:BUILD_BUILDID" } elseif ($env:localappdata) { - $path = "$env:localappdata\vs-platform\tools" + $path = "$env:localappdata\gitrepos\tools" } else { $path = "$PSScriptRoot\..\obj\tools" } diff --git a/azure-pipelines/Get-nbgv.ps1 b/azure-pipelines/Get-nbgv.ps1 index 925eecddb..a5be2cf7c 100644 --- a/azure-pipelines/Get-nbgv.ps1 +++ b/azure-pipelines/Get-nbgv.ps1 @@ -10,11 +10,7 @@ if ($existingTool) { return $existingTool.Path } -if ($env:AGENT_TEMPDIRECTORY) { - $toolInstallDir = "$env:AGENT_TEMPDIRECTORY/$env:BUILD_BUILDID" -} else { - $toolInstallDir = "$PSScriptRoot/../obj/tools" -} +$toolInstallDir = & "$PSScriptRoot/Get-TempToolsPath.ps1" $toolPath = "$toolInstallDir/nbgv" if (!(Test-Path $toolInstallDir)) { New-Item -Path $toolInstallDir -ItemType Directory | Out-Null } From 153cd7d1aaa4738c163e1ad2ee813075183890b0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 11 Dec 2019 17:31:06 -0700 Subject: [PATCH 067/641] Upgrade NuGet credprovider in Azure Pipelines On private agents where it may exist from a prior build, it's important that we update it to whatever the latest version is. --- azure-pipelines/install-dependencies.yml | 2 +- init.ps1 | 7 ++++++- tools/Install-NuGetCredProvider.ps1 | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 8da07957b..9257db852 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -4,7 +4,7 @@ parameters: steps: - powershell: | - .\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} + .\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} -UpgradePrerequisites dotnet --info displayName: Install prerequisites diff --git a/init.ps1 b/init.ps1 index 9dfb6afb9..ae4ce9a69 100644 --- a/init.ps1 +++ b/init.ps1 @@ -15,6 +15,9 @@ Per-repo can lead to file locking issues when dotnet.exe is left running as a bu Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. .PARAMETER NoPrerequisites Skips the installation of prerequisite software (e.g. SDKs, tools). +.PARAMETER UpgradePrerequisites +Takes time to install prerequisites even if they are already present in case they need to be upgraded. +No effect if -NoPrerequisites is specified. .PARAMETER NoRestore Skips the package restore step. .PARAMETER AccessToken @@ -27,13 +30,15 @@ Param ( [Parameter()] [switch]$NoPrerequisites, [Parameter()] + [switch]$UpgradePrerequisites, + [Parameter()] [switch]$NoRestore, [Parameter()] [string]$AccessToken ) if (!$NoPrerequisites) { - & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken + & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality } diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 index ba70f2bd8..0a8d77f62 100644 --- a/tools/Install-NuGetCredProvider.ps1 +++ b/tools/Install-NuGetCredProvider.ps1 @@ -4,11 +4,15 @@ from https://github.com/microsoft/artifacts-credprovider to assist in authenticating to Azure Artifact feeds in interactive development or unattended build agents. +.PARAMETER Force + Forces install of the CredProvider plugin even if one already exists. This is useful to upgrade an older version. .PARAMETER AccessToken An optional access token for authenticating to Azure Artifacts authenticated feeds. #> [CmdletBinding()] Param ( + [Parameter()] + [switch]$Force, [Parameter()] [string]$AccessToken ) @@ -35,7 +39,7 @@ if ($IsMacOS -or $IsLinux) { chmod u+x $installerScript } -& $installerScript +& $installerScript -Force:$Force if ($AccessToken) { $endpoints = @() From be9bbd097fb0410325e1d896f9d3a55f2280e64b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 18 Dec 2019 13:50:18 -0700 Subject: [PATCH 068/641] Update package refs Also stop packing pdb in main nupkg --- src/Directory.Build.props | 9 ++++----- src/Library.Tests/Library.Tests.csproj | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9c875502c..f6d3c9ce6 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -20,14 +20,13 @@ true true snupkg - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - - - + + + + diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj index 7323c8d96..08f74be77 100644 --- a/src/Library.Tests/Library.Tests.csproj +++ b/src/Library.Tests/Library.Tests.csproj @@ -14,8 +14,8 @@ - - + + From e888eb54024e259c801b9b37d363d08ef3eb3f1c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 24 Dec 2019 13:23:35 -0700 Subject: [PATCH 069/641] Bump SDK version to 3.1 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 79422f0cc..e9aac8c22 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.0.100" + "version": "3.1.100" } } From 35bf0941b3900c248c745588f62d711a3bf6860c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 24 Dec 2019 13:36:35 -0700 Subject: [PATCH 070/641] Test on .NET Core 3.1 .NET Core 2.2 is no longer supported. Testing on 2.1 and 3.1 focus testing on LTS releases of .NET Core. --- azure-pipelines/dotnet.yml | 6 +++--- src/Library.Tests/Library.Tests.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 21b189f2f..9d910d2dc 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -26,11 +26,11 @@ steps: workingDirectory: src - task: DotNetCoreCLI@2 - displayName: dotnet test -f netcoreapp2.2 + displayName: dotnet test -f netcoreapp3.1 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.2 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true - testRunTitle: netcoreapp2.2-$(Agent.JobName) + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + testRunTitle: netcoreapp3.1-$(Agent.JobName) workingDirectory: src - task: PowerShell@2 diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj index 08f74be77..78ebcfd4d 100644 --- a/src/Library.Tests/Library.Tests.csproj +++ b/src/Library.Tests/Library.Tests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp2.1;netcoreapp2.2 + net472;netcoreapp2.1;netcoreapp3.1 false $(NoWarn);CS1591 true From 56ab8cb586bb555875acdfe597465ef75aec5dcb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 24 Dec 2019 14:35:30 -0700 Subject: [PATCH 071/641] Use latest StyleCop As necessary for nullable ref type syntax to not flag as warnings in StyleCop --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f6d3c9ce6..ddd8ae606 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -27,7 +27,7 @@ - + From 366d5df26c31eb212dc49c970ec77597874b5fc3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Jan 2020 14:59:28 -0700 Subject: [PATCH 072/641] Start with GitHub Actions (#34) --- .github/workflows/build.yml | 99 ++++++++++++++++++++++++ Expand-Template.ps1 | 3 +- README.md | 4 +- azure-pipelines.yml | 1 - azure-pipelines/Set-EnvVars.ps1 | 46 ++++++++++- azure-pipelines/artifacts/Variables.ps1 | 10 +-- azure-pipelines/artifacts/_pipelines.ps1 | 49 +----------- azure-pipelines/artifacts/_stage_all.ps1 | 59 ++++++++++++++ azure-pipelines/build.yml | 4 +- azure-pipelines/variables/_pipelines.ps1 | 8 +- tools/Install-DotNetSdk.ps1 | 38 +-------- 11 files changed, 222 insertions(+), 99 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 azure-pipelines/artifacts/_stage_all.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..4e9918733 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,99 @@ +name: CI + +on: + push: + branches: + - master + - microbuild + - validate/* + pull_request: + +env: + TreatWarningsAsErrors: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + BUILDCONFIGURATION: Release + codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ + ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed. Learn more at https://github.com/AArnott/Library.Template/issues/28 +# NUGET_PACKAGES: ${{ env.GITHUB_WORKSPACE }}/.nuget/packages + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-18.04 + - macos-latest + - windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Deep clone + run: git fetch --prune --unshallow origin HEAD + - name: Install prerequisites + run: | + ./init.ps1 -UpgradePrerequisites + dotnet --info + shell: pwsh + - name: Set pipeline variables based on source + run: azure-pipelines/variables/_pipelines.ps1 + shell: pwsh + - name: build + run: dotnet build src --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog" + - name: pack + run: dotnet pack src --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog" + - name: test + run: dotnet test src --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + - name: Update pipeline variables based on build outputs + run: azure-pipelines/variables/_pipelines.ps1 + shell: pwsh + - name: Collect artifacts + run: azure-pipelines/artifacts/_stage_all.ps1 + shell: pwsh + - name: Upload project.assets.json files + if: always() + uses: actions/upload-artifact@v1 + with: + name: projectAssetsJson-${{ runner.os }} + path: obj/_artifacts/projectAssetsJson + continue-on-error: true + - name: Upload variables + uses: actions/upload-artifact@v1 + with: + name: variables + path: obj/_artifacts/variables + if: runner.os == 'Windows' + continue-on-error: true + - name: Upload build_logs + if: always() + uses: actions/upload-artifact@v1 + with: + name: build_logs-${{ runner.os }} + path: obj/_artifacts/build_logs + continue-on-error: true + - name: Upload coverageResults + if: always() + uses: actions/upload-artifact@v1 + with: + name: coverageResults-${{ runner.os }} + path: obj/_artifacts/coverageResults + continue-on-error: true + - name: Upload symbols + uses: actions/upload-artifact@v1 + with: + name: symbols + path: obj/_artifacts/symbols + if: runner.os == 'Windows' + continue-on-error: true + - name: Upload deployables + uses: actions/upload-artifact@v1 + with: + name: deployables + path: obj/_artifacts/deployables + if: runner.os == 'Windows' + - name: Publish code coverage results to codecov.io + run: bash <(curl -s https://codecov.io/bash) + shell: bash + timeout-minutes: 3 + continue-on-error: true diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 5225f8785..aa4f5ec25 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -125,7 +125,8 @@ try { } Replace-Placeholders -Path "README.md" -Replacements @{ "(?m)^.*\[NuGet package\][^`r`n]*"="[![NuGet package](https://img.shields.io/nuget/v/$LibraryName.svg)](https://nuget.org/packages/$LibraryName)" - "(?m)^.*\[Build Status\].*`r?`n"="" + "(?m)^.*\[Azure Pipelines status\].*`r?`n"="" + "(?m)^.*\[GitHub Actions status\].*`r?`n"="" "(?m)^.*\[codecov\].*`r?`n"="" } diff --git a/README.md b/README.md index d05ac0d72..0c3bcf59e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ ***An awesome template for your awesome library*** ![NuGet package](https://img.shields.io/badge/nuget-your--package--here-yellow.svg) -[![Build Status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/AArnott.Library.Template?branchName=master)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=29&branchName=master) + +[![Azure Pipelines status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/AArnott.Library.Template?branchName=master)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=29&branchName=master) +![GitHub Actions status](https://github.com/aarnott/Library.Template/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/aarnott/library.template/branch/master/graph/badge.svg)](https://codecov.io/gh/aarnott/library.template) ## Features diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2dbb2cbbd..c6eeb7b66 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,7 +13,6 @@ variables: TreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BuildConfiguration: Release - BuildPlatform: Any CPU codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed. Learn more at https://github.com/AArnott/Library.Template/issues/28 NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages diff --git a/azure-pipelines/Set-EnvVars.ps1 b/azure-pipelines/Set-EnvVars.ps1 index 313cecff1..907659a7b 100644 --- a/azure-pipelines/Set-EnvVars.ps1 +++ b/azure-pipelines/Set-EnvVars.ps1 @@ -10,30 +10,70 @@ [CmdletBinding(SupportsShouldProcess=$true)] Param( [Parameter(Mandatory=$true, Position=1)] - $Variables + $Variables, + [string[]]$PrependPath ) if ($Variables.Count -eq 0) { return $true } -$cmdInstructions = !$env:TF_BUILD -and $env:PS1UnderCmd -eq '1' +$cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and $env:PS1UnderCmd -eq '1' if ($cmdInstructions) { Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe" Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue +} else { + Write-Host "Environment variables set:" -ForegroundColor Blue + $envVars + if ($PrependPath) { + Write-Host "Paths prepended to PATH: $PrependPath" + } +} + +if ($env:TF_BUILD) { + Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path." +} + +if ($env:GITHUB_ACTIONS) { + Write-Host "GitHub Actions detected. Logging commands will be used to propagate environment variables and prepend path." } $Variables.GetEnumerator() |% { Set-Item -Path env:$($_.Key) -Value $_.Value - # If we're running in Azure Pipelines, set these environment variables + # If we're running in a cloud CI, set these environment variables so they propagate. if ($env:TF_BUILD) { Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" } + if ($env:GITHUB_ACTIONS) { + Write-Host "::set-env name=$($_.Key)::$($_.Value)" + } if ($cmdInstructions) { Write-Host "SET $($_.Key)=$($_.Value)" } } +$pathDelimiter = ';' +if ($IsMacOS -or $IsLinux) { + $pathDelimiter = ':' +} + +if ($PrependPath) { + $PrependPath |% { + $newPathValue = "$_$pathDelimiter$env:PATH" + Set-Item -Path env:PATH -Value $newPathValue + if ($cmdInstructions) { + Write-Host "SET PATH=$newPathValue" + } + + if ($env:TF_BUILD) { + Write-Host "##vso[task.prependpath]$_" + } + if ($env:GITHUB_ACTIONS) { + Write-Host "::add-path::$_" + } + } +} + return !$cmdInstructions diff --git a/azure-pipelines/artifacts/Variables.ps1 b/azure-pipelines/artifacts/Variables.ps1 index cfcb7df52..2ee09d42f 100644 --- a/azure-pipelines/artifacts/Variables.ps1 +++ b/azure-pipelines/artifacts/Variables.ps1 @@ -2,13 +2,13 @@ # It "snaps" the values of these variables where we can compute them during the build, # and otherwise captures the scripts to run later during an Azure Pipelines environment release. -$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") -$ArtifactBasePath = "$RepoRoot\obj\_artifacts" -$VariablesArtifactPath = "$ArtifactBasePath\variables" +$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..))) +$ArtifactBasePath = Join-Path $RepoRoot (Join-Path obj _artifacts) +$VariablesArtifactPath = Join-Path $ArtifactBasePath variables if (-not (Test-Path $VariablesArtifactPath)) { New-Item -ItemType Directory -Path $VariablesArtifactPath | Out-Null } # Copy variables, either by value if the value is calculable now, or by script -Get-ChildItem -Path "$PSScriptRoot\..\variables" |% { +Get-ChildItem -Path (Join-Path $PSScriptRoot (Join-Path .. variables)) |% { $value = $null if (-not $_.BaseName.StartsWith('_')) { # Skip trying to interpret special scripts # First check the environment variables in case the variable was set in a queued build @@ -32,7 +32,7 @@ Get-ChildItem -Path "$PSScriptRoot\..\variables" |% { $value = Get-Content -Path $_.FullName } - Set-Content -Path "$VariablesArtifactPath\$($_.Name)" -Value $value + Set-Content -Path (Join-Path $VariablesArtifactPath $_.Name) -Value $value } @{ diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 index 7451ab111..5bca7c6c1 100644 --- a/azure-pipelines/artifacts/_pipelines.ps1 +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -5,51 +5,6 @@ param ( [string]$ArtifactNameSuffix ) -$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") -if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { - $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY -} else { - $ArtifactStagingFolder = "$RepoRoot\obj\_artifacts" - if (Test-Path $ArtifactStagingFolder) { - Remove-Item $ArtifactStagingFolder -Recurse -Force - } -} - -function Create-SymbolicLink { - param ( - $Link, - $Target - ) - - if ($Link -eq $Target) { - return - } - - if (Test-Path $Link) { Remove-Item $Link } - $LinkContainer = Split-Path $Link -Parent - if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer } - Write-Verbose "Linking $Link to $Target" - if ($IsMacOS -or $IsLinux) { - ln $Target $Link - } else { - cmd /c mklink $Link $Target - } -} - -# Stage all artifacts -$Artifacts = & "$PSScriptRoot\_all.ps1" -$Artifacts |% { - $DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\') - $Name = "$(Split-Path $_.Source -Leaf)" - - #Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow - - if (-not (Test-Path $DestinationFolder)) { New-Item -ItemType Directory -Path $DestinationFolder | Out-Null } - if (Test-Path -PathType Leaf $_.Source) { # skip folders - Create-SymbolicLink -Link "$DestinationFolder\$Name" -Target $_.Source - } -} - -$Artifacts |% { $_.ArtifactName } | Get-Unique |% { - Write-Host "##vso[artifact.upload containerfolder=$_$ArtifactNameSuffix;artifactname=$_$ArtifactNameSuffix;]$ArtifactStagingFolder/$_$ArtifactNameSuffix" +& "$PSScriptRoot/_stage_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix |% { + Write-Host "##vso[artifact.upload containerfolder=$($_.Name);artifactname=$($_.Name);]$($_.Path)" } diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 new file mode 100644 index 000000000..a05db5292 --- /dev/null +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -0,0 +1,59 @@ +# This script links all the artifacts described by _all.ps1 +# into a staging directory, reading for uploading to a cloud build artifact store. +# It returns a sequence of objects with Name and Path properties. + +param ( + [string]$ArtifactNameSuffix +) + +$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..))) +if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { + $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY +} else { + $ArtifactStagingFolder = Join-Path $RepoRoot (Join-Path obj _artifacts) + if (Test-Path $ArtifactStagingFolder) { + Remove-Item $ArtifactStagingFolder -Recurse -Force + } +} + +function Create-SymbolicLink { + param ( + $Link, + $Target + ) + + if ($Link -eq $Target) { + return + } + + if (Test-Path $Link) { Remove-Item $Link } + $LinkContainer = Split-Path $Link -Parent + if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer } + Write-Verbose "Linking $Link to $Target" + if ($IsMacOS -or $IsLinux) { + ln $Target $Link | Out-Null + } else { + cmd /c mklink $Link $Target | Out-Null + } +} + +# Stage all artifacts +$Artifacts = & "$PSScriptRoot\_all.ps1" +$Artifacts |% { + $DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\') + $Name = "$(Split-Path $_.Source -Leaf)" + + #Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow + + if (-not (Test-Path $DestinationFolder)) { New-Item -ItemType Directory -Path $DestinationFolder | Out-Null } + if (Test-Path -PathType Leaf $_.Source) { # skip folders + Create-SymbolicLink -Link (Join-Path $DestinationFolder $Name) -Target $_.Source + } +} + +$Artifacts |% { "$($_.ArtifactName)$ArtifactNameSuffix" } | Get-Unique |% { + $artifact = New-Object -TypeName PSObject + Add-Member -InputObject $artifact -MemberType NoteProperty -Name Name -Value $_ + Add-Member -InputObject $artifact -MemberType NoteProperty -Name Path -Value (Join-Path $ArtifactStagingFolder $_) + Write-Output $artifact +} diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 05e32a18e..e1a73d4dc 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -17,7 +17,7 @@ jobs: - job: Linux pool: - vmImage: Ubuntu 16.04 + vmImage: Ubuntu 18.04 steps: - checkout: self clean: true @@ -41,7 +41,7 @@ jobs: - Linux - macOS pool: - vmImage: Ubuntu 16.04 + vmImage: Ubuntu 18.04 condition: succeededOrFailed() steps: - checkout: self diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 9fa0c16b7..28230b817 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -5,11 +5,15 @@ # what the build would do. So only set them if they have not already been set. (& "$PSScriptRoot\_all.ps1").GetEnumerator() |% { - if (Test-Path -Path "env:$($_.Key.ToUpper())") { + if (Test-Path -Path "env:$($_.Key)") { Write-Host "Skipping setting $($_.Key) because variable is already set." -ForegroundColor Cyan } else { Write-Host "$($_.Key)=$($_.Value)" -ForegroundColor Yellow - Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" + if ($env:TF_BUILD) { + Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" + } elseif ($env:GITHUB_ACTIONS) { + Write-Host "::set-env name=$($_.Key)::$($_.Value)" + } Set-Item -Path "env:$($_.Key)" -Value $_.Value } } diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 50687706e..f29cb0a62 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -156,41 +156,5 @@ $runtimeVersions | Get-Unique |% { } if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) { - if ($env:TF_BUILD) { - Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path." - } - - if ($IsMacOS -or $IsLinux) { - $envVars['PATH'] = "${DotNetInstallDir}:$env:PATH" - } else { - $envVars['PATH'] = "$DotNetInstallDir;$env:PATH" - } - - $envVars.GetEnumerator() |% { - Set-Item -Path env:$($_.Key) -Value $_.Value - - # If we're running in Azure Pipelines, set these environment variables - if ($env:TF_BUILD) { - Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" - } - } - - if ($env:TF_BUILD) { - Write-Host "##vso[task.prependpath]$DotNetInstallDir" - } -} - -if ($env:PS1UnderCmd -eq '1') { - Write-Warning "Environment variable changes will be lost because you're running under cmd.exe. Run these commands manually:" - $envVars.GetEnumerator() |% { - if ($_.Key -eq 'PATH') { - # Special case this one for readability - Write-Host "SET PATH=$DotNetInstallDir;%PATH%" - } else { - Write-Host "SET $($_.Key)=$($_.Value)" - } - } -} else { - Write-Host "Environment variables set:" -ForegroundColor Blue - $envVars + & "$PSScriptRoot/../azure-pipelines/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null } From ad12e4a7f4af5563a6132015340e888cd068a714 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Jan 2020 20:22:47 -0700 Subject: [PATCH 073/641] Simpler way to avoid shallow clone --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e9918733..4e178096c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,8 +29,8 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Deep clone - run: git fetch --prune --unshallow origin HEAD + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - name: Install prerequisites run: | ./init.ps1 -UpgradePrerequisites From 2e0c3eb6f0273c6f2350eb5d4a01016dccced6a8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 16 Jan 2020 13:49:59 -0700 Subject: [PATCH 074/641] Pin the compiler version Although we already pin the SDK which includes compilers, when we use msbuild.exe (including VS) to build we still get whatever compilers are on the box. Pinning the compilers has many of the same merits as pinning the SDK. --- src/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ddd8ae606..03a6a1c34 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -27,6 +27,7 @@ + From 45818306689ea5709b30f398e86908cf02eb1ab9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 17 Jan 2020 07:29:10 -0700 Subject: [PATCH 075/641] Set NUGET_PACKAGES in CI workflow --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e178096c..2d71d97a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ env: BUILDCONFIGURATION: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed. Learn more at https://github.com/AArnott/Library.Template/issues/28 -# NUGET_PACKAGES: ${{ env.GITHUB_WORKSPACE }}/.nuget/packages + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages jobs: build: From aa77109d0aaada2d6e53b3035a9a57e4249ea35e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 13 Feb 2020 13:45:54 -0700 Subject: [PATCH 076/641] Update coverlet.msbuild to 2.8.0 --- azure-pipelines/artifacts/coverageResults.ps1 | 4 ++-- azure-pipelines/publish-codecoverage.yml | 2 +- src/Library.Tests/Library.Tests.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines/artifacts/coverageResults.ps1 b/azure-pipelines/artifacts/coverageResults.ps1 index 7d1e9a35f..addbf85c2 100644 --- a/azure-pipelines/artifacts/coverageResults.ps1 +++ b/azure-pipelines/artifacts/coverageResults.ps1 @@ -3,7 +3,7 @@ $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") # Prepare code coverage reports for merging on another machine if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`"" - $reports = Get-ChildItem "$RepoRoot/bin/coverage.cobertura.xml" -Recurse + $reports = Get-ChildItem "$RepoRoot/bin/coverage.*.cobertura.xml" -Recurse $reports |% { $content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" } Set-Content -Path $_ -Value $content -Encoding UTF8 @@ -16,7 +16,7 @@ if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return } @{ $RepoRoot = ( - @(Get-ChildItem "$RepoRoot\bin\coverage.cobertura.xml" -Recurse) + + @(Get-ChildItem "$RepoRoot\bin\coverage.*.cobertura.xml" -Recurse) + (Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse) ); } diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 6d367de96..976f0781b 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -15,7 +15,7 @@ steps: dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" - $reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.cobertura.xml" + $reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.*.cobertura.xml" $reports |% { $content = Get-Content -Path $_ |% { $_.Replace("{reporoot}", "$(System.DefaultWorkingDirectory)") } Set-Content -Path $_ -Value $content -Encoding UTF8 diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj index 78ebcfd4d..1cf1c1b00 100644 --- a/src/Library.Tests/Library.Tests.csproj +++ b/src/Library.Tests/Library.Tests.csproj @@ -14,7 +14,7 @@ - + From ca0811eb720026e8510a4f83813eb15019ac476c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 13 Feb 2020 13:48:09 -0700 Subject: [PATCH 077/641] Update SDK package references --- src/Directory.Build.props | 2 +- src/Library.Tests/Library.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 03a6a1c34..9b2087273 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -26,7 +26,7 @@ - + diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj index 1cf1c1b00..8018f97da 100644 --- a/src/Library.Tests/Library.Tests.csproj +++ b/src/Library.Tests/Library.Tests.csproj @@ -15,7 +15,7 @@ - + From fc25f7a1665fccf4c1cc4d574f18e22894955387 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Jan 2020 13:05:05 -0700 Subject: [PATCH 078/641] Remove unused ci_feed from GitHub workflow --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d71d97a8..86c351641 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,6 @@ env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BUILDCONFIGURATION: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ - ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed. Learn more at https://github.com/AArnott/Library.Template/issues/28 NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages jobs: From 5fbad730e20884725a8930a733f2490ac919c07f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 3 Feb 2020 15:53:59 -0700 Subject: [PATCH 079/641] Always collect artifacts, even on build failures --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86c351641..f3e10f53a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,7 @@ jobs: - name: Collect artifacts run: azure-pipelines/artifacts/_stage_all.ps1 shell: pwsh + if: always() - name: Upload project.assets.json files if: always() uses: actions/upload-artifact@v1 From ba764031a80c365dbf0182c67fda295fd89aaa5b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 25 Feb 2020 13:33:55 -0700 Subject: [PATCH 080/641] Use macOS-10.15 macOS 10.13 is about to be decommissioned on Azure Pipelines --- azure-pipelines/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index e1a73d4dc..186438a1b 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -27,7 +27,7 @@ jobs: - job: macOS pool: - vmImage: macOS 10.13 + vmImage: macOS-10.15 steps: - checkout: self clean: true From d54e43ed8c74c7bc243eee86717fd1fdff9f9bfb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 27 Feb 2020 23:18:59 -0700 Subject: [PATCH 081/641] More assuredly pin the .NET Core SDK version There's talk that the .NET SDK may change the default value for rollForward from "patch" to "latestMajor", effectively turning our "version" property to a minimum instead of a 'pin'. Setting rollForward explicitly guards against this. --- global.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/global.json b/global.json index e9aac8c22..5c8032d35 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,7 @@ { "sdk": { - "version": "3.1.100" + "version": "3.1.100", + "rollForward": "latestPatch", + "allowPrerelease": false } } From e0365203f8562571e344bfeb54418ca65af08fb5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 29 Feb 2020 07:06:03 -0700 Subject: [PATCH 082/641] Generate msbuild properties for every restored package --- src/Directory.Build.props | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9b2087273..5e0395b59 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,4 +1,5 @@ - + Debug $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\')) @@ -34,4 +35,9 @@ + + + + + From c608bf061aaa56fd21b6c2af0b950f61e5132d05 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 3 Mar 2020 09:33:08 -0700 Subject: [PATCH 083/641] Only install .NET Core runtimes once per version --- tools/Install-DotNetSdk.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index f29cb0a62..0bd4082ff 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -91,7 +91,7 @@ if ($InstallLocality -eq 'machine') { Install-DotNet -Version $sdkVersion } - $runtimeVersions |% { + $runtimeVersions | Get-Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { Install-DotNet -Version $_ -Runtime } From abf3830bc939537776c45be9d437cb4b89471baf Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 3 Mar 2020 09:50:03 -0700 Subject: [PATCH 084/641] Add Directory.Build.rsp file --- .gitignore | 1 + Directory.Build.rsp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Directory.Build.rsp diff --git a/.gitignore b/.gitignore index e353101db..d060a300b 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ StyleCopReport.xml *.pgc *.pgd *.rsp +!Directory.Build.rsp *.sbr *.tlb *.tli diff --git a/Directory.Build.rsp b/Directory.Build.rsp new file mode 100644 index 000000000..9a833a034 --- /dev/null +++ b/Directory.Build.rsp @@ -0,0 +1,16 @@ +#------------------------------------------------------------------------------ +# This file contains command-line options that MSBuild will process as part of +# every build, unless the "/noautoresponse" switch is specified. +# +# MSBuild processes the options in this file first, before processing the +# options on the command line. As a result, options on the command line can +# override the options in this file. However, depending on the options being +# set, the overriding can also result in conflicts. +# +# NOTE: The "/noautoresponse" switch cannot be specified in this file, nor in +# any response file that is referenced by this file. +#------------------------------------------------------------------------------ +/nr:false +/m +/verbosity:minimal +/clp:Summary;ForceNoAlign From 3d164a2c0cfdd219930cd84db2db38051483da6d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 6 Mar 2020 13:07:24 -0700 Subject: [PATCH 085/641] Fix _pipelines.ps1 to check env vars in all caps --- azure-pipelines/variables/_pipelines.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 28230b817..14d6ffc28 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -5,15 +5,17 @@ # what the build would do. So only set them if they have not already been set. (& "$PSScriptRoot\_all.ps1").GetEnumerator() |% { - if (Test-Path -Path "env:$($_.Key)") { - Write-Host "Skipping setting $($_.Key) because variable is already set." -ForegroundColor Cyan + # Always use ALL CAPS for env var names since Azure Pipelines converts variable names to all caps and on non-Windows OS, env vars are case sensitive. + $keyCaps = $_.Key.ToUpper() + if (Test-Path -Path "env:$keyCaps") { + Write-Host "Skipping setting $keyCaps because variable is already set." -ForegroundColor Cyan } else { - Write-Host "$($_.Key)=$($_.Value)" -ForegroundColor Yellow + Write-Host "$keyCaps=$($_.Value)" -ForegroundColor Yellow if ($env:TF_BUILD) { - Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" + Write-Host "##vso[task.setvariable variable=$keyCaps;]$($_.Value)" } elseif ($env:GITHUB_ACTIONS) { - Write-Host "::set-env name=$($_.Key)::$($_.Value)" + Write-Host "::set-env name=$keyCaps::$($_.Value)" } - Set-Item -Path "env:$($_.Key)" -Value $_.Value + Set-Item -Path "env:$keyCaps" -Value $_.Value } } From 43d492bdd13912fca8e600824e702b527ee7c2d1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 6 Mar 2020 13:12:28 -0700 Subject: [PATCH 086/641] Fix artifacts/variables.ps1 to check env vars in all caps --- azure-pipelines/artifacts/Variables.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/artifacts/Variables.ps1 b/azure-pipelines/artifacts/Variables.ps1 index 2ee09d42f..c6330cd38 100644 --- a/azure-pipelines/artifacts/Variables.ps1 +++ b/azure-pipelines/artifacts/Variables.ps1 @@ -12,8 +12,11 @@ Get-ChildItem -Path (Join-Path $PSScriptRoot (Join-Path .. variables)) |% { $value = $null if (-not $_.BaseName.StartsWith('_')) { # Skip trying to interpret special scripts # First check the environment variables in case the variable was set in a queued build - if (Test-Path env:$($_.BaseName)) { - $value = Get-Content "env:$($_.BaseName)" + # Always use all caps for env var access because Azure Pipelines converts variables to upper-case for env vars, + # and on non-Windows env vars are case sensitive. + $envVarName = $_.BaseName.ToUpper() + if (Test-Path env:$envVarName) { + $value = Get-Content "env:$envVarName" } # If that didn't give us anything, try executing the script right now from its original position From 53448b3d6825a478d98c90af5b8fbf444ee8870a Mon Sep 17 00:00:00 2001 From: Tina Chen <43013310+xuachen@users.noreply.github.com> Date: Wed, 25 Mar 2020 15:36:12 -0700 Subject: [PATCH 087/641] Use agent jobname for for symbols folder --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 9d910d2dc..9b5a2e883 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -49,7 +49,7 @@ steps: - task: PublishSymbols@2 inputs: - SymbolsFolder: $(Build.ArtifactStagingDirectory)/symbols-Windows + SymbolsFolder: $(Build.ArtifactStagingDirectory)/symbols-$(Agent.JobName) SearchPattern: '**/*.pdb' IndexSources: false SymbolServerType: TeamServices From bdd6849d9956088b9163d771a926e1dc0a5f0b08 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 27 Mar 2020 10:05:42 -0600 Subject: [PATCH 088/641] Update to global.json 3.1.201 --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 5c8032d35..0275fa5c9 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "3.1.100", - "rollForward": "latestPatch", + "version": "3.1.201", + "rollForward": "patch", "allowPrerelease": false } } From 8c4c16154cf2df279e716f6921fe9cb6cd7edffb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 27 Mar 2020 10:11:57 -0600 Subject: [PATCH 089/641] Consider test .runsettings files to be xml --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 03c2bcf34..3a833bdbb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,7 +16,7 @@ insert_final_newline = true trim_trailing_whitespace = true # Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,runsettings}] indent_size = 2 # Xml config files From 917c0492532ac0669bad1696df2b151926562d9a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 27 Mar 2020 10:12:41 -0600 Subject: [PATCH 090/641] Accommodate PathInfo as keys from artifact scripts --- azure-pipelines/artifacts/_all.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index 6f62be5c3..171b55b8f 100644 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -28,7 +28,7 @@ Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% { Write-Warning "No files found for the `"$ArtifactName`" artifact." } else { $fileGroups.GetEnumerator() | % { - $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute) + $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key.ToString()), [UriKind]::Absolute) $_.Value | % { if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) { $_ = $_.FullName From 70a1f50d261b02bde5f121957c317a7cf8dbef3e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 27 Mar 2020 10:29:44 -0600 Subject: [PATCH 091/641] Collect dumps and sequence.xml files on test hangs and crashes This makes diagnosing test runner crashes and hangs on Azure Pipelines possible. After such a failure, a testResults artifact is collected that includes the `Sequence_*.xml` and `testhost.*.dmp` files collected at the timeout or crash. These files can then be downloaded from the Azure Pipeline artifacts for study. --- azure-pipelines/Darwin.runsettings | 1 + azure-pipelines/Linux.runsettings | 1 + azure-pipelines/Windows_NT.runsettings | 14 ++++++++++++++ azure-pipelines/artifacts/testResults.ps1 | 12 ++++++++++++ azure-pipelines/dotnet.yml | 6 +++--- azure-pipelines/install-dependencies.yml | 7 +++++++ 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 azure-pipelines/Darwin.runsettings create mode 100644 azure-pipelines/Linux.runsettings create mode 100644 azure-pipelines/Windows_NT.runsettings create mode 100644 azure-pipelines/artifacts/testResults.ps1 diff --git a/azure-pipelines/Darwin.runsettings b/azure-pipelines/Darwin.runsettings new file mode 100644 index 000000000..b444e8196 --- /dev/null +++ b/azure-pipelines/Darwin.runsettings @@ -0,0 +1 @@ + diff --git a/azure-pipelines/Linux.runsettings b/azure-pipelines/Linux.runsettings new file mode 100644 index 000000000..b444e8196 --- /dev/null +++ b/azure-pipelines/Linux.runsettings @@ -0,0 +1 @@ + diff --git a/azure-pipelines/Windows_NT.runsettings b/azure-pipelines/Windows_NT.runsettings new file mode 100644 index 000000000..0b43ecb09 --- /dev/null +++ b/azure-pipelines/Windows_NT.runsettings @@ -0,0 +1,14 @@ + + + + + + + + + %BUILD_ARTIFACTSTAGINGDIRECTORY% + + + + + diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 new file mode 100644 index 000000000..1c9d3572d --- /dev/null +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -0,0 +1,12 @@ +if ($env:AGENT_TEMPDIRECTORY) { + # The DotNetCoreCLI uses an alternate location to publish these files + $guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$' + @{ + $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost.*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); + } +} else { + $srcRoot = Resolve-Path "$PSScriptRoot\..\..\src" + @{ + $srcRoot = (Get-ChildItem "$srcRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File); + } +} diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 9b5a2e883..0d837acbb 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -12,7 +12,7 @@ steps: displayName: dotnet test -f net472 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: net472-$(Agent.JobName) workingDirectory: src condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) @@ -21,7 +21,7 @@ steps: displayName: dotnet test -f netcoreapp2.1 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: netcoreapp2.1-$(Agent.JobName) workingDirectory: src @@ -29,7 +29,7 @@ steps: displayName: dotnet test -f netcoreapp3.1 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: netcoreapp3.1-$(Agent.JobName) workingDirectory: src diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 9257db852..a778022a0 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -8,6 +8,13 @@ steps: dotnet --info displayName: Install prerequisites +# The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests. +- powershell: | + choco install procdump + Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH;]$env:ProgramData\chocolatey\bin\" + displayName: Install procdump + condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) + - task: PowerShell@2 inputs: filePath: azure-pipelines/variables/_pipelines.ps1 From 941448de1f90a8abebfd487fbcfb9230f5bcdbb7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 27 Mar 2020 14:51:27 -0600 Subject: [PATCH 092/641] Collect crash/hang dumps on GitHub Actions --- .github/workflows/Linux.runsettings | 1 + .github/workflows/Windows.runsettings | 14 ++++++++++++++ .github/workflows/build.yml | 13 ++++++++++++- .github/workflows/macOS.runsettings | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/Linux.runsettings create mode 100644 .github/workflows/Windows.runsettings create mode 100644 .github/workflows/macOS.runsettings diff --git a/.github/workflows/Linux.runsettings b/.github/workflows/Linux.runsettings new file mode 100644 index 000000000..b444e8196 --- /dev/null +++ b/.github/workflows/Linux.runsettings @@ -0,0 +1 @@ + diff --git a/.github/workflows/Windows.runsettings b/.github/workflows/Windows.runsettings new file mode 100644 index 000000000..5e2244a02 --- /dev/null +++ b/.github/workflows/Windows.runsettings @@ -0,0 +1,14 @@ + + + + + + + + + %GITHUB_WORKSPACE% + + + + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3e10f53a..b167b51ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,10 @@ jobs: run: | ./init.ps1 -UpgradePrerequisites dotnet --info + if ($env:RUNNER_OS -eq "Windows") { + choco install procdump + Write-Host "##[set-env name=PROCDUMP_PATH;]$env:PROGRAMDATA\chocolatey\bin\" + } shell: pwsh - name: Set pipeline variables based on source run: azure-pipelines/variables/_pipelines.ps1 @@ -43,7 +47,7 @@ jobs: - name: pack run: dotnet pack src --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog" - name: test - run: dotnet test src --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true + run: dotnet test src --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --settings "${{ github.workspace }}/.github/workflows/${{ runner.os }}.runsettings" - name: Update pipeline variables based on build outputs run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh @@ -72,6 +76,13 @@ jobs: name: build_logs-${{ runner.os }} path: obj/_artifacts/build_logs continue-on-error: true + - name: Upload testResults + if: always() + uses: actions/upload-artifact@v1 + with: + name: testResults-${{ runner.os }} + path: obj/_artifacts/testResults + continue-on-error: true - name: Upload coverageResults if: always() uses: actions/upload-artifact@v1 diff --git a/.github/workflows/macOS.runsettings b/.github/workflows/macOS.runsettings new file mode 100644 index 000000000..b444e8196 --- /dev/null +++ b/.github/workflows/macOS.runsettings @@ -0,0 +1 @@ + From 8a3f6cd5d471bc588b5eb1cf54446a297e4cd3f5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 27 Mar 2020 14:58:41 -0600 Subject: [PATCH 093/641] Collect deployables on GitHub Actions even for failing jobs --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3e10f53a..b50c56050 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: - ubuntu-18.04 @@ -91,7 +92,7 @@ jobs: with: name: deployables path: obj/_artifacts/deployables - if: runner.os == 'Windows' + if: always() && runner.os == 'Windows' - name: Publish code coverage results to codecov.io run: bash <(curl -s https://codecov.io/bash) shell: bash From c5581d16fedaaaf95549f1f8105a8f6a7171534d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 27 Mar 2020 15:39:20 -0600 Subject: [PATCH 094/641] Fix dmp collection on Azure Pipelines --- azure-pipelines/artifacts/testResults.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index 1c9d3572d..bc9e0467e 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -2,7 +2,7 @@ if ($env:AGENT_TEMPDIRECTORY) { # The DotNetCoreCLI uses an alternate location to publish these files $guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$' @{ - $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost.*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); + $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); } } else { $srcRoot = Resolve-Path "$PSScriptRoot\..\..\src" From ce7cd13abbdfd6b7cd0fe95c196bc82e36e7bddb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 28 Mar 2020 13:03:09 -0600 Subject: [PATCH 095/641] Recommend C# extension in VS Code by its new name --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c5b615df4..ecda668ec 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,7 +4,7 @@ // List of extensions which should be recommended for users of this workspace. "recommendations": [ "ms-azure-devops.azure-pipelines", - "ms-vscode.csharp", + "ms-dotnettools.csharp", "k--kato.docomment", "editorconfig.editorconfig", "pflannery.vscode-versionlens", From 426a7bd79f81f9c5dabf5e7f48fc24251e0e5577 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 28 Mar 2020 16:15:06 -0600 Subject: [PATCH 096/641] Update package references --- src/Directory.Build.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 5e0395b59..bdfdc2b2c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -27,9 +27,9 @@ - - - + + + From f0b174a54640be9482a14dea28cd19c9b1cd481b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 29 Mar 2020 07:35:13 -0600 Subject: [PATCH 097/641] Update NB.GV This gets Omnisharp on Linux to work. --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index bdfdc2b2c..ce9c31949 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -27,7 +27,7 @@ - + From ae335995e9c2dd914b642a64084e4be0090901e6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 29 Mar 2020 19:35:18 -0600 Subject: [PATCH 098/641] Make ps1 scripts directly executable from linux --- azure-pipelines/artifacts/_all.ps1 | 2 ++ azure-pipelines/variables/_all.ps1 | 2 ++ init.ps1 | 2 ++ tools/Install-DotNetSdk.ps1 | 2 ++ tools/Install-NuGetCredProvider.ps1 | 2 ++ 5 files changed, 10 insertions(+) mode change 100644 => 100755 azure-pipelines/artifacts/_all.ps1 mode change 100644 => 100755 azure-pipelines/variables/_all.ps1 mode change 100644 => 100755 init.ps1 mode change 100644 => 100755 tools/Install-DotNetSdk.ps1 mode change 100644 => 100755 tools/Install-NuGetCredProvider.ps1 diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 old mode 100644 new mode 100755 index 171b55b8f..4b5442369 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/pwsh + # This script returns all the artifacts that should be collected after a build. # # Each powershell artifact is expressed as an object with these properties: diff --git a/azure-pipelines/variables/_all.ps1 b/azure-pipelines/variables/_all.ps1 old mode 100644 new mode 100755 index ed0997922..269425b56 --- a/azure-pipelines/variables/_all.ps1 +++ b/azure-pipelines/variables/_all.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/pwsh + # This script returns a hashtable of build variables that should be set # at the start of a build or release definition's execution. diff --git a/init.ps1 b/init.ps1 old mode 100644 new mode 100755 index ae4ce9a69..ac980028a --- a/init.ps1 +++ b/init.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/pwsh + <# .SYNOPSIS Installs dependencies required to build and test the projects in this repository. diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 old mode 100644 new mode 100755 index 0bd4082ff..a830dd408 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/pwsh + <# .SYNOPSIS Installs the .NET SDK specified in the global.json file at the root of this repository, diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 old mode 100644 new mode 100755 index 0a8d77f62..9e0e2fce2 --- a/tools/Install-NuGetCredProvider.ps1 +++ b/tools/Install-NuGetCredProvider.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/pwsh + <# .SYNOPSIS Downloads and installs the Microsoft Artifacts Credential Provider From c2c2ec18581074f1ab53333bc97e0b2d9e9e9d51 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 29 Mar 2020 20:26:44 -0600 Subject: [PATCH 099/641] Use more portable #! for ps1 --- azure-pipelines/artifacts/_all.ps1 | 2 +- azure-pipelines/variables/_all.ps1 | 2 +- init.ps1 | 2 +- tools/Install-DotNetSdk.ps1 | 2 +- tools/Install-NuGetCredProvider.ps1 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index 4b5442369..efd6bdb3e 100755 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -1,4 +1,4 @@ -#!/usr/bin/pwsh +#!/usr/bin/env pwsh # This script returns all the artifacts that should be collected after a build. # diff --git a/azure-pipelines/variables/_all.ps1 b/azure-pipelines/variables/_all.ps1 index 269425b56..0407d307e 100755 --- a/azure-pipelines/variables/_all.ps1 +++ b/azure-pipelines/variables/_all.ps1 @@ -1,4 +1,4 @@ -#!/usr/bin/pwsh +#!/usr/bin/env pwsh # This script returns a hashtable of build variables that should be set # at the start of a build or release definition's execution. diff --git a/init.ps1 b/init.ps1 index ac980028a..6701e7254 100755 --- a/init.ps1 +++ b/init.ps1 @@ -1,4 +1,4 @@ -#!/usr/bin/pwsh +#!/usr/bin/env pwsh <# .SYNOPSIS diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index a830dd408..2a444134f 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -1,4 +1,4 @@ -#!/usr/bin/pwsh +#!/usr/bin/env pwsh <# .SYNOPSIS diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 index 9e0e2fce2..496dcd96a 100755 --- a/tools/Install-NuGetCredProvider.ps1 +++ b/tools/Install-NuGetCredProvider.ps1 @@ -1,4 +1,4 @@ -#!/usr/bin/pwsh +#!/usr/bin/env pwsh <# .SYNOPSIS From cbb60159af1bd4bbe336ba677e277152bd8b050b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 30 Mar 2020 10:16:19 -0600 Subject: [PATCH 100/641] Add machine-wide .NET install support off Windows --- tools/Install-DotNetSdk.ps1 | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 2a444134f..101b68fe8 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -83,25 +83,6 @@ Function Install-DotNet($Version, [switch]$Runtime) { } } -if ($InstallLocality -eq 'machine') { - if ($IsMacOS -or $IsLinux) { - Write-Error "Installing the .NET Core SDK or runtime at a machine-wide location is only supported by this script on Windows." - exit 1 - } - - if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { - Install-DotNet -Version $sdkVersion - } - - $runtimeVersions | Get-Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - Install-DotNet -Version $_ -Runtime - } - } - - return -} - $switches = @( '-Architecture','x64' ) @@ -110,7 +91,23 @@ $envVars = @{ 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true'; } -if ($InstallLocality -eq 'repo') { +if ($InstallLocality -eq 'machine') { + if ($IsWindows) { + if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + Install-DotNet -Version $sdkVersion + } + + $runtimeVersions | Get-Unique |% { + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + Install-DotNet -Version $_ -Runtime + } + } + + return + } else { + $DotNetInstallDir = '/usr/share/dotnet' + } +} elseif ($InstallLocality -eq 'repo') { $DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet" } elseif ($env:AGENT_TOOLSDIRECTORY) { $DotNetInstallDir = "$env:AGENT_TOOLSDIRECTORY/dotnet" From ef30ea448e502db518bbe3d245dd6b185e084ad0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 7 Apr 2020 17:22:02 -0600 Subject: [PATCH 101/641] Use PowerShell Core in Azure Pipelines --- azure-pipelines/build.yml | 2 +- azure-pipelines/dotnet.yml | 12 ++++-------- azure-pipelines/expand-template.yml | 2 +- azure-pipelines/install-dependencies.yml | 10 ++++------ azure-pipelines/publish-codecoverage.yml | 2 +- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 186438a1b..218e1c3d3 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -9,7 +9,7 @@ jobs: clean: true - template: install-dependencies.yml - - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud' + - pwsh: '& (./azure-pipelines/Get-nbgv.ps1) cloud' displayName: Set build number - template: dotnet.yml diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 0d837acbb..0b6e3cc5b 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -33,17 +33,13 @@ steps: testRunTitle: netcoreapp3.1-$(Agent.JobName) workingDirectory: src -- task: PowerShell@2 - inputs: - filePath: azure-pipelines/variables/_pipelines.ps1 - failOnStderr: true +- pwsh: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true displayName: Update pipeline variables based on build outputs condition: succeededOrFailed() -- task: PowerShell@2 - inputs: - filePath: azure-pipelines/artifacts/_pipelines.ps1 - arguments: -ArtifactNameSuffix "-$(Agent.JobName)" +- pwsh: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)" + failOnStderr: true displayName: Publish artifacts condition: succeededOrFailed() diff --git a/azure-pipelines/expand-template.yml b/azure-pipelines/expand-template.yml index 2d9ea7b30..a66a11573 100644 --- a/azure-pipelines/expand-template.yml +++ b/azure-pipelines/expand-template.yml @@ -3,7 +3,7 @@ steps: dotnet build-server shutdown git clean -fdx displayName: Cleaning repo for template expansion -- powershell: | +- pwsh: | git config user.name "test user" git config user.email "andrewarnott@gmail.com" ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott" diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index a778022a0..af97093bd 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -3,20 +3,18 @@ parameters: steps: -- powershell: | +- pwsh: | .\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} -UpgradePrerequisites dotnet --info displayName: Install prerequisites # The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests. -- powershell: | +- pwsh: | choco install procdump Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH;]$env:ProgramData\chocolatey\bin\" displayName: Install procdump condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) -- task: PowerShell@2 - inputs: - filePath: azure-pipelines/variables/_pipelines.ps1 - failOnStderr: true +- pwsh: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true displayName: Set pipeline variables based on source diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 976f0781b..080a0f60b 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -11,7 +11,7 @@ steps: artifact: coverageResults-macOS displayName: Download macOS code coverage results continueOnError: true -- powershell: | +- pwsh: | dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" From cae9277ee0851c093aac955ca82e6cb94bfe7408 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 7 Apr 2020 18:56:36 -0600 Subject: [PATCH 102/641] Revert "Use PowerShell Core in Azure Pipelines" This reverts commit ef30ea448e502db518bbe3d245dd6b185e084ad0. --- azure-pipelines/build.yml | 2 +- azure-pipelines/dotnet.yml | 12 ++++++++---- azure-pipelines/expand-template.yml | 2 +- azure-pipelines/install-dependencies.yml | 10 ++++++---- azure-pipelines/publish-codecoverage.yml | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 218e1c3d3..186438a1b 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -9,7 +9,7 @@ jobs: clean: true - template: install-dependencies.yml - - pwsh: '& (./azure-pipelines/Get-nbgv.ps1) cloud' + - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud' displayName: Set build number - template: dotnet.yml diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 0b6e3cc5b..0d837acbb 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -33,13 +33,17 @@ steps: testRunTitle: netcoreapp3.1-$(Agent.JobName) workingDirectory: src -- pwsh: azure-pipelines/variables/_pipelines.ps1 - failOnStderr: true +- task: PowerShell@2 + inputs: + filePath: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true displayName: Update pipeline variables based on build outputs condition: succeededOrFailed() -- pwsh: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)" - failOnStderr: true +- task: PowerShell@2 + inputs: + filePath: azure-pipelines/artifacts/_pipelines.ps1 + arguments: -ArtifactNameSuffix "-$(Agent.JobName)" displayName: Publish artifacts condition: succeededOrFailed() diff --git a/azure-pipelines/expand-template.yml b/azure-pipelines/expand-template.yml index a66a11573..2d9ea7b30 100644 --- a/azure-pipelines/expand-template.yml +++ b/azure-pipelines/expand-template.yml @@ -3,7 +3,7 @@ steps: dotnet build-server shutdown git clean -fdx displayName: Cleaning repo for template expansion -- pwsh: | +- powershell: | git config user.name "test user" git config user.email "andrewarnott@gmail.com" ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott" diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index af97093bd..a778022a0 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -3,18 +3,20 @@ parameters: steps: -- pwsh: | +- powershell: | .\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} -UpgradePrerequisites dotnet --info displayName: Install prerequisites # The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests. -- pwsh: | +- powershell: | choco install procdump Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH;]$env:ProgramData\chocolatey\bin\" displayName: Install procdump condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) -- pwsh: azure-pipelines/variables/_pipelines.ps1 - failOnStderr: true +- task: PowerShell@2 + inputs: + filePath: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true displayName: Set pipeline variables based on source diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 080a0f60b..976f0781b 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -11,7 +11,7 @@ steps: artifact: coverageResults-macOS displayName: Download macOS code coverage results continueOnError: true -- pwsh: | +- powershell: | dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" From fbca91fdfbdbc4cced5d8a7eb2193710e3eb27e5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 7 Apr 2020 18:57:50 -0600 Subject: [PATCH 103/641] Simplify syntax of Powershell tasks --- azure-pipelines/dotnet.yml | 12 ++++-------- azure-pipelines/install-dependencies.yml | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 0d837acbb..71bd42e13 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -33,17 +33,13 @@ steps: testRunTitle: netcoreapp3.1-$(Agent.JobName) workingDirectory: src -- task: PowerShell@2 - inputs: - filePath: azure-pipelines/variables/_pipelines.ps1 - failOnStderr: true +- powershell: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true displayName: Update pipeline variables based on build outputs condition: succeededOrFailed() -- task: PowerShell@2 - inputs: - filePath: azure-pipelines/artifacts/_pipelines.ps1 - arguments: -ArtifactNameSuffix "-$(Agent.JobName)" +- powershell: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)" + failOnStderr: true displayName: Publish artifacts condition: succeededOrFailed() diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index a778022a0..ec9c3f56a 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -15,8 +15,6 @@ steps: displayName: Install procdump condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) -- task: PowerShell@2 - inputs: - filePath: azure-pipelines/variables/_pipelines.ps1 - failOnStderr: true +- powershell: azure-pipelines/variables/_pipelines.ps1 + failOnStderr: true displayName: Set pipeline variables based on source From 8441b31c2d4509873d92a28896d12955e2917f7f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Apr 2020 07:27:52 -0600 Subject: [PATCH 104/641] Specify nuget version to use This shields us against default version changes and service outages such as the one we just experienced. --- azure-pipelines/publish-deployables.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml index a89f389fd..a4f8e593f 100644 --- a/azure-pipelines/publish-deployables.yml +++ b/azure-pipelines/publish-deployables.yml @@ -3,6 +3,11 @@ steps: displayName: Download deployables artifact: deployables-Windows +- task: NuGetToolInstaller@1 + displayName: Use NuGet 5.x + inputs: + versionSpec: 5.x + - task: NuGetCommand@2 displayName: Push packages to CI feed inputs: From 606547170822ba211cb097dcdf5e8da44f4f90e6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Apr 2020 21:34:11 -0600 Subject: [PATCH 105/641] Move sln file to repo root --- .github/workflows/build.yml | 6 +++--- Expand-Template.ps1 | 29 +++++++++++++---------------- src/Library.sln => Library.sln | 22 +++++++++++----------- azure-pipelines/dotnet.yml | 5 ----- azure-pipelines/expand-template.yml | 1 - init.ps1 | 2 +- 6 files changed, 28 insertions(+), 37 deletions(-) rename src/Library.sln => Library.sln (75%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d8d7655f..55575add1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,11 +44,11 @@ jobs: run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh - name: build - run: dotnet build src --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog" + run: dotnet build --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog" - name: pack - run: dotnet pack src --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog" + run: dotnet pack --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog" - name: test - run: dotnet test src --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --settings "${{ github.workspace }}/.github/workflows/${{ runner.os }}.runsettings" + run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --settings "${{ github.workspace }}/.github/workflows/${{ runner.os }}.runsettings" - name: Update pipeline variables based on build outputs run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index aa4f5ec25..6a030fc13 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -80,30 +80,27 @@ try { } # Rename project directories and solution - Set-Location src git mv Library.sln "$LibraryName.sln" - git mv Library/Library.csproj "Library/$LibraryName.csproj" - git mv Library "$LibraryName" - git mv Library.Tests/Library.Tests.csproj "Library.Tests/$LibraryName.Tests.csproj" - git mv Library.Tests "$LibraryName.Tests" + git mv src/Library/Library.csproj "src/Library/$LibraryName.csproj" + git mv src/Library "src/$LibraryName" + git mv src/Library.Tests/Library.Tests.csproj "src/Library.Tests/$LibraryName.Tests.csproj" + git mv src/Library.Tests "src/$LibraryName.Tests" # Refresh solution file both to update paths and give the projects unique GUIDs - dotnet sln remove Library/Library.csproj - dotnet sln remove Library.Tests/Library.Tests.csproj - dotnet sln add "$LibraryName" - dotnet sln add "$LibraryName.Tests" + dotnet sln remove src/Library/Library.csproj + dotnet sln remove src/Library.Tests/Library.Tests.csproj + dotnet sln add "src/$LibraryName" + dotnet sln add "src/$LibraryName.Tests" git add "$LibraryName.sln" # Update project reference in test project. Add before removal to keep the same ItemGroup in place. - dotnet add "$LibraryName.Tests" reference "$LibraryName" - dotnet remove "$LibraryName.Tests" reference Library/Library.csproj - git add "$LibraryName.Tests/$LibraryName.Tests.csproj" + dotnet add "src/$LibraryName.Tests" reference "src/$LibraryName" + dotnet remove "src/$LibraryName.Tests" reference src/Library/Library.csproj + git add "src/$LibraryName.Tests/$LibraryName.Tests.csproj" # Establish a new strong-name key - & $sn.Path -k 2048 strongname.snk - git add strongname.snk - - Set-Location .. + & $sn.Path -k 2048 src/strongname.snk + git add src/strongname.snk # Replace placeholders in source files Replace-Placeholders -Path "src/$LibraryName/Calculator.cs" -Replacements @{ diff --git a/src/Library.sln b/Library.sln similarity index 75% rename from src/Library.sln rename to Library.sln index 09dfb1fe6..d034f5b2d 100644 --- a/src/Library.sln +++ b/Library.sln @@ -3,21 +3,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29322.22 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "src\Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "src\Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CE9670B-D5FF-46A7-9D00-24E70E6ED48B}" ProjectSection(SolutionItems) = preProject - ..\.editorconfig = ..\.editorconfig - Directory.Build.props = Directory.Build.props - Directory.Build.targets = Directory.Build.targets - ..\global.json = ..\global.json - ..\nuget.config = ..\nuget.config - shipping.ruleset = shipping.ruleset - stylecop.json = stylecop.json - tests.ruleset = tests.ruleset - ..\version.json = ..\version.json + .editorconfig = .editorconfig + src\Directory.Build.props = src\Directory.Build.props + src\Directory.Build.targets = src\Directory.Build.targets + global.json = global.json + nuget.config = nuget.config + src\shipping.ruleset = src\shipping.ruleset + src\stylecop.json = src\stylecop.json + src\tests.ruleset = src\tests.ruleset + version.json = version.json EndProjectSection EndProject Global diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 71bd42e13..6764e6ecc 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -2,11 +2,9 @@ steps: - script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: dotnet build - workingDirectory: src - script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog" displayName: dotnet pack - workingDirectory: src - task: DotNetCoreCLI@2 displayName: dotnet test -f net472 @@ -14,7 +12,6 @@ steps: command: test arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: net472-$(Agent.JobName) - workingDirectory: src condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - task: DotNetCoreCLI@2 @@ -23,7 +20,6 @@ steps: command: test arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: netcoreapp2.1-$(Agent.JobName) - workingDirectory: src - task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp3.1 @@ -31,7 +27,6 @@ steps: command: test arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: netcoreapp3.1-$(Agent.JobName) - workingDirectory: src - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true diff --git a/azure-pipelines/expand-template.yml b/azure-pipelines/expand-template.yml index 2d9ea7b30..ed510de3e 100644 --- a/azure-pipelines/expand-template.yml +++ b/azure-pipelines/expand-template.yml @@ -11,5 +11,4 @@ steps: failOnStderr: true # TODO: Verify that all changes are staged to the git index - script: dotnet build - workingDirectory: src displayName: dotnet build (expanded template) diff --git a/init.ps1 b/init.ps1 index 6701e7254..a0c9961f3 100755 --- a/init.ps1 +++ b/init.ps1 @@ -54,7 +54,7 @@ try { if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) { Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor - dotnet restore src + dotnet restore if ($lastexitcode -ne 0) { throw "Failure while restoring packages." } From 234e1da8eb8a1b077214b6e4d8dfc64edcab21b1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Apr 2020 23:06:03 -0600 Subject: [PATCH 106/641] Fix Install-DotNetSdk script under -WhatIf --- tools/Install-DotNetSdk.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 101b68fe8..8d77a9fe7 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -23,7 +23,7 @@ Param ( ) $DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools" -if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot | Out-Null } +if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot -WhatIf:$false | Out-Null } $DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot # Look up actual required .NET Core SDK version from global.json From e9107462f142ba4c25289ef1d609378e0c2bb270 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Apr 2020 23:23:30 -0600 Subject: [PATCH 107/641] Avoid building on Azure Pipelines for .github folder changes --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c6eeb7b66..fc1b06e36 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,6 +8,7 @@ trigger: - doc/ - '*.md' - .vscode/ + - .github/ variables: TreatWarningsAsErrors: true From 18676a3d915d6be387f2b76e19a492c623b9930c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Apr 2020 23:14:23 -0600 Subject: [PATCH 108/641] Lose guid in favor of feed name Closes #28 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fc1b06e36..22f8b5530 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,7 +15,7 @@ variables: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BuildConfiguration: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ - ci_feed: /a5a3bad0-e566-4c53-be83-6458be8d1653 # find guid used by Azure DevOps Artifacts for the feed. Learn more at https://github.com/AArnott/Library.Template/issues/28 + ci_feed: CI # Azure Artifacts feed name NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages jobs: From 9c3b3fe1534bf2b05aa1b7163699590d5027b06b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Apr 2020 23:30:24 -0600 Subject: [PATCH 109/641] Fix build of WPF projects Fixes #22 --- src/Directory.Build.targets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 1ddcba6f4..8f529fae9 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,4 +1,8 @@ + + + false + cobertura [xunit.*]* From 3c0c7dae0fe407097af6455adbfb4d6e8b8ba600 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Apr 2020 22:36:49 -0600 Subject: [PATCH 110/641] Use top-level test folder --- .editorconfig | 8 ++ Directory.Build.props | 43 ++++++++++ Directory.Build.targets | 8 ++ Expand-Template.ps1 | 22 +++--- Library.sln | 28 +++++-- azure-pipelines/artifacts/testResults.ps1 | 4 +- src/.editorconfig | 0 src/Directory.Build.props | 44 +---------- src/Directory.Build.targets | 8 +- src/Library.Tests/Library.Tests.csproj | 23 ------ src/Library/Library.csproj | 5 -- src/shipping.ruleset | 74 ------------------ src/tests.ruleset | 18 ----- src/strongname.snk => strongname.snk | Bin src/stylecop.json => stylecop.json | 0 test/.editorconfig | 28 +++++++ test/Directory.Build.props | 11 +++ test/Directory.Build.targets | 3 + .../Library.Tests/CalculatorTests.cs | 0 test/Library.Tests/Library.Tests.csproj | 14 ++++ {src => test}/Library.Tests/app.config | 0 tools/Install-DotNetSdk.ps1 | 2 +- 22 files changed, 157 insertions(+), 186 deletions(-) create mode 100644 Directory.Build.props create mode 100644 Directory.Build.targets create mode 100644 src/.editorconfig delete mode 100644 src/Library.Tests/Library.Tests.csproj delete mode 100644 src/shipping.ruleset delete mode 100644 src/tests.ruleset rename src/strongname.snk => strongname.snk (100%) rename src/stylecop.json => stylecop.json (100%) create mode 100644 test/.editorconfig create mode 100644 test/Directory.Build.props create mode 100644 test/Directory.Build.targets rename {src => test}/Library.Tests/CalculatorTests.cs (100%) create mode 100644 test/Library.Tests/Library.Tests.csproj rename {src => test}/Library.Tests/app.config (100%) diff --git a/.editorconfig b/.editorconfig index 3a833bdbb..979d170a0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -155,3 +155,11 @@ csharp_new_line_before_members_in_anonymous_types = true # Blocks are allowed csharp_prefer_braces = true:silent + +[*.cs] + +# SA1130: Use lambda syntax +dotnet_diagnostic.SA1130.severity = silent + +[*.sln] +indent_style = tab diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 000000000..7a97368fc --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,43 @@ + + + Debug + $(MSBuildThisFileDirectory) + $(RepoRootPath)obj\$(MSBuildProjectName)\ + $(RepoRootPath)bin\$(MSBuildProjectName)\ + $(RepoRootPath)bin\Packages\$(Configuration)\ + 8.0 + enable + true + + true + $(MSBuildThisFileDirectory)\strongname.snk + + COMPANY-PLACEHOLDER + COMPANY-PLACEHOLDER + © COMPANY-PLACEHOLDER. All rights reserved. + MIT + true + true + true + snupkg + + + + + + + + + + + + + + + + + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 000000000..1ddcba6f4 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,8 @@ + + + cobertura + [xunit.*]* + + $(OutputPath)/ + + diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 6a030fc13..9a05ececc 100644 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -83,20 +83,20 @@ try { git mv Library.sln "$LibraryName.sln" git mv src/Library/Library.csproj "src/Library/$LibraryName.csproj" git mv src/Library "src/$LibraryName" - git mv src/Library.Tests/Library.Tests.csproj "src/Library.Tests/$LibraryName.Tests.csproj" - git mv src/Library.Tests "src/$LibraryName.Tests" + git mv test/Library.Tests/Library.Tests.csproj "test/Library.Tests/$LibraryName.Tests.csproj" + git mv test/Library.Tests "test/$LibraryName.Tests" # Refresh solution file both to update paths and give the projects unique GUIDs dotnet sln remove src/Library/Library.csproj - dotnet sln remove src/Library.Tests/Library.Tests.csproj + dotnet sln remove test/Library.Tests/Library.Tests.csproj dotnet sln add "src/$LibraryName" - dotnet sln add "src/$LibraryName.Tests" + dotnet sln add "test/$LibraryName.Tests" git add "$LibraryName.sln" # Update project reference in test project. Add before removal to keep the same ItemGroup in place. - dotnet add "src/$LibraryName.Tests" reference "src/$LibraryName" - dotnet remove "src/$LibraryName.Tests" reference src/Library/Library.csproj - git add "src/$LibraryName.Tests/$LibraryName.Tests.csproj" + dotnet add "test/$LibraryName.Tests" reference "src/$LibraryName" + dotnet remove "test/$LibraryName.Tests" reference src/Library/Library.csproj + git add "test/$LibraryName.Tests/$LibraryName.Tests.csproj" # Establish a new strong-name key & $sn.Path -k 2048 src/strongname.snk @@ -107,17 +107,17 @@ try { 'Library'=$LibraryName 'COMPANY-PLACEHOLDER'=$Author } - Replace-Placeholders -Path "src/$LibraryName.Tests/CalculatorTests.cs" -Replacements @{ + Replace-Placeholders -Path "test/$LibraryName.Tests/CalculatorTests.cs" -Replacements @{ 'Library'=$LibraryName 'COMPANY-PLACEHOLDER'=$Author } Replace-Placeholders -Path "LICENSE" -Replacements @{ 'COMPANY-PLACEHOLDER'=$Author } - Replace-Placeholders -Path "src/stylecop.json" -Replacements @{ + Replace-Placeholders -Path "stylecop.json" -Replacements @{ 'COMPANY-PLACEHOLDER'=$Author } - Replace-Placeholders -Path "src/Directory.Build.props" -Replacements @{ + Replace-Placeholders -Path "Directory.Build.props" -Replacements @{ 'COMPANY-PLACEHOLDER'=$Author } Replace-Placeholders -Path "README.md" -Replacements @{ @@ -174,4 +174,4 @@ try { } # When testing this script, all the changes can be quickly reverted with this command: -# git reset HEAD :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git co -- :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git clean -fd :/src +# git reset HEAD :/README.md :/LICENSE :/azure-pipelines.yml :/src :/test :/azure-pipelines; git co -- :/README.md :/LICENSE :/azure-pipelines.yml :/src :/azure-pipelines; git clean -fd :/src :/test diff --git a/Library.sln b/Library.sln index d034f5b2d..85b8939d8 100644 --- a/Library.sln +++ b/Library.sln @@ -5,21 +5,33 @@ VisualStudioVersion = 16.0.29322.22 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "src\Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "src\Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "test\Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CE9670B-D5FF-46A7-9D00-24E70E6ED48B}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - src\Directory.Build.props = src\Directory.Build.props - src\Directory.Build.targets = src\Directory.Build.targets + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets global.json = global.json nuget.config = nuget.config - src\shipping.ruleset = src\shipping.ruleset - src\stylecop.json = src\stylecop.json - src\tests.ruleset = src\tests.ruleset + stylecop.json = stylecop.json version.json = version.json EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9E154A29-1796-4B85-BD81-B6A385D8FF71}" + ProjectSection(SolutionItems) = preProject + src\.editorconfig = src\.editorconfig + src\Directory.Build.props = src\Directory.Build.props + src\Directory.Build.targets = src\Directory.Build.targets + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}" + ProjectSection(SolutionItems) = preProject + test\.editorconfig = test\.editorconfig + test\Directory.Build.props = test\Directory.Build.props + test\Directory.Build.targets = test\Directory.Build.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,6 +50,10 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {9E154A29-1796-4B85-BD81-B6A385D8FF71} = {1CE9670B-D5FF-46A7-9D00-24E70E6ED48B} + {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A} = {1CE9670B-D5FF-46A7-9D00-24E70E6ED48B} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E3944F6A-384B-4B0F-B93F-3BD513DC57BD} EndGlobalSection diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index bc9e0467e..1e4c4c4e2 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -5,8 +5,8 @@ if ($env:AGENT_TEMPDIRECTORY) { $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); } } else { - $srcRoot = Resolve-Path "$PSScriptRoot\..\..\src" + $testRoot = Resolve-Path "$PSScriptRoot\..\..\test" @{ - $srcRoot = (Get-ChildItem "$srcRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File); + $testRoot = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File); } } diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 000000000..e69de29bb diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ce9c31949..50b6409ef 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,43 +1,7 @@ - - - Debug - $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\')) - $(RepoRootPath)obj\$(MSBuildProjectName)\ - $(RepoRootPath)bin\$(MSBuildProjectName)\ - $(RepoRootPath)bin\Packages\$(Configuration)\ - 8.0 - enable - true - - true - $(MSBuildThisFileDirectory)\strongname.snk + + - COMPANY-PLACEHOLDER - COMPANY-PLACEHOLDER - © COMPANY-PLACEHOLDER. All rights reserved. - MIT - true - true - true - snupkg + + netstandard2.0 - - - - - - - - - - - - - - - - - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 8f529fae9..ada766550 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -3,10 +3,6 @@ false - - cobertura - [xunit.*]* - - $(OutputPath)/ - + + diff --git a/src/Library.Tests/Library.Tests.csproj b/src/Library.Tests/Library.Tests.csproj deleted file mode 100644 index 8018f97da..000000000 --- a/src/Library.Tests/Library.Tests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net472;netcoreapp2.1;netcoreapp3.1 - false - $(NoWarn);CS1591 - true - ..\tests.ruleset - - - - - - - - - - - - - - - diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index ae6eca97c..61718a1f8 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -1,8 +1,3 @@ - - netstandard2.0 - ..\shipping.ruleset - - diff --git a/src/shipping.ruleset b/src/shipping.ruleset deleted file mode 100644 index 729035460..000000000 --- a/src/shipping.ruleset +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/tests.ruleset b/src/tests.ruleset deleted file mode 100644 index a13659760..000000000 --- a/src/tests.ruleset +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/strongname.snk b/strongname.snk similarity index 100% rename from src/strongname.snk rename to strongname.snk diff --git a/src/stylecop.json b/stylecop.json similarity index 100% rename from src/stylecop.json rename to stylecop.json diff --git a/test/.editorconfig b/test/.editorconfig new file mode 100644 index 000000000..eac6d8ae5 --- /dev/null +++ b/test/.editorconfig @@ -0,0 +1,28 @@ +[*.cs] + +# SA1600: Elements should be documented +dotnet_diagnostic.SA1600.severity = silent + +# SA1601: Partial elements should be documented +dotnet_diagnostic.SA1601.severity = silent + +# SA1602: Enumeration items should be documented +dotnet_diagnostic.SA1602.severity = silent + +# SA1615: Element return value should be documented +dotnet_diagnostic.SA1615.severity = silent + +# VSTHRD103: Call async methods when in an async method +dotnet_diagnostic.VSTHRD103.severity = silent + +# VSTHRD111: Use .ConfigureAwait(bool) +dotnet_diagnostic.VSTHRD111.severity = none + +# VSTHRD200: Use Async suffix for async methods +dotnet_diagnostic.VSTHRD200.severity = silent + +# CA1303: Do not pass literals as localized parameters +dotnet_diagnostic.CA1303.severity = none + +# CS1591: Missing XML comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = silent diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 000000000..66b41d56b --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,11 @@ + + + + + net472;netcoreapp2.1;netcoreapp3.1 + false + true + + + + diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets new file mode 100644 index 000000000..6a5a72c2d --- /dev/null +++ b/test/Directory.Build.targets @@ -0,0 +1,3 @@ + + + diff --git a/src/Library.Tests/CalculatorTests.cs b/test/Library.Tests/CalculatorTests.cs similarity index 100% rename from src/Library.Tests/CalculatorTests.cs rename to test/Library.Tests/CalculatorTests.cs diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj new file mode 100644 index 000000000..6113925a2 --- /dev/null +++ b/test/Library.Tests/Library.Tests.csproj @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Library.Tests/app.config b/test/Library.Tests/app.config similarity index 100% rename from src/Library.Tests/app.config rename to test/Library.Tests/app.config diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 8d77a9fe7..7f9bf6cdc 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -31,7 +31,7 @@ $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1 # Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() -Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% { +Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% { $projXml = [xml](Get-Content -Path $_) $targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework if (!$targetFrameworks) { From acda37b47951338b6c06a579a49e6215ce5bc586 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 10 Apr 2020 09:14:13 -0600 Subject: [PATCH 111/641] Add -y switch to choco install Fixes #47 --- .github/workflows/build.yml | 2 +- azure-pipelines/install-dependencies.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55575add1..4ea0df364 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: ./init.ps1 -UpgradePrerequisites dotnet --info if ($env:RUNNER_OS -eq "Windows") { - choco install procdump + choco install procdump -y Write-Host "##[set-env name=PROCDUMP_PATH;]$env:PROGRAMDATA\chocolatey\bin\" } shell: pwsh diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index ec9c3f56a..d48048666 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -10,7 +10,7 @@ steps: # The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests. - powershell: | - choco install procdump + choco install procdump -y Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH;]$env:ProgramData\chocolatey\bin\" displayName: Install procdump condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) From fd029d44e16358417a3e30cacc159f2efb9f5da0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Apr 2020 07:50:02 -0600 Subject: [PATCH 112/641] Stop passing $(System.AccessToken) as an arg in AzP Fixes #49 --- azure-pipelines/install-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index d48048666..96917c4f3 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -4,7 +4,7 @@ parameters: steps: - powershell: | - .\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} -UpgradePrerequisites + .\init.ps1 ${{ parameters['initArgs'] }} -UpgradePrerequisites dotnet --info displayName: Install prerequisites From f45370dbf3dc173e09d8738e462a81431bd7c70b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Apr 2020 09:42:24 -0600 Subject: [PATCH 113/641] Fix Set-EnvVars to print vars to console When run in the context of init.ps1, they were just swallowed up. Also we should only return a boolean. Outputing more than that will cause callers to malfunction. --- azure-pipelines/Set-EnvVars.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/Set-EnvVars.ps1 b/azure-pipelines/Set-EnvVars.ps1 index 907659a7b..9d14d9aa0 100644 --- a/azure-pipelines/Set-EnvVars.ps1 +++ b/azure-pipelines/Set-EnvVars.ps1 @@ -24,7 +24,7 @@ if ($cmdInstructions) { Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue } else { Write-Host "Environment variables set:" -ForegroundColor Blue - $envVars + Write-Host ($Variables | Out-String) if ($PrependPath) { Write-Host "Paths prepended to PATH: $PrependPath" } From e9dcc410b3a0cc01d48927253a66e9e3e8eb0a21 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Apr 2020 09:44:37 -0600 Subject: [PATCH 114/641] Acquire procdump via nuget Just using nuget instead of choco makes it take less than 1 second instead of nearly a minute. It also removes the requirement for chocolatey to be installed on AzP agents, which helps compatibility with custom/private agents. Also move it to init.ps1 so it doesn't require a special AzP or GitHub Actions task and it canl run on local dev boxes. --- .github/workflows/build.yml | 4 ---- azure-pipelines/Get-ProcDump.ps1 | 14 ++++++++++++++ azure-pipelines/install-dependencies.yml | 7 ------- init.ps1 | 10 ++++++++++ 4 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 azure-pipelines/Get-ProcDump.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ea0df364..91040d811 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,10 +35,6 @@ jobs: run: | ./init.ps1 -UpgradePrerequisites dotnet --info - if ($env:RUNNER_OS -eq "Windows") { - choco install procdump -y - Write-Host "##[set-env name=PROCDUMP_PATH;]$env:PROGRAMDATA\chocolatey\bin\" - } shell: pwsh - name: Set pipeline variables based on source run: azure-pipelines/variables/_pipelines.ps1 diff --git a/azure-pipelines/Get-ProcDump.ps1 b/azure-pipelines/Get-ProcDump.ps1 new file mode 100644 index 000000000..1493fe4b2 --- /dev/null +++ b/azure-pipelines/Get-ProcDump.ps1 @@ -0,0 +1,14 @@ +<# +.SYNOPSIS +Downloads 32-bit and 64-bit procdump executables and returns the path to where they were installed. +#> +$version = '0.0.1' +$baseDir = "$PSScriptRoot\..\obj\tools" +$procDumpToolPath = "$baseDir\procdump.$version\bin" +if (-not (Test-Path $procDumpToolPath)) { + if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } + $baseDir = (Resolve-Path $baseDir).Path # Normalize it + & (& $PSScriptRoot\Get-NuGetTool.ps1) install procdump -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://api.nuget.org/v3/index.json | Out-Null +} + +(Resolve-Path $procDumpToolPath).Path diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 96917c4f3..51cf839d4 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -8,13 +8,6 @@ steps: dotnet --info displayName: Install prerequisites -# The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests. -- powershell: | - choco install procdump -y - Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH;]$env:ProgramData\chocolatey\bin\" - displayName: Install procdump - condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true displayName: Set pipeline variables based on source diff --git a/init.ps1 b/init.ps1 index a0c9961f3..ca0d718a3 100755 --- a/init.ps1 +++ b/init.ps1 @@ -39,9 +39,17 @@ Param ( [string]$AccessToken ) +$EnvVars = @{} + if (!$NoPrerequisites) { & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality + + # The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests. + # But it only works on Windows. + if ($env:OS -eq 'Windows_NT') { + $EnvVars['PROCDUMP_PATH'] = & "$PSScriptRoot\azure-pipelines\Get-ProcDump.ps1" + } } # Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines @@ -59,6 +67,8 @@ try { throw "Failure while restoring packages." } } + + & "$PSScriptRoot\azure-pipelines\Set-EnvVars.ps1" -Variables $EnvVars | Out-Null } catch { Write-Error $error[0] From e5347ab78aada5c9401f35fe6d16b3b5569b0cc6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Apr 2020 11:54:51 -0600 Subject: [PATCH 115/641] Update README file --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0c3bcf59e..32a67820a 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,22 @@ ## Features * Follow the best and simplest patterns of build, pack and test with dotnet CLI. +* Init script that installs prerequisites and auth helpers, supporting both non-elevation and elevation modes. * Static analyzers: [FxCop](https://docs.microsoft.com/en-us/visualstudio/code-quality/fxcop-analyzers?view=vs-2019) and [StyleCop](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) * Read-only source tree (builds to top-level bin/obj folders) * Auto-versioning (via [Nerdbank.GitVersioning](https://github.com/aarnott/nerdbank.gitversioning)) -* Azure Pipeline via YAML with all dependencies declared for long-term serviceability. -* Testing on .NET Framework, multiple .NET Core versions -* Testing on Windows, Linux and OSX -* Code coverage published to Azure Pipelines -* Code coverage published to codecov.io so GitHub PRs get code coverage results added as a PR comment +* Builds with a "pinned" .NET Core SDK to ensure reproducible builds across machines and across time. +* Automatically pack the library and publish it as an artifact, and even push it to some NuGet feed for consumption. +* Testing + * Testing on .NET Framework, multiple .NET Core versions + * Testing on Windows, Linux and OSX + * Tests that crash or hang in Azure Pipelines automatically collect dumps and publish as a pipeline artifact for later investigation. +* Cloud build support: + * YAML based build for long-term serviceability, and PR review opportunities for any changes. + * Azure Pipelines and GitHub Action support + * Emphasis on PowerShell scripts over reliance on tasks for a more locally reproducible build. + * Code coverage published to Azure Pipelines + * Code coverage published to codecov.io so GitHub PRs get code coverage results added as a PR comment ## Consumption From b38ffc731de6cd80b20e1f5f612bb5c2b8ce1055 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Apr 2020 11:56:47 -0600 Subject: [PATCH 116/641] touchup readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32a67820a..e235ca648 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ * Testing on .NET Framework, multiple .NET Core versions * Testing on Windows, Linux and OSX * Tests that crash or hang in Azure Pipelines automatically collect dumps and publish as a pipeline artifact for later investigation. -* Cloud build support: +* Cloud build support * YAML based build for long-term serviceability, and PR review opportunities for any changes. * Azure Pipelines and GitHub Action support * Emphasis on PowerShell scripts over reliance on tasks for a more locally reproducible build. From 091601252d2dfefb66e63da77295dbc853013e79 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 16 Apr 2020 12:02:32 -0600 Subject: [PATCH 117/641] Bring back access tokens for AzP feed access Fixes #49 (properly) --- azure-pipelines/install-dependencies.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 51cf839d4..5b1ac4afd 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -4,7 +4,8 @@ parameters: steps: - powershell: | - .\init.ps1 ${{ parameters['initArgs'] }} -UpgradePrerequisites + $AccessToken = '$(System.AccessToken)' # Avoid specifying the access token directly on the init.ps1 command line to avoid it showing up in errors + .\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites dotnet --info displayName: Install prerequisites From ce6f1d1170dfff88bc1f6f44095442f75bd94e2d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 17 Apr 2020 12:10:46 -0600 Subject: [PATCH 118/641] Update link to NB.GV --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e235ca648..5424ff0a0 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ * Init script that installs prerequisites and auth helpers, supporting both non-elevation and elevation modes. * Static analyzers: [FxCop](https://docs.microsoft.com/en-us/visualstudio/code-quality/fxcop-analyzers?view=vs-2019) and [StyleCop](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) * Read-only source tree (builds to top-level bin/obj folders) -* Auto-versioning (via [Nerdbank.GitVersioning](https://github.com/aarnott/nerdbank.gitversioning)) +* Auto-versioning (via [Nerdbank.GitVersioning](https://github.com/dotnet/nerdbank.gitversioning)) * Builds with a "pinned" .NET Core SDK to ensure reproducible builds across machines and across time. * Automatically pack the library and publish it as an artifact, and even push it to some NuGet feed for consumption. * Testing From ebb0cb39f8ba823761693db82e7e0e509e080df2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 19 Apr 2020 10:10:43 -0600 Subject: [PATCH 119/641] Make Expand-Template.ps1 executable on linux --- Expand-Template.ps1 | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 Expand-Template.ps1 diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 old mode 100644 new mode 100755 index 9a05ececc..84b96680e --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/env pwsh + <# .SYNOPSIS Expands this template into an actual project, taking values for placeholders From 7688576a6aa2badce32e092a66708b0a4f452875 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 19 Apr 2020 10:13:23 -0600 Subject: [PATCH 120/641] Remove line that doesn't work on pwsh --- Expand-Template.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 84b96680e..dc53d1c15 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -148,7 +148,6 @@ try { Replace-Placeholders -Path "azure-pipelines.yml" -Replacements $YmlReplacements # Self destruct - $Invocation = (Get-Variable MyInvocation -Scope 1).Value git rm Expand-Template.* git rm :/azure-pipelines/expand-template.yml From 35cd5a2502d02cf0ba3e0141b7156403bf0b49e0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 19 Apr 2020 10:34:22 -0600 Subject: [PATCH 121/641] Move test project authoring into test folder --- Directory.Build.targets | 6 ------ test/Directory.Build.targets | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 1ddcba6f4..8c119d541 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,8 +1,2 @@ - - cobertura - [xunit.*]* - - $(OutputPath)/ - diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index 6a5a72c2d..c48559e72 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -1,3 +1,10 @@ + + cobertura + [xunit.*]* + + $(OutputPath)/ + + From 498b5e6a34037dca15b629a07ef0d05908fc6782 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Apr 2020 12:19:03 -0600 Subject: [PATCH 122/641] Authorize feeds in all nuget.config files throughout the repo --- tools/Install-NuGetCredProvider.ps1 | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 index 496dcd96a..2b3fb6fb4 100755 --- a/tools/Install-NuGetCredProvider.ps1 +++ b/tools/Install-NuGetCredProvider.ps1 @@ -46,14 +46,20 @@ if ($IsMacOS -or $IsLinux) { if ($AccessToken) { $endpoints = @() - $nugetConfig = [xml](Get-Content -Path "$PSScriptRoot\..\nuget.config") + $endpointURIs = @() + Get-ChildItem "$PSScriptRoot\..\nuget.config" -Recurse |% { + $nugetConfig = [xml](Get-Content -Path $_) - $nugetConfig.configuration.packageSources.add |? { ($_.value -match '^https://pkgs\.dev\.azure\.com/') -or ($_.value -match '^https://[\w\-]+\.pkgs\.visualstudio\.com/') } |% { - $endpoint = New-Object -TypeName PSObject - Add-Member -InputObject $endpoint -MemberType NoteProperty -Name endpoint -Value $_.value - Add-Member -InputObject $endpoint -MemberType NoteProperty -Name username -Value ado - Add-Member -InputObject $endpoint -MemberType NoteProperty -Name password -Value $AccessToken - $endpoints += $endpoint + $nugetConfig.configuration.packageSources.add |? { ($_.value -match '^https://pkgs\.dev\.azure\.com/') -or ($_.value -match '^https://[\w\-]+\.pkgs\.visualstudio\.com/') } |% { + if ($endpointURIs -notcontains $_.Value) { + $endpointURIs += $_.Value + $endpoint = New-Object -TypeName PSObject + Add-Member -InputObject $endpoint -MemberType NoteProperty -Name endpoint -Value $_.value + Add-Member -InputObject $endpoint -MemberType NoteProperty -Name username -Value ado + Add-Member -InputObject $endpoint -MemberType NoteProperty -Name password -Value $AccessToken + $endpoints += $endpoint + } + } } $auth = New-Object -TypeName PSObject From ddccc9105d88680362b8d59de699dfec0ce94bce Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Apr 2020 09:36:52 -0600 Subject: [PATCH 123/641] Fix conditional imports so they skip import on linux --- src/Directory.Build.props | 2 +- src/Directory.Build.targets | 2 +- test/Directory.Build.props | 2 +- test/Directory.Build.targets | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 50b6409ef..165d2ddd4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,5 +1,5 @@ - + netstandard2.0 diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index ada766550..c1ce36344 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -4,5 +4,5 @@ false - + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 66b41d56b..b48b5d81a 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,5 +1,5 @@ - + net472;netcoreapp2.1;netcoreapp3.1 diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index c48559e72..2faab3754 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -6,5 +6,5 @@ $(OutputPath)/ - + From a67e84559d64cf88a38e01c95e7f59a41104787d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Apr 2020 09:38:05 -0600 Subject: [PATCH 124/641] Reorder the docs to make more sense --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0893b308e..2102ba9b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,9 @@ with any additional questions or comments. ## Prerequisites +All dependencies can be installed by running the `init.ps1` script at the root of the repository +using Windows PowerShell or [PowerShell Core][pwsh] (on any OS). + The only prerequisite for building, testing, and deploying from this repository is the [.NET SDK](https://get.dot.net/). You should install the version specified in `global.json` or a later version within @@ -22,11 +25,6 @@ For example if 2.2.300 is specified, you may install 2.2.300, 2.2.301, or 2.2.31 while the 2.2.400 version would not be considered compatible by .NET SDK. See [.NET Core Versioning](https://docs.microsoft.com/en-us/dotnet/core/versions/) for more information. -All dependencies can be installed by running the `init.ps1` script at the root of the repository -using Windows PowerShell or [PowerShell Core][pwsh] (on any OS). - -This repository can be built on Windows, Linux, and OSX. - ## Package restore The easiest way to restore packages may be to run `init.ps1` which automatically authenticates @@ -35,6 +33,8 @@ to the feeds that packages for this repo come from, if any. ## Building +This repository can be built on Windows, Linux, and OSX. + Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.). [pwsh]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 From e649d82e01088d680a1182a49697e5dfa892a553 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Apr 2020 09:38:25 -0600 Subject: [PATCH 125/641] Update dependencies --- test/Library.Tests/Library.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 6113925a2..28433bf5c 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -5,8 +5,8 @@ - - + + From 8c54c69baede3744b4e8f8ed3d72b7115bdffc3b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 11 May 2020 09:40:52 -0600 Subject: [PATCH 126/641] Reduce certain rule severities in test projects --- test/.editorconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/.editorconfig b/test/.editorconfig index eac6d8ae5..89195ddae 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -26,3 +26,15 @@ dotnet_diagnostic.CA1303.severity = none # CS1591: Missing XML comment for publicly visible type or member dotnet_diagnostic.CS1591.severity = silent + +# CA1707: Identifiers should not contain underscores +dotnet_diagnostic.CA1707.severity = silent + +# CA1062: Validate arguments of public methods +dotnet_diagnostic.CA1062.severity = suggestion + +# CA1063: Implement IDisposable Correctly +dotnet_diagnostic.CA1063.severity = silent + +# CA1816: Dispose methods should call SuppressFinalize +dotnet_diagnostic.CA1816.severity = silent From 76eadc7926fc96ebc71e61988d2ee4516b34d73a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 11 May 2020 09:40:59 -0600 Subject: [PATCH 127/641] Add README as solution item --- Library.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/Library.sln b/Library.sln index 85b8939d8..606811aaf 100644 --- a/Library.sln +++ b/Library.sln @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.targets = Directory.Build.targets global.json = global.json nuget.config = nuget.config + README.md = README.md stylecop.json = stylecop.json version.json = version.json EndProjectSection From 160569a53024729c70b014fcad3c005e05a11ad2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 22 May 2020 09:35:59 -0600 Subject: [PATCH 128/641] Update package references --- Directory.Build.props | 6 +++--- test/Library.Tests/Library.Tests.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7a97368fc..9c119f372 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,11 +24,11 @@ - + - - + + diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 28433bf5c..29ac7bf82 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -6,7 +6,7 @@ - + From 6d120a6a222577b239671d0f14f89bd5c63dbb59 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 22 May 2020 09:56:20 -0600 Subject: [PATCH 129/641] Update SDK to 3.1.300 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 0275fa5c9..0200a660d 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.201", + "version": "3.1.300", "rollForward": "patch", "allowPrerelease": false } From ecbb92cd2f3022bb408014c8394869c8f9ed20a2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 22 May 2020 10:20:17 -0600 Subject: [PATCH 130/641] Quote arguments to mklink This prevents breaks when the linked paths contain spaces, commas or other characters. --- azure-pipelines/artifacts/_stage_all.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index a05db5292..4e6a6dbe0 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -33,7 +33,7 @@ function Create-SymbolicLink { if ($IsMacOS -or $IsLinux) { ln $Target $Link | Out-Null } else { - cmd /c mklink $Link $Target | Out-Null + cmd /c "mklink `"$Link`" `"$Target`"" | Out-Null } } From 860402b0b5cd59f44ca392c4ae42d38013eb637f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 8 Jun 2020 15:23:03 -0600 Subject: [PATCH 131/641] Fix Install-DotNetSdk.ps1 script on Windows PowerShell It misinterpreted it as a Mac/Linux environment under Windows Powershell. It only worked as-is under PowerShell Core, where `$IsWindows` is defined. --- tools/Install-DotNetSdk.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 7f9bf6cdc..a13638ae7 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -92,7 +92,9 @@ $envVars = @{ } if ($InstallLocality -eq 'machine') { - if ($IsWindows) { + if ($IsMacOS -or $IsLinux) { + $DotNetInstallDir = '/usr/share/dotnet' + } else { if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { Install-DotNet -Version $sdkVersion } @@ -104,8 +106,6 @@ if ($InstallLocality -eq 'machine') { } return - } else { - $DotNetInstallDir = '/usr/share/dotnet' } } elseif ($InstallLocality -eq 'repo') { $DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet" From 3c97ead14af585787a0cc41040dbb8e7077c5f9a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 15 Jun 2020 07:17:00 -0600 Subject: [PATCH 132/641] Update .NET Core SDK version to 3.1.301 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 0200a660d..11833de02 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.300", + "version": "3.1.301", "rollForward": "patch", "allowPrerelease": false } From bc3f88d11b10f7f34769ad7af884a3eb9cb66fe9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 15 Jun 2020 07:09:02 -0600 Subject: [PATCH 133/641] Avoid unannounced system restart When installing the .NET SDK or runtime, if the installer wants a system restart, it would do so quietly. This avoids the restart but adds a prompt at the end of the script to inform the user of a restart being required when necessary. Fixes #57 --- init.ps1 | 3 +++ tools/Install-DotNetSdk.ps1 | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/init.ps1 b/init.ps1 index ca0d718a3..72d68b5fa 100755 --- a/init.ps1 +++ b/init.ps1 @@ -44,6 +44,9 @@ $EnvVars = @{} if (!$NoPrerequisites) { & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality + if ($LASTEXITCODE -eq 3010) { + Exit 3010 + } # The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests. # But it only works on Windows. diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index a13638ae7..be5f6a276 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -77,8 +77,10 @@ Function Install-DotNet($Version, [switch]$Runtime) { Write-Host "Downloading .NET Core $sdkSubstring$Version..." $Installer = Get-InstallerExe -Version $Version -Runtime:$Runtime Write-Host "Installing .NET Core $sdkSubstring$Version..." - cmd /c start /wait $Installer /install /quiet - if ($LASTEXITCODE -ne 0) { + cmd /c start /wait $Installer /install /passive /norestart + if ($LASTEXITCODE -eq 3010) { + Write-Verbose "Restart required" + } elseif ($LASTEXITCODE -ne 0) { throw "Failure to install .NET Core SDK" } } @@ -95,16 +97,24 @@ if ($InstallLocality -eq 'machine') { if ($IsMacOS -or $IsLinux) { $DotNetInstallDir = '/usr/share/dotnet' } else { + $restartRequired = $false if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { Install-DotNet -Version $sdkVersion + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) } $runtimeVersions | Get-Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { Install-DotNet -Version $_ -Runtime + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) } } + if ($restartRequired) { + Write-Host -ForegroundColor Yellow "System restart required" + Exit 3010 + } + return } } elseif ($InstallLocality -eq 'repo') { From 4a0dface5e4967814178cdf2ebf67f38b01744a7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Jul 2020 15:08:50 -0600 Subject: [PATCH 134/641] Remove strongname.snk This is generated by expanding the template. It was mistakenly checked in at some point. --- strongname.snk | Bin 596 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 strongname.snk diff --git a/strongname.snk b/strongname.snk deleted file mode 100644 index a4d0a2ce39df5f7c284340b4a2c4690385c44208..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097Td7B6KsP|cl#<{bONo_!&t)QUG9wW^j zM1zvNAOI=XF}potSO>54lS%MGl8tv)xYTSw?~K<1McvNlJ;DITeY__C?><|;F`bgX zj;&2ME}KBWPb0zVSK+iW?{2`tzZR-#x0K_|t&0FhD+3urA!lNmCH;&b|?g|_AC39ox-0 zcV%KJis3}%`RVWSXN58fc}#LF$A#kcB2VWh=MH0zs+k7{ zQT<5V>NGhWzC7Jnt4A?n%Kk`fPt&FR4k~q{TSW%@D{plIpotzop}i+x`~C))*Vr-i zrW2)aE17f*=wCRa_#bHkYlQko_Jh)wN@;?yML9mYk)XZ`l6IQ*D7xZmmL=m(T|zMG i={(T>StYQl!YSPV From 2095a96269bc9bcf6c2eb9e21e3bbd2ccc33cc97 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 24 Jul 2020 07:57:24 -0600 Subject: [PATCH 135/641] Print existing variable in Azure Pipelines --- azure-pipelines/variables/_pipelines.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 14d6ffc28..3de19d7a2 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -8,7 +8,7 @@ # Always use ALL CAPS for env var names since Azure Pipelines converts variable names to all caps and on non-Windows OS, env vars are case sensitive. $keyCaps = $_.Key.ToUpper() if (Test-Path -Path "env:$keyCaps") { - Write-Host "Skipping setting $keyCaps because variable is already set." -ForegroundColor Cyan + Write-Host "Skipping setting $keyCaps because variable is already set to '$(Get-Content env:$keyCaps)'." -ForegroundColor Cyan } else { Write-Host "$keyCaps=$($_.Value)" -ForegroundColor Yellow if ($env:TF_BUILD) { From ecf6c16025a3905e673cdd542ad80185a9587e9e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 24 Jul 2020 08:46:23 -0600 Subject: [PATCH 136/641] Fix build and snk updates during template expansion We inappropriately removed the required snk file for our own build in 4a0dface5e496. This brings it back. It also updates Expand-Template.ps1 to overwrite the existing one rather than creating a new one in an ignored location. --- Expand-Template.ps1 | 4 ++-- strongname.snk | Bin 0 -> 596 bytes 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 strongname.snk diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index dc53d1c15..5ed211d03 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -101,8 +101,8 @@ try { git add "test/$LibraryName.Tests/$LibraryName.Tests.csproj" # Establish a new strong-name key - & $sn.Path -k 2048 src/strongname.snk - git add src/strongname.snk + & $sn.Path -k 2048 strongname.snk + git add strongname.snk # Replace placeholders in source files Replace-Placeholders -Path "src/$LibraryName/Calculator.cs" -Replacements @{ diff --git a/strongname.snk b/strongname.snk new file mode 100644 index 0000000000000000000000000000000000000000..a4d0a2ce39df5f7c284340b4a2c4690385c44208 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097Td7B6KsP|cl#<{bONo_!&t)QUG9wW^j zM1zvNAOI=XF}potSO>54lS%MGl8tv)xYTSw?~K<1McvNlJ;DITeY__C?><|;F`bgX zj;&2ME}KBWPb0zVSK+iW?{2`tzZR-#x0K_|t&0FhD+3urA!lNmCH;&b|?g|_AC39ox-0 zcV%KJis3}%`RVWSXN58fc}#LF$A#kcB2VWh=MH0zs+k7{ zQT<5V>NGhWzC7Jnt4A?n%Kk`fPt&FR4k~q{TSW%@D{plIpotzop}i+x`~C))*Vr-i zrW2)aE17f*=wCRa_#bHkYlQko_Jh)wN@;?yML9mYk)XZ`l6IQ*D7xZmmL=m(T|zMG i={(T>StYQl!YSPV literal 0 HcmV?d00001 From c03b185de7c83b21f1f84ac01656e2d3226625ac Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 25 Jul 2020 09:59:36 -0600 Subject: [PATCH 137/641] Set output variables as well This allows them to be referenced by subsequent jobs and stages. --- azure-pipelines/install-dependencies.yml | 1 + azure-pipelines/variables/_pipelines.ps1 | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 5b1ac4afd..f773f3853 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -12,3 +12,4 @@ steps: - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true displayName: Set pipeline variables based on source + name: SetPipelineVariables diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 3de19d7a2..552995509 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -12,7 +12,10 @@ } else { Write-Host "$keyCaps=$($_.Value)" -ForegroundColor Yellow if ($env:TF_BUILD) { - Write-Host "##vso[task.setvariable variable=$keyCaps;]$($_.Value)" + # Create two variables: the first that can be used by its simple name and accessible only within this job. + Write-Host "##vso[task.setvariable variable=$keyCaps]$($_.Value)" + # and the second that works across jobs and stages but must be fully qualified when referenced. + Write-Host "##vso[task.setvariable variable=$keyCaps;isOutput=true]$($_.Value)" } elseif ($env:GITHUB_ACTIONS) { Write-Host "::set-env name=$keyCaps::$($_.Value)" } From 171534d501b52b18a1d8bba53f93ec0149ad016a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 27 Jul 2020 16:13:01 -0600 Subject: [PATCH 138/641] Remove microbuild from CI list --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91040d811..b9f17c23c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - microbuild - validate/* pull_request: From 285bd4f1a116799fe42bbb454710fec90155e9f8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 4 Aug 2020 10:01:41 -0600 Subject: [PATCH 139/641] Enable GitHub Dependabot --- .editorconfig | 4 ++++ .github/dependabot.yml | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.editorconfig b/.editorconfig index 979d170a0..15f0b0e6b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,10 @@ indent_style = space # (Please don't specify an indent_size here; that has too many unintended consequences.) +[*.yml] +indent_size = 2 +indent_style = space + # Code files [*.{cs,csx,vb,vbx,h,cpp,idl}] indent_size = 4 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..aa48b0fe7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: +- package-ecosystem: nuget + directory: / + schedule: + interval: weekly From cc969eccc71582c459b528fbd6f2a7752a302e4f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 16:03:35 +0000 Subject: [PATCH 140/641] Bump xunit.runner.visualstudio from 2.4.1 to 2.4.3 Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.4.1 to 2.4.3. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/commits/v2.4.3) Signed-off-by: dependabot[bot] --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 29ac7bf82..a491f3697 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -8,7 +8,7 @@ - + From 116a8b074c2cc91e2ee2105e29b6bbaf9010c793 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 16:03:38 +0000 Subject: [PATCH 141/641] Bump Nerdbank.GitVersioning from 3.1.91 to 3.2.31 Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.1.91 to 3.2.31. - [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases) - [Commits](https://github.com/dotnet/Nerdbank.GitVersioning/compare/v3.1.91...v3.2.31) Signed-off-by: dependabot[bot] --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 9c119f372..7a6a46aee 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -27,7 +27,7 @@ - + From a6010319f64a75446a3f0c513388e736e0c98c0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 16:16:14 +0000 Subject: [PATCH 142/641] Bump coverlet.msbuild from 2.8.1 to 2.9.0 Bumps [coverlet.msbuild](https://github.com/coverlet-coverage/coverlet) from 2.8.1 to 2.9.0. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/commits) Signed-off-by: dependabot[bot] --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index a491f3697..4b76c54b7 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -5,7 +5,7 @@ - + From a8c59c572c872c495b467e1a1a1f81d174592bd6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2020 06:21:04 +0000 Subject: [PATCH 143/641] Bump Microsoft.Net.Compilers.Toolset from 3.6.0 to 3.7.0 Bumps [Microsoft.Net.Compilers.Toolset](https://github.com/dotnet/roslyn) from 3.6.0 to 3.7.0. - [Release notes](https://github.com/dotnet/roslyn/releases) - [Changelog](https://github.com/dotnet/roslyn/blob/master/docs/Breaking%20API%20Changes.md) - [Commits](https://github.com/dotnet/roslyn/commits) Signed-off-by: dependabot[bot] --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7a6a46aee..8ffdea803 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,7 +28,7 @@ - + From c73b9220f6b0131fc5ac67af91b71c96df51d782 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2020 06:21:04 +0000 Subject: [PATCH 144/641] Bump Microsoft.NET.Test.Sdk from 16.6.1 to 16.7.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.6.1 to 16.7.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.6.1...v16.7.0) Signed-off-by: dependabot[bot] --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 4b76c54b7..6e1c82938 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -6,7 +6,7 @@ - + From 29cf0a517da6adf751a11d2558361d5240f831a2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Aug 2020 08:02:17 -0600 Subject: [PATCH 145/641] Update .NET Core SDK to 3.1.302 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 11833de02..cc9e47f21 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.301", + "version": "3.1.302", "rollForward": "patch", "allowPrerelease": false } From fe64abe20bc74fc6aecedcbc54176b76298e4302 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Aug 2020 09:13:44 -0600 Subject: [PATCH 146/641] Get WPF inner-builds to import NuGet packages' imports Workaround for https://github.com/dotnet/wpf/issues/810 --- Directory.Build.props | 27 +++++++++++++++++++++++++++ Directory.Build.targets | 6 ++++++ src/Directory.Build.targets | 5 ----- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7a6a46aee..23d033f65 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -40,4 +40,31 @@ + + + false + true + + + + + <_WpfTempProjectNuGetFilePathNoExt>$(RepoRootPath)obj\$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g + + false + false + false + false + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets index 8c119d541..65a15bfc8 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,2 +1,8 @@ + + + false + + + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index c1ce36344..e7edee55a 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,8 +1,3 @@ - - - false - - From 225c8e7b9ea43c30640323f8ba4b89c5783b386c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 15 Aug 2020 09:00:24 -0600 Subject: [PATCH 147/641] Ignore CA2007 in tests --- test/.editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/.editorconfig b/test/.editorconfig index 89195ddae..2abae62d7 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -38,3 +38,6 @@ dotnet_diagnostic.CA1063.severity = silent # CA1816: Dispose methods should call SuppressFinalize dotnet_diagnostic.CA1816.severity = silent + +# CA2007: Consider calling ConfigureAwait on the awaited task +dotnet_diagnostic.CA2007.severity = none From eef30466f115466841d4107cfc7cd6affec91e08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2020 06:30:20 +0000 Subject: [PATCH 148/641] Bump Microsoft.CodeAnalysis.FxCopAnalyzers from 3.0.0 to 3.3.0 Bumps [Microsoft.CodeAnalysis.FxCopAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 3.0.0 to 3.3.0. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/master/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/v3.0.0...v3.3.0) Signed-off-by: dependabot[bot] --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index ce0d2a55f..b9f89e5a2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,7 +24,7 @@ - + From d5f3e774f5b345b578742607edc91513fcf66d0f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 19 Aug 2020 10:57:24 -0600 Subject: [PATCH 149/641] Add YAML based release pipeline --- azure-pipelines/release.yml | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 azure-pipelines/release.yml diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml new file mode 100644 index 000000000..bfe5987cd --- /dev/null +++ b/azure-pipelines/release.yml @@ -0,0 +1,72 @@ +trigger: none # We only want to trigger manually or based on resources +pr: none + +resources: + pipelines: + - pipeline: CI + source: Library # TODO: This should match the name of your CI pipeline + trigger: + tags: + - auto-release + +stages: +- stage: GitHubRelease + displayName: GitHub Release + jobs: + - deployment: create + pool: + vmImage: ubuntu-latest + environment: No-Approval + strategy: + runOnce: + deploy: + steps: + - download: none + - powershell: | + Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" + displayName: Set pipeline name + - task: GitHubRelease@1 + displayName: GitHub release (create) + inputs: + gitHubConnection: # TODO: fill in service connection here + repositoryName: $(Build.Repository.Name) + target: $(resources.pipeline.CI.sourceCommit) + tagSource: userSpecifiedTag + tag: v$(resources.pipeline.CI.runName) + title: v$(resources.pipeline.CI.runName) + isDraft: true # After running this step, visit the new draft release, edit, and publish. + changeLogCompareToRelease: lastNonDraftRelease + changeLogType: issueBased + changeLogLabels: | + [ + { "label" : "bug", "displayName" : "Fixes", "state" : "closed" }, + { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } + ] + +- stage: nuget_org + displayName: nuget.org + dependsOn: GitHubRelease + jobs: + - deployment: push + pool: + vmImage: ubuntu-latest + environment: No-Approval + strategy: + runOnce: + deploy: + steps: + - download: CI + artifact: deployables-Windows + displayName: Download deployables-Windows artifact + patterns: 'deployables-Windows/*' + - task: NuGetToolInstaller@1 + displayName: Use NuGet 5.x + inputs: + versionSpec: 5.x + - task: NuGetCommand@2 + displayName: NuGet push + inputs: + command: push + packagesToPush: $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg + nuGetFeedType: external + publishFeedCredentials: # TODO: fill in service connection here From 9469bdf8c4e70ac8a8d5d7b8eacbf94ad2b1c5e0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 19 Aug 2020 12:13:49 -0600 Subject: [PATCH 150/641] Fix up init.cmd to set env vars from .ps1 child process --- azure-pipelines/Set-EnvVars.ps1 | 20 ++++++++++++++++++- init.cmd | 16 +++++++++++++++ init.ps1 | 35 ++++++++++++++++++--------------- tools/Install-DotNetSdk.ps1 | 22 ++++++++++----------- 4 files changed, 65 insertions(+), 28 deletions(-) diff --git a/azure-pipelines/Set-EnvVars.ps1 b/azure-pipelines/Set-EnvVars.ps1 index 9d14d9aa0..bde2e3438 100644 --- a/azure-pipelines/Set-EnvVars.ps1 +++ b/azure-pipelines/Set-EnvVars.ps1 @@ -4,8 +4,13 @@ Azure Pipeline and CMD environments are considered. .PARAMETER Variables A hashtable of variables to be set. +.PARAMETER PrependPath + A set of paths to prepend to the PATH environment variable. .OUTPUTS A boolean indicating whether the environment variables can be expected to propagate to the caller's environment. +.DESCRIPTION + The CmdEnvScriptPath environment variable may be optionally set to a path to a cmd shell script to be created (or appended to if it already exists) that will set the environment variables in cmd.exe that are set within the PowerShell environment. + This is used by init.cmd in order to reapply any new environment variables to the parent cmd.exe process that were set in the powershell child process. #> [CmdletBinding(SupportsShouldProcess=$true)] Param( @@ -18,7 +23,7 @@ if ($Variables.Count -eq 0) { return $true } -$cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and $env:PS1UnderCmd -eq '1' +$cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and !$env:CmdEnvScriptPath -and ($env:PS1UnderCmd -eq '1') if ($cmdInstructions) { Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe" Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue @@ -38,6 +43,7 @@ if ($env:GITHUB_ACTIONS) { Write-Host "GitHub Actions detected. Logging commands will be used to propagate environment variables and prepend path." } +$CmdEnvScript = '' $Variables.GetEnumerator() |% { Set-Item -Path env:$($_.Key) -Value $_.Value @@ -52,6 +58,8 @@ $Variables.GetEnumerator() |% { if ($cmdInstructions) { Write-Host "SET $($_.Key)=$($_.Value)" } + + $CmdEnvScript += "SET $($_.Key)=$($_.Value)`r`n" } $pathDelimiter = ';' @@ -73,7 +81,17 @@ if ($PrependPath) { if ($env:GITHUB_ACTIONS) { Write-Host "::add-path::$_" } + + $CmdEnvScript += "SET PATH=$_$pathDelimiter%PATH%" + } +} + +if ($env:CmdEnvScriptPath) { + if (Test-Path $env:CmdEnvScriptPath) { + $CmdEnvScript = (Get-Content -Path $env:CmdEnvScriptPath) + $CmdEnvScript } + + Set-Content -Path $env:CmdEnvScriptPath -Value $CmdEnvScript } return !$cmdInstructions diff --git a/init.cmd b/init.cmd index 970285c2f..667efabb7 100644 --- a/init.cmd +++ b/init.cmd @@ -1,4 +1,20 @@ @echo off SETLOCAL set PS1UnderCmd=1 + +:: Get the datetime in a format that can go in a filename. +set _my_datetime=%date%_%time% +set _my_datetime=%_my_datetime: =_% +set _my_datetime=%_my_datetime::=% +set _my_datetime=%_my_datetime:/=_% +set _my_datetime=%_my_datetime:.=_% +set CmdEnvScriptPath=%temp%\envvarscript_%_my_datetime%.cmd + powershell.exe -NoProfile -NoLogo -ExecutionPolicy bypass -Command "try { & '%~dpn0.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }" + +:: Set environment variables in the parent cmd.exe process. +IF EXIST "%CmdEnvScriptPath%" ( + ENDLOCAL + CALL "%CmdEnvScriptPath%" + DEL "%CmdEnvScriptPath%" +) diff --git a/init.ps1 b/init.ps1 index 72d68b5fa..a6978b6fe 100755 --- a/init.ps1 +++ b/init.ps1 @@ -2,28 +2,31 @@ <# .SYNOPSIS -Installs dependencies required to build and test the projects in this repository. + Installs dependencies required to build and test the projects in this repository. .DESCRIPTION -This MAY not require elevation, as the SDK and runtimes are installed to a per-user location, -unless the `-InstallLocality` switch is specified directing to a per-repo or per-machine location. -See detailed help on that switch for more information. + This MAY not require elevation, as the SDK and runtimes are installed to a per-user location, + unless the `-InstallLocality` switch is specified directing to a per-repo or per-machine location. + See detailed help on that switch for more information. + + The CmdEnvScriptPath environment variable may be optionally set to a path to a cmd shell script to be created (or appended to if it already exists) that will set the environment variables in cmd.exe that are set within the PowerShell environment. + This is used by init.cmd in order to reapply any new environment variables to the parent cmd.exe process that were set in the powershell child process. .PARAMETER InstallLocality -A value indicating whether dependencies should be installed locally to the repo or at a per-user location. -Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. -Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. -Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. -When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. -Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. -Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. + A value indicating whether dependencies should be installed locally to the repo or at a per-user location. + Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. + Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. + Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. + When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. + Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. + Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. .PARAMETER NoPrerequisites -Skips the installation of prerequisite software (e.g. SDKs, tools). + Skips the installation of prerequisite software (e.g. SDKs, tools). .PARAMETER UpgradePrerequisites -Takes time to install prerequisites even if they are already present in case they need to be upgraded. -No effect if -NoPrerequisites is specified. + Takes time to install prerequisites even if they are already present in case they need to be upgraded. + No effect if -NoPrerequisites is specified. .PARAMETER NoRestore -Skips the package restore step. + Skips the package restore step. .PARAMETER AccessToken -An optional access token for authenticating to Azure Artifacts authenticated feeds. + An optional access token for authenticating to Azure Artifacts authenticated feeds. #> [CmdletBinding(SupportsShouldProcess=$true)] Param ( diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index be5f6a276..a02b5cdce 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -2,19 +2,19 @@ <# .SYNOPSIS -Installs the .NET SDK specified in the global.json file at the root of this repository, -along with supporting .NET Core runtimes used for testing. + Installs the .NET SDK specified in the global.json file at the root of this repository, + along with supporting .NET Core runtimes used for testing. .DESCRIPTION -This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location, -unless `-InstallLocality machine` is specified. + This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location, + unless `-InstallLocality machine` is specified. .PARAMETER InstallLocality -A value indicating whether dependencies should be installed locally to the repo or at a per-user location. -Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. -Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. -Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. -When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. -Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. -Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. + A value indicating whether dependencies should be installed locally to the repo or at a per-user location. + Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. + Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. + Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. + When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. + Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. + Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] Param ( From 5439be7fde0ebed774cffc561bf2390cea1a87b3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 19 Aug 2020 12:14:19 -0600 Subject: [PATCH 151/641] Move Set-EnvVars.ps1 to tools --- init.ps1 | 2 +- tools/Install-DotNetSdk.ps1 | 2 +- tools/Install-NuGetCredProvider.ps1 | 8 +++++--- {azure-pipelines => tools}/Set-EnvVars.ps1 | 0 4 files changed, 7 insertions(+), 5 deletions(-) rename {azure-pipelines => tools}/Set-EnvVars.ps1 (100%) diff --git a/init.ps1 b/init.ps1 index a6978b6fe..e5aad5bfa 100755 --- a/init.ps1 +++ b/init.ps1 @@ -74,7 +74,7 @@ try { } } - & "$PSScriptRoot\azure-pipelines\Set-EnvVars.ps1" -Variables $EnvVars | Out-Null + & "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars | Out-Null } catch { Write-Error $error[0] diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index a02b5cdce..2da4a73dc 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -165,5 +165,5 @@ $runtimeVersions | Get-Unique |% { } if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) { - & "$PSScriptRoot/../azure-pipelines/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null + & "$PSScriptRoot/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null } diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 index 2b3fb6fb4..6d3100349 100755 --- a/tools/Install-NuGetCredProvider.ps1 +++ b/tools/Install-NuGetCredProvider.ps1 @@ -19,6 +19,8 @@ Param ( [string]$AccessToken ) +$envVars = @{} + $toolsPath = & "$PSScriptRoot\..\azure-pipelines\Get-TempToolsPath.ps1" if ($IsMacOS -or $IsLinux) { @@ -66,9 +68,9 @@ if ($AccessToken) { Add-Member -InputObject $auth -MemberType NoteProperty -Name endpointCredentials -Value $endpoints $authJson = ConvertTo-Json -InputObject $auth - $envVars = @{ + $envVars += @{ 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS'=$authJson; } - - & "$PSScriptRoot\..\azure-pipelines\Set-EnvVars.ps1" -Variables $envVars | Out-Null } + +& "$PSScriptRoot/Set-EnvVars.ps1" -Variables $envVars | Out-Null diff --git a/azure-pipelines/Set-EnvVars.ps1 b/tools/Set-EnvVars.ps1 similarity index 100% rename from azure-pipelines/Set-EnvVars.ps1 rename to tools/Set-EnvVars.ps1 From 7d217d1f1658b5348bd9739b1e742c9ad7e21402 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 21 Aug 2020 21:54:00 -0600 Subject: [PATCH 152/641] Run net472 tests on mac/linux (which means on Mono) --- azure-pipelines/dotnet.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 6764e6ecc..8f4e950f0 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -12,7 +12,7 @@ steps: command: test arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: net472-$(Agent.JobName) - condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) + condition: succeededOrFailed() - task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp2.1 @@ -20,6 +20,7 @@ steps: command: test arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: netcoreapp2.1-$(Agent.JobName) + condition: succeededOrFailed() - task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp3.1 @@ -27,6 +28,7 @@ steps: command: test arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" testRunTitle: netcoreapp3.1-$(Agent.JobName) + condition: succeededOrFailed() - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true From 461288dfc334ecacc78d797ab9ceba504bbac25b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 23 Aug 2020 12:58:47 -0600 Subject: [PATCH 153/641] Beef up contrib doc explanation of init.ps1 --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2102ba9b0..36424c42d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,8 @@ with any additional questions or comments. All dependencies can be installed by running the `init.ps1` script at the root of the repository using Windows PowerShell or [PowerShell Core][pwsh] (on any OS). +Some dependencies installed by `init.ps1` may only be discoverable from the same command line environment the init script was run from due to environment variables, so be sure to launch Visual Studio or build the repo from that same environment. +Alternatively, run `init.ps1 -InstallLocality Machine` (which may require elevation) in order to install dependencies at machine-wide locations so Visual Studio and builds work everywhere. The only prerequisite for building, testing, and deploying from this repository is the [.NET SDK](https://get.dot.net/). From b79b08af1a6da50c9bee63c8b5e932992be53fa2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 23 Aug 2020 13:15:57 -0600 Subject: [PATCH 154/641] Add warning that non-machine installs must run within same environment --- tools/Install-DotNetSdk.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 2da4a73dc..ec66c949a 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -148,7 +148,10 @@ if (-not (Test-Path $DotNetInstallScriptPath)) { } } +$anythingInstalled = $false + if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" } else { Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" @@ -158,6 +161,7 @@ $switches += '-Runtime','dotnet' $runtimeVersions | Get-Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" } else { Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" @@ -167,3 +171,7 @@ $runtimeVersions | Get-Unique |% { if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) { & "$PSScriptRoot/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null } + +if ($anythingInstalled -and ($InstallLocality -ne 'machine') -and !$env:TF_BUILD -and !$env:GITHUB_ACTIONS) { + Write-Warning ".NET Core runtimes or SDKs were installed to a non-machine location. Perform your builds or open Visual Studio from this same environment in order for tools to discover the location of these dependencies." +} From 3d1c43c3d3222adfec73c0981fc799308a6a94e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Aug 2020 06:48:20 -0600 Subject: [PATCH 155/641] Bump Microsoft.NET.Test.Sdk from 16.7.0 to 16.7.1 (#72) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.7.0 to 16.7.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.7.0...v16.7.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 6e1c82938..ea4220b9a 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -6,7 +6,7 @@ - + From 641eaa17cdf690aacad122a78b3f32b13cf36d8a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Sep 2020 03:40:22 -0600 Subject: [PATCH 156/641] Provide better error when sn is not on the PATH Since the .NET Core SDK does not include the sn tool, on mac/linux the only way to create strong name keys is with mono. The expand-template.ps1 script didn't explain this to the user, but instead searched a Windows directory. This commit improves the error they see. Fixes #73 --- Expand-Template.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 5ed211d03..e0708bd4d 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -56,6 +56,10 @@ function Replace-Placeholders { # Try to find sn.exe if it isn't on the PATH $sn = Get-Command sn -ErrorAction SilentlyContinue if (-not $sn) { + if ($IsMacOS -or $IsLinux) { + Write-Error "sn command not found on PATH. Install mono and/or vote up this issue: https://github.com/dotnet/sdk/issues/13560" + exit(1) + } $snExes = Get-ChildItem -Recurse "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\sn.exe" if ($snExes) { $sn = Get-Command $snExes[0].FullName From e3449f0b073df5ec14886be35a8f01e76f4c50f1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Sep 2020 03:44:08 -0600 Subject: [PATCH 157/641] Fail fast when dotnet returns an exit code --- Expand-Template.ps1 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index e0708bd4d..adc4fb112 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -82,31 +82,48 @@ try { if ($Squash) { $originalCommitId = git rev-parse HEAD git reset --soft $(git rev-list --max-parents=0 HEAD) + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git commit --amend -qm "Initial template from https://github.com/AArnott/Library.Template" -m "Original commit from template $originalCommitId" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } # Rename project directories and solution git mv Library.sln "$LibraryName.sln" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git mv src/Library/Library.csproj "src/Library/$LibraryName.csproj" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git mv src/Library "src/$LibraryName" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git mv test/Library.Tests/Library.Tests.csproj "test/Library.Tests/$LibraryName.Tests.csproj" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git mv test/Library.Tests "test/$LibraryName.Tests" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # Refresh solution file both to update paths and give the projects unique GUIDs dotnet sln remove src/Library/Library.csproj + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } dotnet sln remove test/Library.Tests/Library.Tests.csproj + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } dotnet sln add "src/$LibraryName" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } dotnet sln add "test/$LibraryName.Tests" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git add "$LibraryName.sln" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # Update project reference in test project. Add before removal to keep the same ItemGroup in place. dotnet add "test/$LibraryName.Tests" reference "src/$LibraryName" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } dotnet remove "test/$LibraryName.Tests" reference src/Library/Library.csproj + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git add "test/$LibraryName.Tests/$LibraryName.Tests.csproj" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # Establish a new strong-name key & $sn.Path -k 2048 strongname.snk + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git add strongname.snk + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # Replace placeholders in source files Replace-Placeholders -Path "src/$LibraryName/Calculator.cs" -Replacements @{ @@ -153,7 +170,9 @@ try { # Self destruct git rm Expand-Template.* + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git rm :/azure-pipelines/expand-template.yml + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # Self-integrity check Get-ChildItem -Recurse -File -Exclude bin,obj,README.md,Expand-Template.* |? { -not $_.FullName.Contains("obj") } |% { @@ -165,6 +184,7 @@ try { # Commit the changes git commit -qm "Expanded template for $LibraryName" -m "This expansion done by the (now removed) Expand-Template.ps1 script." + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host -ForegroundColor Green "Template successfully expanded." From 0c212b6459c470633a941c7854eb6f73f258f488 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Sep 2020 05:59:22 -0600 Subject: [PATCH 158/641] Skip .NET SDK and runtime install when unneeded --- tools/Check-DotNetRuntime.ps1 | 41 +++++++++++++++++++++++++++++ tools/Check-DotNetSdk.ps1 | 31 ++++++++++++++++++++++ tools/Install-DotNetSdk.ps1 | 49 ++++++++++++++++++++++++----------- 3 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 tools/Check-DotNetRuntime.ps1 create mode 100644 tools/Check-DotNetSdk.ps1 diff --git a/tools/Check-DotNetRuntime.ps1 b/tools/Check-DotNetRuntime.ps1 new file mode 100644 index 000000000..9d0121095 --- /dev/null +++ b/tools/Check-DotNetRuntime.ps1 @@ -0,0 +1,41 @@ +<# +.SYNOPSIS + Checks whether a given .NET Core runtime is installed. +#> +[CmdletBinding()] +Param ( + [Parameter()] + [ValidateSet('Microsoft.AspNetCore.App','Microsoft.NETCore.App')] + [string]$Runtime='Microsoft.NETCore.App', + [Parameter(Mandatory=$true)] + [Version]$Version +) + +$dotnet = Get-Command dotnet -ErrorAction SilentlyContinue +if (!$dotnet) { + # Nothing is installed. + Write-Output $false + exit 1 +} + +Function IsVersionMatch { + Param( + [Parameter()] + $actualVersion + ) + return $actualVersion -and + $Version.Major -eq $actualVersion.Major -and + $Version.Minor -eq $actualVersion.Minor -and + (($Version.Build -eq -1) -or ($Version.Build -eq $actualVersion.Build)) -and + (($Version.Revision -eq -1) -or ($Version.Revision -eq $actualVersion.Revision)) +} + +$installedRuntimes = dotnet --list-runtimes |? { $_.Split()[0] -ieq $Runtime } |% { $v = $null; [Version]::tryparse($_.Split()[1], [ref] $v); $v } +$matchingRuntimes = $installedRuntimes |? { IsVersionMatch -actualVersion $_ } +if (!$matchingRuntimes) { + Write-Output $false + exit 1 +} + +Write-Output $true +exit 0 diff --git a/tools/Check-DotNetSdk.ps1 b/tools/Check-DotNetSdk.ps1 new file mode 100644 index 000000000..9d080f75f --- /dev/null +++ b/tools/Check-DotNetSdk.ps1 @@ -0,0 +1,31 @@ +<# +.SYNOPSIS + Checks whether the .NET Core SDK required by this repo is installed. +#> +[CmdletBinding()] +Param ( +) + +$dotnet = Get-Command dotnet -ErrorAction SilentlyContinue +if (!$dotnet) { + # Nothing is installed. + Write-Output $false + exit 1 +} + +# We need to set the current directory so dotnet considers the SDK required by our global.json file. +Push-Location "$PSScriptRoot\.." +try { + dotnet -h 2>&1 | Out-Null + if ($LASTEXITCODE -eq 129) { + # This error code indicates no matching SDK exists. + Write-Output $false + exit 2 + } + + # The required SDK is already installed! + Write-Output $true + exit 0 +} finally { + Pop-Location +} diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index ec66c949a..f7c023e61 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -15,11 +15,14 @@ When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. +.PARAMETER Force + Installs the preferred .NET SDK and runtime versions even if compatible versions are found to already be installed. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] Param ( [ValidateSet('repo','user','machine')] - [string]$InstallLocality='user' + [string]$InstallLocality='user', + [switch]$Force ) $DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools" @@ -98,15 +101,23 @@ if ($InstallLocality -eq 'machine') { $DotNetInstallDir = '/usr/share/dotnet' } else { $restartRequired = $false - if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { - Install-DotNet -Version $sdkVersion - $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetSdk.ps1"))) { + if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + Install-DotNet -Version $sdkVersion + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + } + } else { + Write-Verbose "A .NET SDK version compatible with $sdkVersion is already installed." } $runtimeVersions | Get-Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - Install-DotNet -Version $_ -Runtime - $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetRuntime.ps1" -Version $_))) { + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + Install-DotNet -Version $_ -Runtime + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + } + } else { + Write-Verbose ".NET runtime $_ is already installed." } } @@ -150,21 +161,29 @@ if (-not (Test-Path $DotNetInstallScriptPath)) { $anythingInstalled = $false -if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { - $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" +if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetSdk.ps1"))) { + if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" + } else { + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" + } } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" + Write-Verbose "A .NET SDK version compatible with $sdkVersion is already installed." } $switches += '-Runtime','dotnet' $runtimeVersions | Get-Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" + if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetRuntime.ps1" -Version $_))) { + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" + } else { + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" + } } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" + Write-Verbose ".NET runtime $_ is already installed." } } From 1c2cb37ea5e403f058c045559bc1788d416c2bf7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Sep 2020 05:59:35 -0600 Subject: [PATCH 159/641] Install SDK to expand-template when necessary --- Expand-Template.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index adc4fb112..c6ae8cba2 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -15,7 +15,7 @@ The `/{guid}` path to the Azure Pipelines artifact feed to push your nuget packa .PARAMETER Squash A switch that causes all of git history to be squashed to just one initial commit for the template, and one for its expansion. #> -[CmdletBinding()] +[CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')] Param( [Parameter(Mandatory=$true)] [string]$LibraryName, @@ -69,6 +69,15 @@ if (-not $sn) { } } +if (-not (& "$PSScriptRoot\tools\Check-DotNetSdk.ps1")) { + if ($PSCmdlet.ShouldProcess('Install .NET Core SDK?')) { + & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" + } else { + Write-Error "Matching .NET Core SDK version not found. Install now?" + exit 1 + } +} + # Verify all commands we use are on the PATH ('git','dotnet') |% { if (-not (Get-Command $_ -ErrorAction SilentlyContinue)) { From 8377c641a87333da635846e2b4511900407ac1bd Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 13 Sep 2020 07:40:35 -0600 Subject: [PATCH 160/641] Catch exception thrown on some machines --- tools/Check-DotNetSdk.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/Check-DotNetSdk.ps1 b/tools/Check-DotNetSdk.ps1 index 9d080f75f..6c9fa772c 100644 --- a/tools/Check-DotNetSdk.ps1 +++ b/tools/Check-DotNetSdk.ps1 @@ -17,8 +17,10 @@ if (!$dotnet) { Push-Location "$PSScriptRoot\.." try { dotnet -h 2>&1 | Out-Null - if ($LASTEXITCODE -eq 129) { - # This error code indicates no matching SDK exists. + if (($LASTEXITCODE -eq 129) -or # On Linux + ($LASTEXITCODE -eq -2147450751) # On Windows + ) { + # These exit codes indicate no matching SDK exists. Write-Output $false exit 2 } @@ -26,6 +28,10 @@ try { # The required SDK is already installed! Write-Output $true exit 0 +} catch { + # I don't know why, but on some build agents (e.g. MicroBuild), an exception is thrown from the `dotnet` invocation when a match is not found. + Write-Output $false + exit 3 } finally { Pop-Location } From 69a74f8c05201c01d1771f9ea2fa528283275e0d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Sep 2020 11:46:12 -0600 Subject: [PATCH 161/641] Revert incremental install of SDKs/Runtimes The 0c212b6459c4 commit brought this optimization in, but it is buggy because an SDK or runtime might not be installed because it's at the machine level, but if another runtime is missing and installed, it sets env vars which hide the machine level ones already found, so now they need to also be installed. But they weren't, so the build would just fail. Similarly, if the script is supposed to install to the machine location and the SDK is already installed at the user location, the recent optimization would skip installing it at the machine location. --- tools/Install-DotNetSdk.ps1 | 49 ++++++++++++------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index f7c023e61..ec66c949a 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -15,14 +15,11 @@ When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. -.PARAMETER Force - Installs the preferred .NET SDK and runtime versions even if compatible versions are found to already be installed. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] Param ( [ValidateSet('repo','user','machine')] - [string]$InstallLocality='user', - [switch]$Force + [string]$InstallLocality='user' ) $DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools" @@ -101,23 +98,15 @@ if ($InstallLocality -eq 'machine') { $DotNetInstallDir = '/usr/share/dotnet' } else { $restartRequired = $false - if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetSdk.ps1"))) { - if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { - Install-DotNet -Version $sdkVersion - $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) - } - } else { - Write-Verbose "A .NET SDK version compatible with $sdkVersion is already installed." + if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + Install-DotNet -Version $sdkVersion + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) } $runtimeVersions | Get-Unique |% { - if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetRuntime.ps1" -Version $_))) { - if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - Install-DotNet -Version $_ -Runtime - $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) - } - } else { - Write-Verbose ".NET runtime $_ is already installed." + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + Install-DotNet -Version $_ -Runtime + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) } } @@ -161,29 +150,21 @@ if (-not (Test-Path $DotNetInstallScriptPath)) { $anythingInstalled = $false -if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetSdk.ps1"))) { - if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { - $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" - } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" - } +if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" } else { - Write-Verbose "A .NET SDK version compatible with $sdkVersion is already installed." + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" } $switches += '-Runtime','dotnet' $runtimeVersions | Get-Unique |% { - if ($Force -or (-not (& "$PSScriptRoot/Check-DotNetRuntime.ps1" -Version $_))) { - if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" - } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" - } + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" } else { - Write-Verbose ".NET runtime $_ is already installed." + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" } } From 6c9781abbfcdcf0bd3001583cae8be38ab4c4903 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Sep 2020 11:34:03 -0600 Subject: [PATCH 162/641] Bump SDK to 3.1.402 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index cc9e47f21..a2e8ff9ec 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.302", + "version": "3.1.402", "rollForward": "patch", "allowPrerelease": false } From 1304c04d58a501d47ce335515b8aa61404a8126e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Sep 2020 14:52:20 -0600 Subject: [PATCH 163/641] Use lowercase for privateassets --- Directory.Build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b9f89e5a2..c6652de48 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -25,8 +25,8 @@ - - + + From 35ce94a23526a98dd3b827c1c609f6a4cf9968e9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Sep 2020 14:50:01 -0600 Subject: [PATCH 164/641] Simplify Project tag --- Directory.Build.props | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index c6652de48..8bb360bf0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@ - + Debug $(MSBuildThisFileDirectory) From c406cb86fdc100dd8ace0902562701f6a0110b1f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Sep 2020 14:50:11 -0600 Subject: [PATCH 165/641] Update URL for NB.GV schema --- version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.json b/version.json index 38da1662c..a13f567b5 100644 --- a/version.json +++ b/version.json @@ -1,8 +1,8 @@ { - "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", "version": "0.1-beta", "publicReleaseRefSpec": [ "^refs/heads/master$", "^refs/heads/v\\d+(?:\\.\\d+)?$" ] -} \ No newline at end of file +} From 19da325b6bb3aa7d61195098c546e6d0ed58cf31 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 25 Sep 2020 09:24:48 -0600 Subject: [PATCH 166/641] Add `Nullable` package --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8bb360bf0..4e95413bf 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,10 +24,11 @@ + - + From e00b38d09ce88c091325e6c572b397827b146683 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 25 Sep 2020 12:26:36 -0600 Subject: [PATCH 167/641] Checkout ps1 with LF endings --- .gitattributes | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index 9b6ea6248..c22a129ef 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,8 +3,9 @@ ############################################################################### * text=auto -# Ensure bash shell scripts use LF line endings +# Ensure shell scripts use LF line endings (linux only accepts LF) *.sh eol=lf +*.ps1 eol=lf ############################################################################### # Set default behavior for command prompt diff. @@ -20,7 +21,7 @@ # # Merging from the command prompt will add diff markers to the files if there # are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following +# the diff markers are never inserted). Diff markers may cause the following # file extensions to fail to load in VS. An alternative would be to treat # these files as binary and thus will always conflict and require user # intervention with every merge. To do so, just uncomment the entries below @@ -49,9 +50,9 @@ ############################################################################### # diff behavior for common document formats -# +# # Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the +# is only available from the command line. Turn it on by uncommenting the # entries below. ############################################################################### #*.doc diff=astextplain From 4765380c9ee5f82d2622728cfb4397d93e23a265 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 30 Mar 2020 10:00:18 -0600 Subject: [PATCH 168/641] Reorder TFMs in test project This gets the default run (and only run from VS Code) to work on Linux. --- test/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index b48b5d81a..2b7800299 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,7 +2,7 @@ - net472;netcoreapp2.1;netcoreapp3.1 + netcoreapp3.1;netcoreapp2.1;net472 false true From 68153893f540a33cd449500c5ca742888928e54e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 25 Sep 2020 13:50:58 -0600 Subject: [PATCH 169/641] Add devcontainer.json Also add other supporting files so that the VS Code 'dev container' scenario and GitHub Codespaces works nicely. --- .devcontainer/Dockerfile | 8 ++++++++ .devcontainer/devcontainer.json | 16 ++++++++++++++++ .vscode/extensions.json | 4 +++- .vscode/launch.json | 14 ++++++++++++++ .vscode/tasks.json | 17 +++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..c551ecf23 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,8 @@ +FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic + +# Installing mono makes `dotnet test` work without errors even for net472. +# But installing it takes a long time, so it's excluded by default. +#RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF +#RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list +#RUN apt-get update +#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mono-devel diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..9a86e07da --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,16 @@ +{ + "name": "Dev space", + "dockerFile": "Dockerfile", + "postCreateCommand": "./init.ps1 -InstallLocality machine", + "extensions": [ + "ms-azure-devops.azure-pipelines", + "ms-dotnettools.csharp", + "k--kato.docomment", + "editorconfig.editorconfig", + "pflannery.vscode-versionlens", + "davidanson.vscode-markdownlint", + "dotjoshjohnson.xml", + "ms-vscode-remote.remote-containers", + "ms-azuretools.vscode-docker" + ] +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ecda668ec..4ca016163 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -9,7 +9,9 @@ "editorconfig.editorconfig", "pflannery.vscode-versionlens", "davidanson.vscode-markdownlint", - "dotjoshjohnson.xml" + "dotjoshjohnson.xml", + "ms-vscode-remote.remote-containers", + "ms-azuretools.vscode-docker" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..a6e4859c2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..67b06180f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} From e1294286706d94b02029da23aa48ab177fa8d494 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 25 Sep 2020 17:59:29 -0600 Subject: [PATCH 170/641] Honor .editorconfig in Omnisharp --- .vscode/settings.json | 5 ++++- test/Library.Tests/CalculatorTests.cs | 7 +------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f0cafc05f..00aaed88f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,8 @@ { "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "files.trimFinalNewlines": true + "files.trimFinalNewlines": true, + "omnisharp.enableEditorConfigSupport": true, + "omnisharp.enableImportCompletion": true, + "omnisharp.enableRoslynAnalyzers": true } diff --git a/test/Library.Tests/CalculatorTests.cs b/test/Library.Tests/CalculatorTests.cs index 84fe9a97c..44e89aaa4 100644 --- a/test/Library.Tests/CalculatorTests.cs +++ b/test/Library.Tests/CalculatorTests.cs @@ -1,18 +1,13 @@ // Copyright (c) COMPANY-PLACEHOLDER. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using Library; using Xunit; -using Xunit.Abstractions; public class CalculatorTests { - private readonly ITestOutputHelper logger; - - public CalculatorTests(ITestOutputHelper logger) + public CalculatorTests() { - this.logger = logger; } [Fact] From aed5ff61d26dc1aa77f1eeeb73ddc47a640b1c39 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 26 Sep 2020 21:07:19 -0600 Subject: [PATCH 171/641] Fix RootNamespace property to actually take effect --- test/Directory.Build.props | 1 - test/Library.Tests/Library.Tests.csproj | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 2b7800299..2371a7ef5 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -5,7 +5,6 @@ netcoreapp3.1;netcoreapp2.1;net472 false true - diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index ea4220b9a..3565372a8 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -1,5 +1,9 @@ + + + + From 41d2e5533ffdacbb6abf9555860bead64cbcd1ea Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 30 Sep 2020 17:19:25 +0000 Subject: [PATCH 172/641] Use PowerShell as the preferred terminal --- .devcontainer/devcontainer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9a86e07da..996302820 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,9 @@ { "name": "Dev space", "dockerFile": "Dockerfile", + "settings": { + "terminal.integrated.shell.linux": "/usr/bin/pwsh" + }, "postCreateCommand": "./init.ps1 -InstallLocality machine", "extensions": [ "ms-azure-devops.azure-pipelines", From fa5d1e6eacf9de4a29fdf9d429541e33d0ddc8d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Oct 2020 16:05:42 -0500 Subject: [PATCH 173/641] Bump Nerdbank.GitVersioning from 3.2.31 to 3.3.37 (#75) Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.2.31 to 3.3.37. - [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases) - [Commits](https://github.com/dotnet/Nerdbank.GitVersioning/compare/v3.2.31...v3.3.37) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 4e95413bf..7fb8d8263 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -27,7 +27,7 @@ - + From bfd65cceb1895c72d04008ee5bcb9abed1f4d6dc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 20 Oct 2020 08:23:21 -0600 Subject: [PATCH 174/641] Print mono version in Azure Pipelines --- azure-pipelines/install-dependencies.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index f773f3853..7563bc1f8 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -7,6 +7,11 @@ steps: $AccessToken = '$(System.AccessToken)' # Avoid specifying the access token directly on the init.ps1 command line to avoid it showing up in errors .\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites dotnet --info + + # Print mono version if it is present. + if (Get-Command mono -ErrorAction SilentlyContinue) { + mono --version + } displayName: Install prerequisites - powershell: azure-pipelines/variables/_pipelines.ps1 From 5fdb2443f20647acb95316eaa1c39f94422a8f39 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 21 Oct 2020 07:42:32 -0600 Subject: [PATCH 175/641] Update dependencies monthly instead of weekly --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index aa48b0fe7..b9b0f54a2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,4 +6,4 @@ updates: - package-ecosystem: nuget directory: / schedule: - interval: weekly + interval: monthly From 4f2a03546774ba1f8312a2c3c8d4838aff43ca13 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 22 Oct 2020 09:05:58 -0600 Subject: [PATCH 176/641] Add release notes link to built package --- Directory.Build.props | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index 7fb8d8263..7ced2673b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -41,6 +41,13 @@ + + + + + + + false true From 958ffedb97ea213d52b76e04af515e31b1342eba Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 25 Oct 2020 21:36:40 -0600 Subject: [PATCH 177/641] Avoid warnings in Expand-Template due to line endings --- Expand-Template.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index c6ae8cba2..d665e56a3 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -96,6 +96,8 @@ try { if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } + git config core.safecrlf false # Avoid warnings when adding files with mangled line endings + # Rename project directories and solution git mv Library.sln "$LibraryName.sln" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } @@ -204,6 +206,7 @@ try { } } finally { + git config --local --unset core.safecrlf Pop-Location } From 05b332401c7545ac7c669f59defdcf796d4925e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2020 06:14:20 -0700 Subject: [PATCH 178/641] Bump Microsoft.CodeAnalysis.FxCopAnalyzers from 3.3.0 to 3.3.1 (#76) Bumps [Microsoft.CodeAnalysis.FxCopAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/master/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/v3.3.0...v3.3.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7ced2673b..642fb1d7d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,7 +23,7 @@ - + From 9c16ae2061cf5dc70b79c9cfa94bac9e95a978c8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 2 Nov 2020 09:48:52 -0700 Subject: [PATCH 179/641] Publish test symbols on failures When investigating test run failures from Azure Pipelines, symbols from test binaries may be just as important as symbols from product binaries. So publish them as pipeline artifacts as well. Also index all these symbols even in PR builds, since PR builds may fail and investigations may be required. --- azure-pipelines/Get-SymbolFiles.ps1 | 67 ++++++++++++++++++++++ azure-pipelines/artifacts/symbols.ps1 | 54 +---------------- azure-pipelines/artifacts/test_symbols.ps1 | 12 ++++ azure-pipelines/dotnet.yml | 11 +++- 4 files changed, 90 insertions(+), 54 deletions(-) create mode 100644 azure-pipelines/Get-SymbolFiles.ps1 create mode 100644 azure-pipelines/artifacts/test_symbols.ps1 diff --git a/azure-pipelines/Get-SymbolFiles.ps1 b/azure-pipelines/Get-SymbolFiles.ps1 new file mode 100644 index 000000000..bba177f1a --- /dev/null +++ b/azure-pipelines/Get-SymbolFiles.ps1 @@ -0,0 +1,67 @@ +<# +.SYNOPSIS + Collect the list of PDBs built in this repo, after converting them from portable to Windows PDBs. +.PARAMETER Path + The root path to recursively search for PDBs. +.PARAMETER Tests + A switch indicating to find test-related PDBs instead of product-only PDBs. +#> +[CmdletBinding()] +param ( + [parameter(Mandatory=$true)] + [string]$Path, + [switch]$Tests +) + +$WindowsPdbSubDirName = "symstore" + +$ActivityName = "Collecting symbols from $Path" +Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files" +$PDBs = Get-ChildItem -rec "$Path\*.pdb" |? { $_.FullName -notmatch "\W$WindowsPdbSubDirName\W" } + +# Filter PDBs to product OR test related. +$testregex = "unittest|tests" +if ($Tests) { + $PDBs = $PDBs |? { $_.FullName -match $testregex } +} else { + $PDBs = $PDBs |? { $_.FullName -notmatch $testregex } +} + +Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" +$PDBsByHash = @{} +$i = 0 +$PDBs |% { + Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" -PercentComplete (100 * $i / $PDBs.Length) + $hash = Get-FileHash $_ + $i++ + Add-Member -InputObject $_ -MemberType NoteProperty -Name Hash -Value $hash.Hash + Write-Output $_ +} | Sort-Object CreationTime |% { + # De-dupe based on hash. Prefer the first match so we take the first built copy. + if (-not $PDBsByHash.ContainsKey($_.Hash)) { + $PDBsByHash.Add($_.Hash, $_.FullName) + Write-Output $_ + } +} |% { + # Collect the DLLs/EXEs as well. + $dllPath = "$($_.Directory)\$($_.BaseName).dll" + $exePath = "$($_.Directory)\$($_.BaseName).exe" + if (Test-Path $dllPath) { + $BinaryImagePath = $dllPath + } elseif (Test-Path $exePath) { + $BinaryImagePath = $exePath + } + + Write-Output $BinaryImagePath + + # Convert the PDB to legacy Windows PDBs + Write-Host "Converting PDB for $_" -ForegroundColor DarkGray + $WindowsPdbDir = "$($_.Directory.FullName)\$WindowsPdbSubDirName" + if (!(Test-Path $WindowsPdbDir)) { mkdir $WindowsPdbDir | Out-Null } + & "$PSScriptRoot\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath "$WindowsPdbDir\$($_.BaseName).pdb" + if ($LASTEXITCODE -ne 0) { + Write-Warning "PDB conversion of `"$_`" failed." + } + + Write-Output "$WindowsPdbDir\$($_.BaseName).pdb" +} diff --git a/azure-pipelines/artifacts/symbols.ps1 b/azure-pipelines/artifacts/symbols.ps1 index 504913689..b3451ce1e 100644 --- a/azure-pipelines/artifacts/symbols.ps1 +++ b/azure-pipelines/artifacts/symbols.ps1 @@ -1,55 +1,3 @@ -Function Get-SymbolFiles { - [CmdletBinding()] - param ( - [parameter(Mandatory=$true)] - [string]$Path - ) - - $WindowsPdbSubDirName = "symstore" - - $ActivityName = "Collecting symbols from $Path" - Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files" - $PDBs = Get-ChildItem -rec "$Path\*.pdb" |? { $_.FullName -notmatch "unittest|tests|\W$WindowsPdbSubDirName\W" } - Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" - $PDBsByHash = @{} - $i = 0 - $PDBs |% { - Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" -PercentComplete (100 * $i / $PDBs.Length) - $hash = Get-FileHash $_ - $i++ - Add-Member -InputObject $_ -MemberType NoteProperty -Name Hash -Value $hash.Hash - Write-Output $_ - } | Sort-Object CreationTime |% { - # De-dupe based on hash. Prefer the first match so we take the first built copy. - if (-not $PDBsByHash.ContainsKey($_.Hash)) { - $PDBsByHash.Add($_.Hash, $_.FullName) - Write-Output $_ - } - } |% { - # Collect the DLLs/EXEs as well. - $dllPath = "$($_.Directory)\$($_.BaseName).dll" - $exePath = "$($_.Directory)\$($_.BaseName).exe" - if (Test-Path $dllPath) { - $BinaryImagePath = $dllPath - } elseif (Test-Path $exePath) { - $BinaryImagePath = $exePath - } - - Write-Output $BinaryImagePath - - # Convert the PDB to legacy Windows PDBs - Write-Host "Converting PDB for $_" -ForegroundColor DarkGray - $WindowsPdbDir = "$($_.Directory.FullName)\$WindowsPdbSubDirName" - if (!(Test-Path $WindowsPdbDir)) { mkdir $WindowsPdbDir | Out-Null } - & "$PSScriptRoot\..\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath "$WindowsPdbDir\$($_.BaseName).pdb" - if ($LASTEXITCODE -ne 0) { - Write-Warning "PDB conversion of `"$_`" failed." - } - - Write-Output "$WindowsPdbDir\$($_.BaseName).pdb" - } -} - # This doesn't work off Windows, nor do we need to convert symbols on multiple OS agents if ($IsMacOS -or $IsLinux) { return; @@ -57,7 +5,7 @@ if ($IsMacOS -or $IsLinux) { $BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\bin") if (!(Test-Path $BinPath)) { return } -$symbolfiles = Get-SymbolFiles -Path $BinPath | Get-Unique +$symbolfiles = & "$PSScriptRoot\..\Get-SymbolFiles.ps1" -Path $BinPath | Get-Unique @{ "$BinPath" = $SymbolFiles; diff --git a/azure-pipelines/artifacts/test_symbols.ps1 b/azure-pipelines/artifacts/test_symbols.ps1 new file mode 100644 index 000000000..d65ad0ae5 --- /dev/null +++ b/azure-pipelines/artifacts/test_symbols.ps1 @@ -0,0 +1,12 @@ +# This doesn't work off Windows, nor do we need to convert symbols on multiple OS agents +if ($IsMacOS -or $IsLinux) { + return; +} + +$BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\bin") +if (!(Test-Path $BinPath)) { return } +$symbolfiles = & "$PSScriptRoot\..\Get-SymbolFiles.ps1" -Path $BinPath -Tests | Get-Unique + +@{ + "$BinPath" = $SymbolFiles; +} diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 8f4e950f0..e664ecd3c 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -47,7 +47,16 @@ steps: IndexSources: false SymbolServerType: TeamServices displayName: Publish symbols to symbol server - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Agent.OS'], 'Windows_NT')) + condition: eq(variables['Agent.OS'], 'Windows_NT') # Execute on failed test runs too. Windows-only till https://github.com/microsoft/azure-pipelines-tasks/issues/13821 is fixed. + +- task: PublishSymbols@2 + inputs: + SymbolsFolder: $(Build.ArtifactStagingDirectory)/test_symbols-$(Agent.JobName) + SearchPattern: '**/*.pdb' + IndexSources: false + SymbolServerType: TeamServices + displayName: Publish test symbols to symbol server + condition: and(failed(), eq(variables['Agent.OS'], 'Windows_NT')) # Execute on failed test runs only. - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io From 1ba201241f4ab86578fd26e6f0489aaa620268cc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 2 Nov 2020 11:17:29 -0700 Subject: [PATCH 180/641] Remove macOS from Azure Pipeline runs --- azure-pipelines.yml | 8 ++++++++ azure-pipelines/build.yml | 4 ++++ azure-pipelines/publish-codecoverage.yml | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 22f8b5530..bba62459d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,6 +10,12 @@ trigger: - .vscode/ - .github/ +parameters: +- name: includeMacOS + displayName: Build on macOS + type: boolean + default: false # macOS is often bogged down in Azure Pipelines + variables: TreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true @@ -20,3 +26,5 @@ variables: jobs: - template: azure-pipelines/build.yml + parameters: + includeMacOS: ${{ parameters.includeMacOS }} diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 186438a1b..b4561394c 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -1,5 +1,6 @@ parameters: windowsPool: Hosted Windows 2019 with VS2019 + includeMacOS: jobs: - job: Windows @@ -26,6 +27,7 @@ jobs: - template: expand-template.yml - job: macOS + condition: ${{ parameters.includeMacOS }} pool: vmImage: macOS-10.15 steps: @@ -50,4 +52,6 @@ jobs: parameters: initArgs: -NoRestore - template: publish-codecoverage.yml + parameters: + includeMacOS: ${{ parameters.includeMacOS }} - template: publish-deployables.yml diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 976f0781b..0112aacf7 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -1,3 +1,6 @@ +parameters: + includeMacOS: + steps: - download: current artifact: coverageResults-Windows @@ -11,6 +14,7 @@ steps: artifact: coverageResults-macOS displayName: Download macOS code coverage results continueOnError: true + condition: ${{ parameters.includeMacOS }} - powershell: | dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj From d4b9a6afcd2fd37fe66be60a2ad9888a194cf53f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 3 Nov 2020 10:05:53 -0700 Subject: [PATCH 181/641] Capture binlog for test runs --- azure-pipelines/dotnet.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index e664ecd3c..5c498fc9a 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: dotnet test -f net472 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" + arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog" testRunTitle: net472-$(Agent.JobName) condition: succeededOrFailed() @@ -18,7 +18,7 @@ steps: displayName: dotnet test -f netcoreapp2.1 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp2.1.binlog" testRunTitle: netcoreapp2.1-$(Agent.JobName) condition: succeededOrFailed() @@ -26,7 +26,7 @@ steps: displayName: dotnet test -f netcoreapp3.1 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog" testRunTitle: netcoreapp3.1-$(Agent.JobName) condition: succeededOrFailed() From c234c68d0b45e5cc621db26063c199b51b4a45fd Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 11 Nov 2020 08:51:22 -0700 Subject: [PATCH 182/641] Update to .NET 5.0.100 SDK --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index a2e8ff9ec..e6e7ee5c0 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.402", + "version": "5.0.100", "rollForward": "patch", "allowPrerelease": false } From d8b3fc060bc43cc9e0371a62720e2b828c72f308 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 16 Nov 2020 09:48:54 -0700 Subject: [PATCH 183/641] Adapt to GitHub's new env and path operations Fixes #79 --- azure-pipelines/variables/_pipelines.ps1 | 2 +- tools/Set-EnvVars.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 552995509..867b7fc8b 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -17,7 +17,7 @@ # and the second that works across jobs and stages but must be fully qualified when referenced. Write-Host "##vso[task.setvariable variable=$keyCaps;isOutput=true]$($_.Value)" } elseif ($env:GITHUB_ACTIONS) { - Write-Host "::set-env name=$keyCaps::$($_.Value)" + Add-Content -Path $env:GITHUB_ENV -Value "$keyCaps=$($_.Value)" } Set-Item -Path "env:$keyCaps" -Value $_.Value } diff --git a/tools/Set-EnvVars.ps1 b/tools/Set-EnvVars.ps1 index bde2e3438..3f6f86ba5 100644 --- a/tools/Set-EnvVars.ps1 +++ b/tools/Set-EnvVars.ps1 @@ -52,7 +52,7 @@ $Variables.GetEnumerator() |% { Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" } if ($env:GITHUB_ACTIONS) { - Write-Host "::set-env name=$($_.Key)::$($_.Value)" + Add-Content -Path $env:GITHUB_ENV -Value "$($_.Key)=$($_.Value)" } if ($cmdInstructions) { @@ -79,7 +79,7 @@ if ($PrependPath) { Write-Host "##vso[task.prependpath]$_" } if ($env:GITHUB_ACTIONS) { - Write-Host "::add-path::$_" + Add-Content -Path $env:GITHUB_PATH -Value $_ } $CmdEnvScript += "SET PATH=$_$pathDelimiter%PATH%" From 759f9645c2ff5385c00f7c7e7a1613fba9628f8a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 17 Nov 2020 08:45:06 -0700 Subject: [PATCH 184/641] Add .NET 5.0 as a tested runtime --- Directory.Build.props | 2 +- azure-pipelines/dotnet.yml | 8 ++++++++ test/Directory.Build.props | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 642fb1d7d..ae6f905bb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,7 +24,7 @@ - + diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 5c498fc9a..34db9a40b 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -30,6 +30,14 @@ steps: testRunTitle: netcoreapp3.1-$(Agent.JobName) condition: succeededOrFailed() +- task: DotNetCoreCLI@2 + displayName: dotnet test -f net5.0 + inputs: + command: test + arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog" + testRunTitle: net5.0-$(Agent.JobName) + condition: succeededOrFailed() + - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true displayName: Update pipeline variables based on build outputs diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 2371a7ef5..4803641a5 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,7 +2,7 @@ - netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;net472 false true From 80928a35fc7d1499cadfd62f3e656ccb713a3c2f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 17 Nov 2020 08:46:15 -0700 Subject: [PATCH 185/641] Update package dependencies --- Directory.Build.props | 4 ++-- test/Library.Tests/Library.Tests.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 642fb1d7d..db63a1898 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,12 +24,12 @@ - + - + diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 3565372a8..ee3b3ae6f 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From 1aaddcfd2d397004c01aacd549136e06b80350bf Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Dec 2020 16:16:48 -0700 Subject: [PATCH 186/641] Update code analysis --- .editorconfig | 3 +++ Directory.Build.props | 3 ++- test/.editorconfig | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 15f0b0e6b..3be52e30b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -165,5 +165,8 @@ csharp_prefer_braces = true:silent # SA1130: Use lambda syntax dotnet_diagnostic.SA1130.severity = silent +# CA1508: Avoid dead conditional code +dotnet_diagnostic.CA1508.severity = warning + [*.sln] indent_style = tab diff --git a/Directory.Build.props b/Directory.Build.props index ae6f905bb..dedb50b87 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,6 +7,7 @@ $(RepoRootPath)bin\Packages\$(Configuration)\ 8.0 enable + latest true true @@ -23,7 +24,7 @@ - + diff --git a/test/.editorconfig b/test/.editorconfig index 2abae62d7..19b19171d 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -21,6 +21,12 @@ dotnet_diagnostic.VSTHRD111.severity = none # VSTHRD200: Use Async suffix for async methods dotnet_diagnostic.VSTHRD200.severity = silent +# CA1014: Mark assemblies with CLSCompliant +dotnet_diagnostic.CA1014.severity = none + +# CA1050: Declare types in namespaces +dotnet_diagnostic.CA1050.severity = none + # CA1303: Do not pass literals as localized parameters dotnet_diagnostic.CA1303.severity = none From 3ecde23ecfbd8983ee613dee60ed2c0bfe140608 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Dec 2020 16:17:45 -0700 Subject: [PATCH 187/641] Update compiler toolset This applies the fix to https://github.com/dotnet/roslyn/issues/49882 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index dedb50b87..2253d3e56 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -25,7 +25,7 @@ - + From 20e22606dc0c5bd2349b1c847ea619809bbe3946 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Dec 2020 16:34:12 -0700 Subject: [PATCH 188/641] Download pdb2pdb from pkgs.dev.azure.com instead of dotnet.myget.org --- azure-pipelines/Convert-PDB.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/Convert-PDB.ps1 b/azure-pipelines/Convert-PDB.ps1 index a3212213b..cfdb23697 100644 --- a/azure-pipelines/Convert-PDB.ps1 +++ b/azure-pipelines/Convert-PDB.ps1 @@ -24,7 +24,7 @@ if (-not (Test-Path $pdb2pdbpath)) { if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } $baseDir = (Resolve-Path $baseDir).Path # Normalize it - & (& $PSScriptRoot\Get-NuGetTool.ps1) install pdb2pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://dotnet.myget.org/F/symreader-converter/api/v3/index.json | Out-Null + & (& $PSScriptRoot\Get-NuGetTool.ps1) install pdb2pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/myget-legacy/nuget/v3/index.json | Out-Null } $args = $DllPath,'/out',$OutputPath,'/nowarn','0021' From 1e98c8f2c174806de3a82ca08b3834429a641bfc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Dec 2020 17:19:13 -0700 Subject: [PATCH 189/641] Update source and pkg id for pdb2pdb tool --- azure-pipelines/Convert-PDB.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/Convert-PDB.ps1 b/azure-pipelines/Convert-PDB.ps1 index cfdb23697..e9ecebcdb 100644 --- a/azure-pipelines/Convert-PDB.ps1 +++ b/azure-pipelines/Convert-PDB.ps1 @@ -18,13 +18,13 @@ [string]$OutputPath ) - $version = '1.1.0-beta1-64128-01' + $version = '1.1.0-beta2-20115-01' $baseDir = "$PSScriptRoot\..\obj\tools" - $pdb2pdbpath = "$baseDir\pdb2pdb.$version\tools\Pdb2Pdb.exe" + $pdb2pdbpath = "$baseDir\Microsoft.DiaSymReader.Pdb2Pdb.$version\tools\Pdb2Pdb.exe" if (-not (Test-Path $pdb2pdbpath)) { if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } $baseDir = (Resolve-Path $baseDir).Path # Normalize it - & (& $PSScriptRoot\Get-NuGetTool.ps1) install pdb2pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/myget-legacy/nuget/v3/index.json | Out-Null + & (& $PSScriptRoot\Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null } $args = $DllPath,'/out',$OutputPath,'/nowarn','0021' From e48583cdb8b5fec1e8debd747952ac6275ff6285 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 17 Dec 2020 10:45:30 -0700 Subject: [PATCH 190/641] Update to .NET Core SDK 3.1.404 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index a2e8ff9ec..daed8e947 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.402", + "version": "3.1.404", "rollForward": "patch", "allowPrerelease": false } From e36ce89e39e21d9adf14ca5e7aa4a9a684ee2701 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Jan 2021 07:27:43 -0700 Subject: [PATCH 191/641] Bump Microsoft.NET.Test.Sdk from 16.8.0 to 16.8.3 (#85) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.8.0 to 16.8.3. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.8.0...v16.8.3) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index ee3b3ae6f..aef334c26 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From c8c97da661b70635c42b56d5c3e6111f62abc448 Mon Sep 17 00:00:00 2001 From: Julien Chomarat Date: Thu, 7 Jan 2021 11:06:16 +0100 Subject: [PATCH 192/641] Remove [*.cs] Remove the second [*.cs] because it is already declared at line 122 --- .editorconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 15f0b0e6b..4937e1537 100644 --- a/.editorconfig +++ b/.editorconfig @@ -160,8 +160,6 @@ csharp_new_line_before_members_in_anonymous_types = true # Blocks are allowed csharp_prefer_braces = true:silent -[*.cs] - # SA1130: Use lambda syntax dotnet_diagnostic.SA1130.severity = silent From e47af99c1a8ba0dd97b6370d5f1b214c39e2ef67 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 15 Jan 2021 10:36:00 -0700 Subject: [PATCH 193/641] Remove protocolVersion attribute from nuget.config This isn't necessary so long as the URL ends in `/index.json`. --- nuget.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuget.config b/nuget.config index c0173d1ba..68f36551f 100644 --- a/nuget.config +++ b/nuget.config @@ -6,6 +6,6 @@ - + From e7e6de897b7ec8f6a442fd5ab9008d1d8993f271 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Feb 2021 20:17:53 -0700 Subject: [PATCH 194/641] Bump coverlet.msbuild from 2.9.0 to 3.0.2 (#88) Bumps [coverlet.msbuild](https://github.com/coverlet-coverage/coverlet) from 2.9.0 to 3.0.2. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/commits) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index aef334c26..72782f198 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -9,7 +9,7 @@ - + From 17ccfd1c617c6a3eaf6c95bedc5031404fb425a0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 11 Nov 2020 08:51:22 -0700 Subject: [PATCH 195/641] Update to .NET 5.0.102 SDK --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index e6e7ee5c0..b95ee4da2 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.100", + "version": "5.0.102", "rollForward": "patch", "allowPrerelease": false } From 72d343729e63bc2cb098aab63e63f3a6e96d5e4d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Feb 2021 17:11:22 -0700 Subject: [PATCH 196/641] Update compilers --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2253d3e56..c67b24ac4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -25,7 +25,7 @@ - + From fba5eed179f121b5db92185215b15af7caa73266 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Feb 2021 17:33:40 -0700 Subject: [PATCH 197/641] Rename master branch to main --- .github/workflows/build.yml | 2 +- README.md | 4 ++-- azure-pipelines.yml | 2 +- version.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9f17c23c..8567b4c9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - master + - main - validate/* pull_request: diff --git a/README.md b/README.md index 5424ff0a0..22d1091ef 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ ![NuGet package](https://img.shields.io/badge/nuget-your--package--here-yellow.svg) -[![Azure Pipelines status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/AArnott.Library.Template?branchName=master)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=29&branchName=master) +[![Azure Pipelines status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/AArnott.Library.Template?branchName=main)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=29&branchName=main) ![GitHub Actions status](https://github.com/aarnott/Library.Template/workflows/CI/badge.svg) -[![codecov](https://codecov.io/gh/aarnott/library.template/branch/master/graph/badge.svg)](https://codecov.io/gh/aarnott/library.template) +[![codecov](https://codecov.io/gh/aarnott/library.template/branch/main/graph/badge.svg)](https://codecov.io/gh/aarnott/library.template) ## Features diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bba62459d..2e4b2c157 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,7 +1,7 @@ trigger: branches: include: - - master + - main - 'validate/*' paths: exclude: diff --git a/version.json b/version.json index a13f567b5..f0da4f6a1 100644 --- a/version.json +++ b/version.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", "version": "0.1-beta", "publicReleaseRefSpec": [ - "^refs/heads/master$", + "^refs/heads/main$", "^refs/heads/v\\d+(?:\\.\\d+)?$" ] } From 7d993369c0977f77c28754360781ec67b3eeedf2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Feb 2021 18:25:04 -0700 Subject: [PATCH 198/641] Bump Microsoft.CodeAnalysis.NetAnalyzers from 5.0.1 to 5.0.3 (#89) Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 5.0.1 to 5.0.3. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/master/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/5.0.1...5.0.3) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index ecc066061..bedac7bbb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,7 +24,7 @@ - + From 28f1b256e7915a8889c3868cc965907fbb508dc9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Feb 2021 18:17:22 -0700 Subject: [PATCH 199/641] Consume newer PDB conversion package that is signed --- azure-pipelines/Convert-PDB.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/Convert-PDB.ps1 b/azure-pipelines/Convert-PDB.ps1 index e9ecebcdb..7a20305dc 100644 --- a/azure-pipelines/Convert-PDB.ps1 +++ b/azure-pipelines/Convert-PDB.ps1 @@ -18,7 +18,7 @@ [string]$OutputPath ) - $version = '1.1.0-beta2-20115-01' + $version = '1.1.0-beta2-21101-01' $baseDir = "$PSScriptRoot\..\obj\tools" $pdb2pdbpath = "$baseDir\Microsoft.DiaSymReader.Pdb2Pdb.$version\tools\Pdb2Pdb.exe" if (-not (Test-Path $pdb2pdbpath)) { From b3f2ca32e4b9139125b5075a556965731ff5bf1a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Feb 2021 18:28:51 -0700 Subject: [PATCH 200/641] Update dotnet-reportgenerator-globaltool to 4.8.5 --- azure-pipelines/publish-codecoverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 0112aacf7..d83eb64ad 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -16,7 +16,7 @@ steps: continueOnError: true condition: ${{ parameters.includeMacOS }} - powershell: | - dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config + dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.8.5 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" $reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.*.cobertura.xml" From 18b5902d5ea27b3d71aed9f231e79e142ea57c8c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Feb 2021 20:58:50 -0700 Subject: [PATCH 201/641] Propagate failure to install .NET SDK --- tools/Install-DotNetSdk.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index ec66c949a..06710ee3d 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -149,10 +149,16 @@ if (-not (Test-Path $DotNetInstallScriptPath)) { } $anythingInstalled = $false +$global:LASTEXITCODE = 0 if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } } else { Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" } @@ -163,6 +169,11 @@ $runtimeVersions | Get-Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { $anythingInstalled = $true Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } } else { Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" } From 5355f205cefddc0b46291cd02ca7e96f9df072d2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Feb 2021 21:06:04 -0700 Subject: [PATCH 202/641] Use pinned dotnet installer script This unblocks builds by working around https://github.com/dotnet/install-scripts/issues/136 --- tools/Install-DotNetSdk.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 06710ee3d..83ddec87f 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -134,10 +134,10 @@ if ($DotNetInstallDir) { } if ($IsMacOS -or $IsLinux) { - $DownloadUri = "https://dot.net/v1/dotnet-install.sh" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/1ebb108764c092e7a314ff3fe1388f582cbcf89a/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { - $DownloadUri = "https://dot.net/v1/dotnet-install.ps1" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/1ebb108764c092e7a314ff3fe1388f582cbcf89a/src/dotnet-install.ps1" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } From 2152fb59ab19d37691ff3fe9ac0df58cf433d921 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 5 Feb 2021 19:53:57 -0700 Subject: [PATCH 203/641] Update LangVersion to 9 Also update StyleCop. --- Directory.Build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index bedac7bbb..0281d8abc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,7 @@ $(RepoRootPath)obj\$(MSBuildProjectName)\ $(RepoRootPath)bin\$(MSBuildProjectName)\ $(RepoRootPath)bin\Packages\$(Configuration)\ - 8.0 + 9.0 enable latest true @@ -30,7 +30,7 @@ - + From a64ebcc0e9965c8b5119c79807f5b47bcfd8e96e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 8 Feb 2021 08:29:48 -0700 Subject: [PATCH 204/641] Update .NET installer script This may help with curl failures, as described in https://github.com/dotnet/install-scripts/issues/139 --- tools/Install-DotNetSdk.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 83ddec87f..132c374e6 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -134,10 +134,10 @@ if ($DotNetInstallDir) { } if ($IsMacOS -or $IsLinux) { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/1ebb108764c092e7a314ff3fe1388f582cbcf89a/src/dotnet-install.sh" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/7a9d5dcab92cf131fc2d8977052f8c2c2d540e22/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/1ebb108764c092e7a314ff3fe1388f582cbcf89a/src/dotnet-install.ps1" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/7a9d5dcab92cf131fc2d8977052f8c2c2d540e22/src/dotnet-install.ps1" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } From 791accaddbc87f2a06675d7620c849bc0a15a605 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 18 Feb 2021 15:55:28 -0700 Subject: [PATCH 205/641] Embed PDBs for all local builds --- Directory.Build.props | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index 0281d8abc..836dd5210 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,6 +10,9 @@ latest true + + embedded + true $(MSBuildThisFileDirectory)\strongname.snk From c463b89ca7a0edd3c8024420f3559b024126f8c7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 19 Feb 2021 10:20:37 -0700 Subject: [PATCH 206/641] Produce ref assembly for better incremental build Referencing projects don't need to recompile if the public API of a referenced project does not change. --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 836dd5210..081e4cfa7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,6 +9,7 @@ enable latest true + true embedded From c24318f044150c84e25c12d3240dddcfb9b509d8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 24 Feb 2021 09:52:16 -0700 Subject: [PATCH 207/641] Update to .NET SDK 5.0.103 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index b95ee4da2..24c50bd3e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.102", + "version": "5.0.103", "rollForward": "patch", "allowPrerelease": false } From fb488e6cd9acbf391f24db08cdbb51f2d0826113 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 24 Feb 2021 09:52:51 -0700 Subject: [PATCH 208/641] Sort PackageReference items --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 72782f198..8da189276 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -11,8 +11,8 @@ - + From a568829bc239d746133f05200936a1074627a9ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 09:19:46 -0700 Subject: [PATCH 209/641] Bump Microsoft.NET.Test.Sdk from 16.8.3 to 16.9.1 (#95) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.8.3 to 16.9.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.8.3...v16.9.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 8da189276..b1728e23d 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From bf34bea3b0d8cb04c617fa82a2b4bbd487e6ebaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 16:42:18 +0000 Subject: [PATCH 210/641] Bump coverlet.msbuild from 3.0.2 to 3.0.3 (#94) --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index b1728e23d..5a37213f1 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -9,7 +9,7 @@ - + From 1c04816f75df76aefb8cfdb9f61865de2104ff92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Apr 2021 10:09:48 -0600 Subject: [PATCH 211/641] Bump Microsoft.Net.Compilers.Toolset from 3.9.0-3.final to 3.9.0 (#96) Bumps [Microsoft.Net.Compilers.Toolset](https://github.com/dotnet/roslyn) from 3.9.0-3.final to 3.9.0. - [Release notes](https://github.com/dotnet/roslyn/releases) - [Changelog](https://github.com/dotnet/roslyn/blob/main/docs/Breaking%20API%20Changes.md) - [Commits](https://github.com/dotnet/roslyn/commits/v3.9.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 081e4cfa7..df9e2a693 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -29,7 +29,7 @@ - + From 1685f22a5954a7ffd5b83ab4a85769551a27dc5c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 10 Apr 2021 06:51:29 -0600 Subject: [PATCH 212/641] Bump .NET SDK to 5.0.201 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 24c50bd3e..e8e7c67eb 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.103", + "version": "5.0.201", "rollForward": "patch", "allowPrerelease": false } From 98156ca3cad1a3095df9b061df4adaa4fe8bbc62 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 27 Apr 2021 08:35:25 -0600 Subject: [PATCH 213/641] Fix local pack builds Local dev boxes were failing to build the `pack` target because symbols are now embedded into the assembly in that configuration and thus there were no pdb files to include in the snupkg file. --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index df9e2a693..ad5589bfe 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,7 +23,7 @@ MIT true true - true + true snupkg From 00cc0d4cdc0cade1e1ef311b63ed36c5f9293fb0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 27 Apr 2021 08:35:42 -0600 Subject: [PATCH 214/641] Bump .NET SDK to 5.0.202 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index e8e7c67eb..728ab6742 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.201", + "version": "5.0.202", "rollForward": "patch", "allowPrerelease": false } From ca33a6cabf6125d561f8e80466840181d8494592 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 May 2021 18:28:42 -0600 Subject: [PATCH 215/641] Bump Microsoft.NET.Test.Sdk from 16.9.1 to 16.9.4 (#98) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.9.1 to 16.9.4. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.9.1...v16.9.4) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 5a37213f1..2b8eff730 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From aba19025767fed9e84f867e3a1efc1e6a3051e92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 May 2021 18:28:55 -0600 Subject: [PATCH 216/641] Bump Nerdbank.GitVersioning from 3.3.37 to 3.4.194 (#97) Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.3.37 to 3.4.194. - [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases) - [Commits](https://github.com/dotnet/Nerdbank.GitVersioning/compare/v3.3.37...v3.4.194) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index ad5589bfe..1dc06021d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -32,7 +32,7 @@ - + From d3d35b668d08a2852bdd224c4f695d8b8e677605 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 15 May 2021 17:45:08 -0600 Subject: [PATCH 217/641] Add support for windowsdesktop runtimes to Install-DotNetSdk.ps1 script --- tools/Install-DotNetSdk.ps1 | 44 ++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 132c374e6..3afca0eed 100755 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -31,17 +31,25 @@ $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1 # Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() +$windowsDesktopRuntimeVersions = @() Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% { $projXml = [xml](Get-Content -Path $_) - $targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework - if (!$targetFrameworks) { - $targetFrameworks = $projXml.Project.PropertyGroup.TargetFrameworks - if ($targetFrameworks) { - $targetFrameworks = $targetFrameworks -Split ';' + $pg = $projXml.Project.PropertyGroup + if ($pg) { + $targetFrameworks = $pg.TargetFramework + if (!$targetFrameworks) { + $targetFrameworks = $pg.TargetFrameworks + if ($targetFrameworks) { + $targetFrameworks = $targetFrameworks -Split ';' + } } } $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% { - $runtimeVersions += $Matches[1] + $v = $Matches[1] + $runtimeVersions += $v + if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) { + $windowsDesktopRuntimeVersions += $v + } } } @@ -163,19 +171,35 @@ if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" } -$switches += '-Runtime','dotnet' +$dotnetRuntimeSwitches = $switches + '-Runtime','dotnet' -$runtimeVersions | Get-Unique |% { +$runtimeVersions | Sort-Object -Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $dotnetRuntimeSwitches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } + } else { + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $dotnetRuntimeSwitches -DryRun" + } +} + +$windowsDesktopRuntimeSwitches = $switches + '-Runtime','windowsdesktop' + +$windowsDesktopRuntimeVersions | Sort-Object -Unique |% { + if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop runtime $_", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $windowsDesktopRuntimeSwitches" if ($LASTEXITCODE -ne 0) { Write-Error ".NET SDK installation failure: $LASTEXITCODE" exit $LASTEXITCODE } } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $windowsDesktopRuntimeSwitches -DryRun" } } From f62b3815de957cae7e1f99376215fbec4fab84f0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 29 May 2021 09:21:55 -0600 Subject: [PATCH 218/641] Unpack xml doc files with nupkg for better Intellisense When using devcontainer for development, the xml files were not getting unpacked due to an environment variable being set in the docker container. This reverts that. Workaround for https://github.com/dotnet/dotnet-docker/issues/2790 --- .devcontainer/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c551ecf23..40e736b3f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,3 +6,8 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic #RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list #RUN apt-get update #RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mono-devel + +# Clear the NUGET_XMLDOC_MODE env var so xml api doc files get unpacked, allowing a rich experience in Intellisense. +# See https://github.com/dotnet/dotnet-docker/issues/2790 for a discussion on this, where the prioritized use case +# was *not* devcontainers, sadly. +ENV NUGET_XMLDOC_MODE= From 8644f535701be9be5f1f6b92fb5f10c566272394 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 29 May 2021 09:28:27 -0600 Subject: [PATCH 219/641] Update devcontainer base image to match global.json This leads to faster devcontainer creation times because init.ps1 can skip the SDK installation step. --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 40e736b3f..4e7707663 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic +FROM mcr.microsoft.com/dotnet/sdk:5.0.202-focal # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. From ee7f2ebc84a391f77229dce0d76878940b0b4c59 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 29 May 2021 09:48:29 -0600 Subject: [PATCH 220/641] Add powershell extension to devcontainer.json --- .devcontainer/devcontainer.json | 3 ++- .editorconfig | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 996302820..f4e3b31a3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,6 +14,7 @@ "davidanson.vscode-markdownlint", "dotjoshjohnson.xml", "ms-vscode-remote.remote-containers", - "ms-azuretools.vscode-docker" + "ms-azuretools.vscode-docker", + "ms-vscode.powershell" ] } diff --git a/.editorconfig b/.editorconfig index 01feb97fc..3f5b80ac4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -30,6 +30,7 @@ indent_size = 2 # JSON files [*.json] indent_size = 2 +indent_style = space # Dotnet code style settings: [*.{cs,vb}] From 7a23e0daa9c0179205aed56bab82e5dd5df75d24 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 29 May 2021 19:05:50 -0600 Subject: [PATCH 221/641] Fixes the Install-DotNetSdk.ps1 script when the path to the repo contains spaces (#100) --- tools/Install-DotNetSdk.ps1 | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) mode change 100755 => 100644 tools/Install-DotNetSdk.ps1 diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 old mode 100755 new mode 100644 index 3afca0eed..91399997c --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -136,16 +136,16 @@ if ($InstallLocality -eq 'machine') { Write-Host "Installing .NET Core SDK and runtimes to $DotNetInstallDir" -ForegroundColor Blue if ($DotNetInstallDir) { - $switches += '-InstallDir',$DotNetInstallDir + $switches += '-InstallDir',"`"$DotNetInstallDir`"" $envVars['DOTNET_MULTILEVEL_LOOKUP'] = '0' $envVars['DOTNET_ROOT'] = $DotNetInstallDir } if ($IsMacOS -or $IsLinux) { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/7a9d5dcab92cf131fc2d8977052f8c2c2d540e22/src/dotnet-install.sh" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/49d5da7f7d313aa65d24fe95cc29767faef553fd/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/7a9d5dcab92cf131fc2d8977052f8c2c2d540e22/src/dotnet-install.ps1" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/49d5da7f7d313aa65d24fe95cc29767faef553fd/src/dotnet-install.ps1" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } @@ -156,19 +156,24 @@ if (-not (Test-Path $DotNetInstallScriptPath)) { } } +# In case the script we invoke is in a directory with spaces, wrap it with single quotes. +# In case the path includes single quotes, escape them. +$DotNetInstallScriptPathExpression = $DotNetInstallScriptPath.Replace("'", "''") +$DotNetInstallScriptPathExpression = "& '$DotNetInstallScriptPathExpression'" + $anythingInstalled = $false $global:LASTEXITCODE = 0 if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion $switches" if ($LASTEXITCODE -ne 0) { Write-Error ".NET SDK installation failure: $LASTEXITCODE" exit $LASTEXITCODE } } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion $switches -DryRun" } $dotnetRuntimeSwitches = $switches + '-Runtime','dotnet' @@ -176,14 +181,14 @@ $dotnetRuntimeSwitches = $switches + '-Runtime','dotnet' $runtimeVersions | Sort-Object -Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $dotnetRuntimeSwitches" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $dotnetRuntimeSwitches" if ($LASTEXITCODE -ne 0) { Write-Error ".NET SDK installation failure: $LASTEXITCODE" exit $LASTEXITCODE } } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $dotnetRuntimeSwitches -DryRun" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $dotnetRuntimeSwitches -DryRun" } } @@ -192,14 +197,14 @@ $windowsDesktopRuntimeSwitches = $switches + '-Runtime','windowsdesktop' $windowsDesktopRuntimeVersions | Sort-Object -Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop runtime $_", "Install")) { $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $windowsDesktopRuntimeSwitches" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $windowsDesktopRuntimeSwitches" if ($LASTEXITCODE -ne 0) { Write-Error ".NET SDK installation failure: $LASTEXITCODE" exit $LASTEXITCODE } } else { - Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $windowsDesktopRuntimeSwitches -DryRun" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $windowsDesktopRuntimeSwitches -DryRun" } } From 30c95ce6bfce68ed827ec86eace746cca6f3af8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Jun 2021 07:05:02 -0600 Subject: [PATCH 222/641] Bump Microsoft.NET.Test.Sdk from 16.9.4 to 16.10.0 (#101) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.9.4 to 16.10.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.9.4...v16.10.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 2b8eff730..38e325ac4 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From 7c90eadbe31ccbf681c4f61a8002d93cef712ba5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Jun 2021 13:20:30 +0000 Subject: [PATCH 223/641] Bump Nerdbank.GitVersioning from 3.4.194 to 3.4.205 (#103) --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 1dc06021d..3282b7950 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -32,7 +32,7 @@ - + From fc1faae5f71bb2f7e4fa9cafef565617756b78d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Jun 2021 13:31:36 +0000 Subject: [PATCH 224/641] Bump Microsoft.NETFramework.ReferenceAssemblies from 1.0.0 to 1.0.2 (#102) --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3282b7950..d375bb2b1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -30,7 +30,7 @@ - + From 2f9ae16d7de3980d88b3ca5af327f2f24bc0b483 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 15 Jun 2021 15:57:41 -0600 Subject: [PATCH 225/641] Update StyleCop.Analyzers to 1.2.0-beta.333 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index d375bb2b1..7ea3c86b1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -34,7 +34,7 @@ - + From 29e05c03fb75ff4f5b6422edc171cad77b13c860 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 21 Jun 2021 08:32:15 -0600 Subject: [PATCH 226/641] Run IDExxxx analyzers in the build This helps the repo stay clean so users don't see a bunch of warnings in the error list when they open the solution from a team branch. --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 7ea3c86b1..bcc5a80d7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -8,6 +8,7 @@ 9.0 enable latest + true true true From ce744862270a6515fae669bf84e7495e134b61d6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 21 Jun 2021 08:33:56 -0600 Subject: [PATCH 227/641] Update Nerdbank.GitVersioning to 3.4.216 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index bcc5a80d7..bb311c675 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -33,7 +33,7 @@ - + From 68f4b7f1e1e0034f226f37722724a64d7af6723e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 21 Jun 2021 08:35:32 -0600 Subject: [PATCH 228/641] Update Microsoft.Net.Compilers.Toolset to 3.10.0 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index bb311c675..88b2e5836 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -30,7 +30,7 @@ - + From e7fab6db055c5173fa1cf105e48094283923175c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 28 Jun 2021 06:59:28 -0600 Subject: [PATCH 229/641] Update Ubuntu agent on AzP to 20.04 --- azure-pipelines/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index b4561394c..cd39a76ab 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -18,7 +18,7 @@ jobs: - job: Linux pool: - vmImage: Ubuntu 18.04 + vmImage: Ubuntu 20.04 steps: - checkout: self clean: true @@ -43,7 +43,7 @@ jobs: - Linux - macOS pool: - vmImage: Ubuntu 18.04 + vmImage: Ubuntu 20.04 condition: succeededOrFailed() steps: - checkout: self From d3b2f39ccc2ed8078da4d86302ac39ee2d007d52 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 28 Jun 2021 13:28:24 -0600 Subject: [PATCH 230/641] Use NuGetAuthenticate in AzP instead of hand installation This works around microsoft/artifacts-credprovider#244 --- azure-pipelines/install-dependencies.yml | 7 ++++++- init.ps1 | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 7563bc1f8..4f848b099 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -3,9 +3,14 @@ parameters: steps: +- task: NuGetAuthenticate@0 + displayName: Authenticate NuGet feeds + inputs: + forceReinstallCredentialProvider: true + - powershell: | $AccessToken = '$(System.AccessToken)' # Avoid specifying the access token directly on the init.ps1 command line to avoid it showing up in errors - .\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites + .\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites -NoNuGetCredProvider dotnet --info # Print mono version if it is present. diff --git a/init.ps1 b/init.ps1 index e5aad5bfa..4cf910f26 100755 --- a/init.ps1 +++ b/init.ps1 @@ -20,6 +20,9 @@ Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. .PARAMETER NoPrerequisites Skips the installation of prerequisite software (e.g. SDKs, tools). +.PARAMETER NoNuGetCredProvider + Skips the installation of the NuGet credential provider. Useful in pipelines with the `NuGetAuthenticate` task, as a workaround for https://github.com/microsoft/artifacts-credprovider/issues/244. + This switch is ignored and installation is skipped when -NoPrerequisites is specified. .PARAMETER UpgradePrerequisites Takes time to install prerequisites even if they are already present in case they need to be upgraded. No effect if -NoPrerequisites is specified. @@ -35,6 +38,8 @@ Param ( [Parameter()] [switch]$NoPrerequisites, [Parameter()] + [switch]$NoNuGetCredProvider, + [Parameter()] [switch]$UpgradePrerequisites, [Parameter()] [switch]$NoRestore, @@ -45,7 +50,10 @@ Param ( $EnvVars = @{} if (!$NoPrerequisites) { - & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites + if (!$NoNuGetCredProvider) { + & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites + } + & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality if ($LASTEXITCODE -eq 3010) { Exit 3010 From 505f36a697ae0736f029b6e9baab9b54fdd611bb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 30 Jun 2021 18:26:45 -0600 Subject: [PATCH 231/641] Update .NET SDK --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 728ab6742..34eb419ff 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.202", + "version": "5.0.301", "rollForward": "patch", "allowPrerelease": false } From c0e8f4210567af6799ebd6343ae59dd6e547558e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 1 Jul 2021 06:50:34 -0600 Subject: [PATCH 232/641] Use batched CI --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2e4b2c157..a1435d918 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,4 +1,5 @@ trigger: + batch: true branches: include: - main From 3230021112457742dbc0a6c05f5088c19fe25156 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jul 2021 07:19:49 -0600 Subject: [PATCH 233/641] Bump Nerdbank.GitVersioning from 3.4.216 to 3.4.220 (#106) Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.4.216 to 3.4.220. - [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases) - [Commits](https://github.com/dotnet/Nerdbank.GitVersioning/compare/v3.4.216...v3.4.220) --- updated-dependencies: - dependency-name: Nerdbank.GitVersioning dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 88b2e5836..d439a72c3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -33,7 +33,7 @@ - + From 3a49199ce9cc05805877e6a0822e5b9e9f153804 Mon Sep 17 00:00:00 2001 From: Steve Bush Date: Sun, 25 Jul 2021 11:11:45 -0700 Subject: [PATCH 234/641] Add support for TargetFrameworks of the form netXX Add support for TargetFrameworks of the form netXX to Dotnet SDK installer script --- tools/Install-DotNetSdk.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 91399997c..00772a9e2 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -51,6 +51,15 @@ Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$P $windowsDesktopRuntimeVersions += $v } } + + # Add target frameworks of the form: netXX + $targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% { + $v = $Matches[1] + $runtimeVersions += $v + if (-not ($IsMacOS -or $IsLinux)) { + $windowsDesktopRuntimeVersions += $v + } + } } Function Get-FileFromWeb([Uri]$Uri, $OutDir) { From fd43c77b00bc00d5fddf485f994a34f07313df15 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 25 Jul 2021 21:29:11 -0600 Subject: [PATCH 235/641] Update coverlet.msbuild and .NET SDK --- global.json | 2 +- test/Library.Tests/Library.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 34eb419ff..d28f85bf6 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.301", + "version": "5.0.302", "rollForward": "patch", "allowPrerelease": false } diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 38e325ac4..660f9fb5b 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -9,7 +9,7 @@ - + From 998b4dbed1cf203d8c423b13d9c5133b77f16232 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Aug 2021 07:20:04 -0600 Subject: [PATCH 236/641] Bump Nerdbank.GitVersioning from 3.4.220 to 3.4.231 (#110) Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.4.220 to 3.4.231. - [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases) - [Commits](https://github.com/dotnet/Nerdbank.GitVersioning/compare/v3.4.220...v3.4.231) --- updated-dependencies: - dependency-name: Nerdbank.GitVersioning dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index d439a72c3..125552453 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -33,7 +33,7 @@ - + From 1808050a987440698578162df0f4f077c86feb18 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Aug 2021 08:51:43 -0600 Subject: [PATCH 237/641] Drop netcoreapp2.1 as a target It is no longer in its LTS lifecycle. --- azure-pipelines/dotnet.yml | 8 -------- test/Directory.Build.props | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 34db9a40b..50ba58f1d 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -14,14 +14,6 @@ steps: testRunTitle: net472-$(Agent.JobName) condition: succeededOrFailed() -- task: DotNetCoreCLI@2 - displayName: dotnet test -f netcoreapp2.1 - inputs: - command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp2.1.binlog" - testRunTitle: netcoreapp2.1-$(Agent.JobName) - condition: succeededOrFailed() - - task: DotNetCoreCLI@2 displayName: dotnet test -f netcoreapp3.1 inputs: diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 4803641a5..1b45d7162 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,7 +2,7 @@ - net5.0;netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;net472 false true From 10ed82d6504eb858dfca86b69d0b732896556e9c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Aug 2021 09:11:57 -0600 Subject: [PATCH 238/641] Suppress SA1401 (private fields) in tests --- test/.editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/.editorconfig b/test/.editorconfig index 19b19171d..8aa791bef 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -47,3 +47,6 @@ dotnet_diagnostic.CA1816.severity = silent # CA2007: Consider calling ConfigureAwait on the awaited task dotnet_diagnostic.CA2007.severity = none + +# SA1401: Fields should be private +dotnet_diagnostic.SA1401.severity = silent From f90f4949877855b010afdff5626dd238390ceb9d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Aug 2021 11:40:33 -0600 Subject: [PATCH 239/641] Touch-up on code style --- .editorconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 3f5b80ac4..0689e4e0a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -129,7 +129,7 @@ csharp_indent_switch_labels = true csharp_indent_labels = flush_left # Prefer "var" everywhere -csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_for_built_in_types = false csharp_style_var_when_type_is_apparent = true:suggestion csharp_style_var_elsewhere = false:warning @@ -167,5 +167,8 @@ dotnet_diagnostic.SA1130.severity = silent # CA1508: Avoid dead conditional code dotnet_diagnostic.CA1508.severity = warning +# IDE1006: Naming Styles - StyleCop handles these for us +dotnet_diagnostic.IDE1006.severity = none + [*.sln] indent_style = tab From 9cd3507c973ea9662b69928f0490e1e00ea447b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:48:29 -0600 Subject: [PATCH 240/641] Bump Microsoft.NET.Test.Sdk from 16.10.0 to 16.11.0 (#114) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.10.0 to 16.11.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.10.0...v16.11.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 660f9fb5b..c66b7aac2 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From ad83aa039c3868874a928c92aa886726a7623d2d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:48:43 -0600 Subject: [PATCH 241/641] Bump Microsoft.Net.Compilers.Toolset from 3.10.0 to 3.11.0 (#113) Bumps [Microsoft.Net.Compilers.Toolset](https://github.com/dotnet/roslyn) from 3.10.0 to 3.11.0. - [Release notes](https://github.com/dotnet/roslyn/releases) - [Changelog](https://github.com/dotnet/roslyn/blob/main/docs/Breaking%20API%20Changes.md) - [Commits](https://github.com/dotnet/roslyn/commits) --- updated-dependencies: - dependency-name: Microsoft.Net.Compilers.Toolset dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 125552453..c732a3a94 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -30,7 +30,7 @@ - + From 9ac560c10f1a1e4f6397519d66956f0f8bfddc3b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 1 Sep 2021 22:36:19 -0600 Subject: [PATCH 242/641] Fix SDK installation on ARM64 --- tools/Install-DotNetSdk.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 00772a9e2..67c66c1e7 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -29,6 +29,9 @@ $DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot # Look up actual required .NET Core SDK version from global.json $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1" +$arch = 'x64' +if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' } + # Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() $windowsDesktopRuntimeVersions = @() @@ -51,7 +54,7 @@ Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$P $windowsDesktopRuntimeVersions += $v } } - + # Add target frameworks of the form: netXX $targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% { $v = $Matches[1] @@ -86,7 +89,7 @@ Function Get-InstallerExe($Version, [switch]$Runtime) { $Version = $versionInfo[-1] } - Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-x64.exe" -OutDir "$DotNetInstallScriptRoot" + Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-$arch.exe" -OutDir "$DotNetInstallScriptRoot" } Function Install-DotNet($Version, [switch]$Runtime) { @@ -103,7 +106,7 @@ Function Install-DotNet($Version, [switch]$Runtime) { } $switches = @( - '-Architecture','x64' + '-Architecture',$arch ) $envVars = @{ # For locally installed dotnet, skip first time experience which takes a long time From c70330018b2f9c772ef886819baf47537214d84e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Sep 2021 15:55:41 -0600 Subject: [PATCH 243/641] Update StyleCop.Analyzers version --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index c732a3a94..277c9cde1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -35,7 +35,7 @@ - + From b2453ab34a09cfb47c3d34e8cf912af611a5283e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Sep 2021 21:07:23 -0600 Subject: [PATCH 244/641] Fix position of runsettings in .editorconfig --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 0689e4e0a..6015ff487 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,11 +20,11 @@ insert_final_newline = true trim_trailing_whitespace = true # Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,runsettings}] +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] indent_size = 2 # Xml config files -[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,runsettings}] indent_size = 2 # JSON files From eba9acb28b6c66b40a14d7759365b20a9d89df0f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 9 Sep 2021 20:49:50 -0600 Subject: [PATCH 245/641] Update .NET SDK to 5.0.400 --- .devcontainer/Dockerfile | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4e7707663..889499464 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:5.0.202-focal +FROM mcr.microsoft.com/dotnet/sdk:5.0.400-focal # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/global.json b/global.json index d28f85bf6..9f36eab1a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.302", + "version": "5.0.400", "rollForward": "patch", "allowPrerelease": false } From e94bf29eed1dc1ba106f263e2e5ac1c27aa0c096 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Sep 2021 08:59:25 -0600 Subject: [PATCH 246/641] Build on ubuntu 20.04 in Github workflows This matches what we were already doing on Azure Pipelines. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8567b4c9e..1b3b6b131 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: fail-fast: false matrix: os: - - ubuntu-18.04 + - ubuntu-20.04 - macos-latest - windows-latest From 9c06ecb7ee50f4fef66dd82ff1bbe9949e3e2d31 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Sep 2021 09:00:17 -0600 Subject: [PATCH 247/641] Publish variables, symbols and deployables from non-Windows agents too --- .github/workflows/build.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b3b6b131..b8499b90c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,9 +61,8 @@ jobs: - name: Upload variables uses: actions/upload-artifact@v1 with: - name: variables + name: variables-${{ runner.os }} path: obj/_artifacts/variables - if: runner.os == 'Windows' continue-on-error: true - name: Upload build_logs if: always() @@ -89,16 +88,15 @@ jobs: - name: Upload symbols uses: actions/upload-artifact@v1 with: - name: symbols + name: symbols-${{ runner.os }} path: obj/_artifacts/symbols - if: runner.os == 'Windows' continue-on-error: true - name: Upload deployables uses: actions/upload-artifact@v1 with: - name: deployables + name: deployables-${{ runner.os }} path: obj/_artifacts/deployables - if: always() && runner.os == 'Windows' + if: always() - name: Publish code coverage results to codecov.io run: bash <(curl -s https://codecov.io/bash) shell: bash From 4854ca17b0473bc9627bd457bcfcc03cfdf7e59c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Sep 2021 09:30:47 -0600 Subject: [PATCH 248/641] Fix up symbol collection off-Windows --- azure-pipelines/Convert-PDB.ps1 | 12 +++++++++--- azure-pipelines/Get-SymbolFiles.ps1 | 26 ++++++++++++++------------ azure-pipelines/artifacts/symbols.ps1 | 10 ++-------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/azure-pipelines/Convert-PDB.ps1 b/azure-pipelines/Convert-PDB.ps1 index 7a20305dc..2d394e72d 100644 --- a/azure-pipelines/Convert-PDB.ps1 +++ b/azure-pipelines/Convert-PDB.ps1 @@ -18,13 +18,19 @@ [string]$OutputPath ) + if ($IsMacOS -or $IsLinux) { + Write-Error "This script only works on Windows" + return + } + $version = '1.1.0-beta2-21101-01' - $baseDir = "$PSScriptRoot\..\obj\tools" - $pdb2pdbpath = "$baseDir\Microsoft.DiaSymReader.Pdb2Pdb.$version\tools\Pdb2Pdb.exe" + $baseDir = "$PSScriptRoot/../obj/tools" + $pdb2pdbpath = "$baseDir/Microsoft.DiaSymReader.Pdb2Pdb.$version/tools/Pdb2Pdb.exe" if (-not (Test-Path $pdb2pdbpath)) { if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } $baseDir = (Resolve-Path $baseDir).Path # Normalize it - & (& $PSScriptRoot\Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null + Write-Verbose "& (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null" + & (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null } $args = $DllPath,'/out',$OutputPath,'/nowarn','0021' diff --git a/azure-pipelines/Get-SymbolFiles.ps1 b/azure-pipelines/Get-SymbolFiles.ps1 index bba177f1a..45afe7c2a 100644 --- a/azure-pipelines/Get-SymbolFiles.ps1 +++ b/azure-pipelines/Get-SymbolFiles.ps1 @@ -17,7 +17,7 @@ $WindowsPdbSubDirName = "symstore" $ActivityName = "Collecting symbols from $Path" Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files" -$PDBs = Get-ChildItem -rec "$Path\*.pdb" |? { $_.FullName -notmatch "\W$WindowsPdbSubDirName\W" } +$PDBs = Get-ChildItem -rec "$Path/*.pdb" |? { $_.FullName -notmatch "\W$WindowsPdbSubDirName\W" } # Filter PDBs to product OR test related. $testregex = "unittest|tests" @@ -44,8 +44,8 @@ $PDBs |% { } } |% { # Collect the DLLs/EXEs as well. - $dllPath = "$($_.Directory)\$($_.BaseName).dll" - $exePath = "$($_.Directory)\$($_.BaseName).exe" + $dllPath = "$($_.Directory)/$($_.BaseName).dll" + $exePath = "$($_.Directory)/$($_.BaseName).exe" if (Test-Path $dllPath) { $BinaryImagePath = $dllPath } elseif (Test-Path $exePath) { @@ -54,14 +54,16 @@ $PDBs |% { Write-Output $BinaryImagePath - # Convert the PDB to legacy Windows PDBs - Write-Host "Converting PDB for $_" -ForegroundColor DarkGray - $WindowsPdbDir = "$($_.Directory.FullName)\$WindowsPdbSubDirName" - if (!(Test-Path $WindowsPdbDir)) { mkdir $WindowsPdbDir | Out-Null } - & "$PSScriptRoot\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath "$WindowsPdbDir\$($_.BaseName).pdb" - if ($LASTEXITCODE -ne 0) { - Write-Warning "PDB conversion of `"$_`" failed." - } + if (-not ($IsMacOS -or $IsLinux)) { + # Convert the PDB to legacy Windows PDBs + Write-Host "Converting PDB for $_" -ForegroundColor DarkGray + $WindowsPdbDir = "$($_.Directory.FullName)\$WindowsPdbSubDirName" + if (!(Test-Path $WindowsPdbDir)) { mkdir $WindowsPdbDir | Out-Null } + & "$PSScriptRoot\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath "$WindowsPdbDir\$($_.BaseName).pdb" + if ($LASTEXITCODE -ne 0) { + Write-Warning "PDB conversion of `"$_`" failed." + } - Write-Output "$WindowsPdbDir\$($_.BaseName).pdb" + Write-Output "$WindowsPdbDir\$($_.BaseName).pdb" + } } diff --git a/azure-pipelines/artifacts/symbols.ps1 b/azure-pipelines/artifacts/symbols.ps1 index b3451ce1e..8704571ec 100644 --- a/azure-pipelines/artifacts/symbols.ps1 +++ b/azure-pipelines/artifacts/symbols.ps1 @@ -1,11 +1,5 @@ -# This doesn't work off Windows, nor do we need to convert symbols on multiple OS agents -if ($IsMacOS -or $IsLinux) { - return; -} - -$BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\bin") -if (!(Test-Path $BinPath)) { return } -$symbolfiles = & "$PSScriptRoot\..\Get-SymbolFiles.ps1" -Path $BinPath | Get-Unique +$BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot/../../bin") +$symbolfiles = & "$PSScriptRoot/../Get-SymbolFiles.ps1" -Path $BinPath | Get-Unique @{ "$BinPath" = $SymbolFiles; From 4438c0718d81c15796eaa4cadd96352ed436825b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Sep 2021 14:27:58 -0600 Subject: [PATCH 249/641] Update to latest dotnet-install script --- tools/Install-DotNetSdk.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 67c66c1e7..73dae25fe 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -154,10 +154,10 @@ if ($DotNetInstallDir) { } if ($IsMacOS -or $IsLinux) { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/49d5da7f7d313aa65d24fe95cc29767faef553fd/src/dotnet-install.sh" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" } else { - $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/49d5da7f7d313aa65d24fe95cc29767faef553fd/src/dotnet-install.ps1" + $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.ps1" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" } From f220004889a1ac02ac55cafcc84b737be04f4ad1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Sep 2021 07:14:15 -0600 Subject: [PATCH 250/641] Capture dumps from test hangs on Mac/Linux --- .github/workflows/Linux.runsettings | 15 ++++++++++++++- .github/workflows/macOS.runsettings | 15 ++++++++++++++- azure-pipelines/Darwin.runsettings | 15 ++++++++++++++- azure-pipelines/Linux.runsettings | 15 ++++++++++++++- azure-pipelines/artifacts/testResults.ps1 | 2 +- 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Linux.runsettings b/.github/workflows/Linux.runsettings index b444e8196..5e2244a02 100644 --- a/.github/workflows/Linux.runsettings +++ b/.github/workflows/Linux.runsettings @@ -1 +1,14 @@ - + + + + + + + + + %GITHUB_WORKSPACE% + + + + + diff --git a/.github/workflows/macOS.runsettings b/.github/workflows/macOS.runsettings index b444e8196..5e2244a02 100644 --- a/.github/workflows/macOS.runsettings +++ b/.github/workflows/macOS.runsettings @@ -1 +1,14 @@ - + + + + + + + + + %GITHUB_WORKSPACE% + + + + + diff --git a/azure-pipelines/Darwin.runsettings b/azure-pipelines/Darwin.runsettings index b444e8196..0b43ecb09 100644 --- a/azure-pipelines/Darwin.runsettings +++ b/azure-pipelines/Darwin.runsettings @@ -1 +1,14 @@ - + + + + + + + + + %BUILD_ARTIFACTSTAGINGDIRECTORY% + + + + + diff --git a/azure-pipelines/Linux.runsettings b/azure-pipelines/Linux.runsettings index b444e8196..0b43ecb09 100644 --- a/azure-pipelines/Linux.runsettings +++ b/azure-pipelines/Linux.runsettings @@ -1 +1,14 @@ - + + + + + + + + + %BUILD_ARTIFACTSTAGINGDIRECTORY% + + + + + diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index 1e4c4c4e2..7895ddcaa 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -2,7 +2,7 @@ if ($env:AGENT_TEMPDIRECTORY) { # The DotNetCoreCLI uses an alternate location to publish these files $guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$' @{ - $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); + $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\dotnet*.dmp","$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); } } else { $testRoot = Resolve-Path "$PSScriptRoot\..\..\test" From da2dbc0e905c0b6045c7f51875848fa50cad9b7e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Sep 2021 07:56:31 -0600 Subject: [PATCH 251/641] Remove ResultsDirectory tag --- .github/workflows/Linux.runsettings | 2 -- .github/workflows/Windows.runsettings | 2 -- .github/workflows/macOS.runsettings | 2 -- azure-pipelines/Darwin.runsettings | 2 -- azure-pipelines/Linux.runsettings | 2 -- azure-pipelines/Windows_NT.runsettings | 2 -- 6 files changed, 12 deletions(-) diff --git a/.github/workflows/Linux.runsettings b/.github/workflows/Linux.runsettings index 5e2244a02..db20611f1 100644 --- a/.github/workflows/Linux.runsettings +++ b/.github/workflows/Linux.runsettings @@ -5,8 +5,6 @@ - - %GITHUB_WORKSPACE% diff --git a/.github/workflows/Windows.runsettings b/.github/workflows/Windows.runsettings index 5e2244a02..db20611f1 100644 --- a/.github/workflows/Windows.runsettings +++ b/.github/workflows/Windows.runsettings @@ -5,8 +5,6 @@ - - %GITHUB_WORKSPACE% diff --git a/.github/workflows/macOS.runsettings b/.github/workflows/macOS.runsettings index 5e2244a02..db20611f1 100644 --- a/.github/workflows/macOS.runsettings +++ b/.github/workflows/macOS.runsettings @@ -5,8 +5,6 @@ - - %GITHUB_WORKSPACE% diff --git a/azure-pipelines/Darwin.runsettings b/azure-pipelines/Darwin.runsettings index 0b43ecb09..db20611f1 100644 --- a/azure-pipelines/Darwin.runsettings +++ b/azure-pipelines/Darwin.runsettings @@ -5,8 +5,6 @@ - - %BUILD_ARTIFACTSTAGINGDIRECTORY% diff --git a/azure-pipelines/Linux.runsettings b/azure-pipelines/Linux.runsettings index 0b43ecb09..db20611f1 100644 --- a/azure-pipelines/Linux.runsettings +++ b/azure-pipelines/Linux.runsettings @@ -5,8 +5,6 @@ - - %BUILD_ARTIFACTSTAGINGDIRECTORY% diff --git a/azure-pipelines/Windows_NT.runsettings b/azure-pipelines/Windows_NT.runsettings index 0b43ecb09..db20611f1 100644 --- a/azure-pipelines/Windows_NT.runsettings +++ b/azure-pipelines/Windows_NT.runsettings @@ -5,8 +5,6 @@ - - %BUILD_ARTIFACTSTAGINGDIRECTORY% From ecbaf97d74980f7455d3426f0138611992acc256 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Sep 2021 08:32:30 -0600 Subject: [PATCH 252/641] Update SDK to 5.0.401 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 9f36eab1a..3057bb452 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.400", + "version": "5.0.401", "rollForward": "patch", "allowPrerelease": false } From 04544dcde313bc25a6ed33f196816d48210fade1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Sep 2021 14:31:02 -0600 Subject: [PATCH 253/641] Update Nerdbank.GitVersioning to 3.5.37-alpha This gets `msbuild -graph -isolate` working. Note when using `dotnet build` the `-graph -isolate` switches must be combined with `--no-restore` to workaround https://github.com/dotnet/msbuild/issues/6856. --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 277c9cde1..0df35e997 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -33,7 +33,7 @@ - + From f6bc832d634d56f1107a29f747159c06c32eb892 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Sep 2021 15:30:05 -0600 Subject: [PATCH 254/641] Optimize the build for just one version applied everywhere --- Directory.Build.props | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index 0df35e997..9184728d7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,6 +12,9 @@ true true + + $(MSBuildThisFileDirectory) + embedded From 934d5f208f748fcdaf99e628c36c127246af99e6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Sep 2021 15:36:27 -0600 Subject: [PATCH 255/641] Add a collection for prepended paths --- init.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.ps1 b/init.ps1 index 4cf910f26..cb86c6cac 100755 --- a/init.ps1 +++ b/init.ps1 @@ -48,6 +48,7 @@ Param ( ) $EnvVars = @{} +$PrependPath = @() if (!$NoPrerequisites) { if (!$NoNuGetCredProvider) { @@ -82,7 +83,7 @@ try { } } - & "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars | Out-Null + & "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null } catch { Write-Error $error[0] From 62687e5afd6515409d332ee7cbbba5e38ea45885 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Sep 2021 16:56:28 -0600 Subject: [PATCH 256/641] Stabilize package restore in the face of outside influences --- nuget.config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nuget.config b/nuget.config index 68f36551f..22f7b8098 100644 --- a/nuget.config +++ b/nuget.config @@ -8,4 +8,8 @@ + + + + From ccae4b2e7701f9d7236c035f33fc0d702b80271e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 3 Oct 2021 14:01:00 -0600 Subject: [PATCH 257/641] Place obj folders in the same hierarchy as the source appears in the repo This avoids inadvertent obj dir collisions when the project name matches, which tends to happen when using dirs.proj. --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 9184728d7..3b53649ad 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ Debug $(MSBuildThisFileDirectory) - $(RepoRootPath)obj\$(MSBuildProjectName)\ + $(RepoRootPath)obj\$([MSBuild]::MakeRelative($(RepoRootPath), $(MSBuildProjectDirectory)))\ $(RepoRootPath)bin\$(MSBuildProjectName)\ $(RepoRootPath)bin\Packages\$(Configuration)\ 9.0 From 26afcd2276a2b0df4157d1594c260fd264a6adcd Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 3 Oct 2021 14:01:13 -0600 Subject: [PATCH 258/641] Calculate the version just once for the whole repo --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 3b53649ad..8a8effea9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,6 +11,7 @@ true true true + $(RepoRootPath) $(MSBuildThisFileDirectory) From 392da69055086b58b6296379aa6c502a5b2ba947 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 3 Oct 2021 14:01:33 -0600 Subject: [PATCH 259/641] Opt into the WPF nuget fix in .NET 5 SDK --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 8a8effea9..6e481b01a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,6 +11,7 @@ true true true + true $(RepoRootPath) From 8094b0aac7e7ef8cb7b1c3b3cfd64455b0986973 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 8 Oct 2021 17:55:07 -0600 Subject: [PATCH 260/641] Set indent size for msbuildproj files --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 6015ff487..c561b3810 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,7 +20,7 @@ insert_final_newline = true trim_trailing_whitespace = true # Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,msbuildproj}] indent_size = 2 # Xml config files From 6cd48ff31414e2004ebb579d6a9e3e2ab4d422df Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 11 Oct 2021 15:07:39 -0600 Subject: [PATCH 261/641] Move TargetFramework properties into projects They cause more confusion and issues being imported than its worth. --- src/Directory.Build.props | 4 ---- src/Library/Library.csproj | 4 +++- test/Directory.Build.props | 1 - test/Library.Tests/Library.Tests.csproj | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 165d2ddd4..77d947658 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,3 @@ - - - netstandard2.0 - diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index 61718a1f8..4641dbd64 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -1,3 +1,5 @@ - + + netstandard2.0 + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 1b45d7162..449a06e45 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,7 +2,6 @@ - net5.0;netcoreapp3.1;net472 false true diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index c66b7aac2..9a0a5820e 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -1,6 +1,7 @@ + net5.0;netcoreapp3.1;net472 From 295a5328208e65883c9a3add6fdfdba3bd14b34a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Oct 2021 06:24:16 -0600 Subject: [PATCH 262/641] Include README in nupkg --- src/Library/Library.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index 4641dbd64..a7547da10 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -1,5 +1,9 @@ netstandard2.0 + README.md + + + From d3cb4c585962ff32716f4e6c22a3ebe905a6e8a4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Oct 2021 06:38:13 -0600 Subject: [PATCH 263/641] Revert "Include README in nupkg" This reverts commit 295a5328208e65883c9a3add6fdfdba3bd14b34a. This is due to https://github.com/NuGet/Home/issues/10791. We can reapply the readme after switching to .NET SDK 6.0. --- src/Library/Library.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index a7547da10..4641dbd64 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -1,9 +1,5 @@ netstandard2.0 - README.md - - - From 2174046dee68180b06a3de37420161cfa4566dbb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Oct 2021 06:38:42 -0600 Subject: [PATCH 264/641] Reapply "Include README in nupkg" This reverts commit d3cb4c585962ff32716f4e6c22a3ebe905a6e8a4. --- src/Library/Library.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index 4641dbd64..a7547da10 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -1,5 +1,9 @@ netstandard2.0 + README.md + + + From 5fa2a94852e82ada595c6d3a7c112670d9590493 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Oct 2021 06:51:05 -0600 Subject: [PATCH 265/641] Update to .NET 6 SDK --- Directory.Build.props | 3 +-- global.json | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6e481b01a..fac9c6770 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -34,8 +34,7 @@ - - + diff --git a/global.json b/global.json index 3057bb452..973759e1f 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "5.0.401", + "version": "6.0.100-rc.2.21505.57", "rollForward": "patch", - "allowPrerelease": false + "allowPrerelease": true } } From 346548ac0da1ae678c32af3b0381df4c34277a0b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Oct 2021 07:31:30 -0600 Subject: [PATCH 266/641] Search for .NET 5+ runtime requirements --- tools/Install-DotNetSdk.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 73dae25fe..427899307 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -47,7 +47,7 @@ Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$P } } } - $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% { + $targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% { $v = $Matches[1] $runtimeVersions += $v if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) { From ef76eb2d0d8cc2d90ce4eee2cd07d485b18ecedf Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Oct 2021 08:20:31 -0600 Subject: [PATCH 267/641] Use C# 10 syntax --- Directory.Build.props | 4 ++-- src/Library/Calculator.cs | 39 ++++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index fac9c6770..38102b59f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,8 +5,9 @@ $(RepoRootPath)obj\$([MSBuild]::MakeRelative($(RepoRootPath), $(MSBuildProjectDirectory)))\ $(RepoRootPath)bin\$(MSBuildProjectName)\ $(RepoRootPath)bin\Packages\$(Configuration)\ - 9.0 + 10.0 enable + enable latest true true @@ -34,7 +35,6 @@ - diff --git a/src/Library/Calculator.cs b/src/Library/Calculator.cs index 9156a1a34..706c341d9 100644 --- a/src/Library/Calculator.cs +++ b/src/Library/Calculator.cs @@ -1,29 +1,26 @@ // Copyright (c) COMPANY-PLACEHOLDER. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Library -{ - using System; +namespace Library; +/// +/// My first class. +/// +public static class Calculator +{ /// - /// My first class. + /// Adds two integers. /// - public static class Calculator - { - /// - /// Adds two integers. - /// - /// The first integer. - /// The second integer. - /// The sum of the two integers. - public static int Add(int a, int b) => a + b; + /// The first integer. + /// The second integer. + /// The sum of the two integers. + public static int Add(int a, int b) => a + b; - /// - /// Subtracts one integer from another. - /// - /// The original integer. - /// The integer to subtract. - /// The difference between the two integers. - public static int Subtract(int a, int b) => a - b; - } + /// + /// Subtracts one integer from another. + /// + /// The original integer. + /// The integer to subtract. + /// The difference between the two integers. + public static int Subtract(int a, int b) => a - b; } From 2cc62417f55390b6ef18b69c51fe3b1ec7dc1082 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Oct 2021 08:22:53 -0600 Subject: [PATCH 268/641] Remove WPF workaround that isn't necessary with the .NET 6 SDK --- Directory.Build.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 38102b59f..38d8582da 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,6 @@ true true true - true $(RepoRootPath) From a280dfc4ad77431e75a359b37c27886cf3a3afe7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 13:00:43 +0000 Subject: [PATCH 269/641] Bump Microsoft.NET.Test.Sdk from 16.11.0 to 17.0.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.11.0 to 17.0.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.11.0...v17.0.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 9a0a5820e..ebd5df8ff 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -11,7 +11,7 @@ - + From ab053bb6cc903ac4a48ba198f126b5e021905e33 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 2 Nov 2021 06:13:29 -0600 Subject: [PATCH 270/641] Disable default, redundant NB.GV behavior We already call `nbgv cloud` in the cloud builds, so there is no need to set certain pipeline variables with every project. In fact given a couple bugs that have come into NB.GV lately around issues on [AzP](https://github.com/dotnet/Nerdbank.GitVersioning/pull/675) or [GitHub Actions](https://github.com/dotnet/Nerdbank.GitVersioning/issues/683) around setting pipeline variables, this should improve build reliability. --- version.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/version.json b/version.json index f0da4f6a1..39add9860 100644 --- a/version.json +++ b/version.json @@ -4,5 +4,8 @@ "publicReleaseRefSpec": [ "^refs/heads/main$", "^refs/heads/v\\d+(?:\\.\\d+)?$" - ] + ], + "cloudBuild": { + "setVersionVariables": false + } } From 16d30af64f26f62e547805ebcb002b1efd3f7a6d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 2 Nov 2021 10:29:57 -0600 Subject: [PATCH 271/641] Log artifact warnings in more cases We were not warning when *groups* would be defined by an artifact collector even if all those groups were empty. --- azure-pipelines/artifacts/_all.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index efd6bdb3e..db10c5ffa 100755 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -25,10 +25,9 @@ Function EnsureTrailingSlash($path) { Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% { $ArtifactName = $_.BaseName + $totalFileCount = 0 $fileGroups = & $_ - if (!$fileGroups -or $fileGroups.Count -eq 0) { - Write-Warning "No files found for the `"$ArtifactName`" artifact." - } else { + if ($fileGroups) { $fileGroups.GetEnumerator() | % { $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key.ToString()), [UriKind]::Absolute) $_.Value | % { @@ -46,7 +45,12 @@ Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% { Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath) Write-Output $artifact + $totalFileCount += 1 } } } + + if ($totalFileCount -eq 0) { + Write-Warning "No files found for the `"$ArtifactName`" artifact." + } } From cbf38a43293df070b8dc0cf8f365e2b237f4bd22 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 8 Nov 2021 12:31:26 -0700 Subject: [PATCH 272/641] Use .NET SDK 6.0.100 GA --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 973759e1f..e2af429b5 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "6.0.100-rc.2.21505.57", + "version": "6.0.100", "rollForward": "patch", - "allowPrerelease": true + "allowPrerelease": false } } From 4582d85ab68fe930a4b2016a7351322a0e6672db Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 12 Nov 2021 08:25:49 -0700 Subject: [PATCH 273/641] Collect coverage in non-multitargeting environments --- azure-pipelines/artifacts/coverageResults.ps1 | 4 ++-- azure-pipelines/publish-codecoverage.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/artifacts/coverageResults.ps1 b/azure-pipelines/artifacts/coverageResults.ps1 index addbf85c2..8fdb3f720 100644 --- a/azure-pipelines/artifacts/coverageResults.ps1 +++ b/azure-pipelines/artifacts/coverageResults.ps1 @@ -3,7 +3,7 @@ $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") # Prepare code coverage reports for merging on another machine if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`"" - $reports = Get-ChildItem "$RepoRoot/bin/coverage.*.cobertura.xml" -Recurse + $reports = Get-ChildItem "$RepoRoot/bin/coverage.*cobertura.xml" -Recurse $reports |% { $content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" } Set-Content -Path $_ -Value $content -Encoding UTF8 @@ -16,7 +16,7 @@ if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return } @{ $RepoRoot = ( - @(Get-ChildItem "$RepoRoot\bin\coverage.*.cobertura.xml" -Recurse) + + @(Get-ChildItem "$RepoRoot\bin\coverage.*cobertura.xml" -Recurse) + (Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse) ); } diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index d83eb64ad..3667b976c 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -19,7 +19,7 @@ steps: dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.8.5 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" - $reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.*.cobertura.xml" + $reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.*cobertura.xml" $reports |% { $content = Get-Content -Path $_ |% { $_.Replace("{reporoot}", "$(System.DefaultWorkingDirectory)") } Set-Content -Path $_ -Value $content -Encoding UTF8 From 920947343737b964b1f84a4359529286bb9b869f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 18 Nov 2021 21:43:01 -0700 Subject: [PATCH 274/641] Touch-ups --- .devcontainer/Dockerfile | 2 +- .vscode/settings.json | 12 ++++++------ Directory.Build.props | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 889499464..c47acfaa9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:5.0.400-focal +FROM mcr.microsoft.com/dotnet/sdk:6.0.100-focal # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/.vscode/settings.json b/.vscode/settings.json index 00aaed88f..3ae1371c6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,8 @@ { - "files.trimTrailingWhitespace": true, - "files.insertFinalNewline": true, - "files.trimFinalNewlines": true, - "omnisharp.enableEditorConfigSupport": true, - "omnisharp.enableImportCompletion": true, - "omnisharp.enableRoslynAnalyzers": true + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "omnisharp.enableEditorConfigSupport": true, + "omnisharp.enableImportCompletion": true, + "omnisharp.enableRoslynAnalyzers": true } diff --git a/Directory.Build.props b/Directory.Build.props index 38d8582da..0ce1cbb72 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,6 @@ true true true - $(RepoRootPath) $(MSBuildThisFileDirectory) From 686e55d0f99445c0db83bdbe45d14722a5597651 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 19 Nov 2021 12:41:18 -0700 Subject: [PATCH 275/641] Add Apply-Template.ps1 script to automate template updates --- Apply-Template.ps1 | 27 +++++++++++++++++++++++++++ Expand-Template.ps1 | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Apply-Template.ps1 diff --git a/Apply-Template.ps1 b/Apply-Template.ps1 new file mode 100644 index 000000000..544b7a7c0 --- /dev/null +++ b/Apply-Template.ps1 @@ -0,0 +1,27 @@ +#!/usr/bin/env pwsh + +<# +.SYNOPSIS +Applies the template to another repo in a semi-destructive way. +Always apply to a clean working copy so that undesired updates can be easily reverted. +.PARAMETER Path +The path to the root of the repo to be updated with the latest version of this template. +#> + +[CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')] +Param( + [Parameter(Mandatory=$true)] + [ValidateScript({Test-Path $_})] + [string]$Path +) + +Write-Host "Updating $Path" +robocopy /mir $PSScriptRoot/azure-pipelines $Path/azure-pipelines +robocopy /mir $PSScriptRoot/.devcontainer $Path/.devcontainer +robocopy /mir $PSScriptRoot/.github $Path/.github +robocopy /mir $PSScriptRoot/.vscode $Path/.vscode +robocopy /mir $PSScriptRoot/tools $Path/tools +robocopy $PSScriptRoot $Path Directory.Build.* global.json init.* azure-pipelines.yml .gitignore .gitattributes .editorconfig +robocopy $PSScriptRoot/src $Path/src Directory.Build.* .editorconfig +robocopy $PSScriptRoot/test $Path/test Directory.Build.* .editorconfig +Remove-Item $Path/azure-pipelines/expand-template.yml diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index d665e56a3..9e4d49737 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -180,7 +180,7 @@ try { Replace-Placeholders -Path "azure-pipelines.yml" -Replacements $YmlReplacements # Self destruct - git rm Expand-Template.* + git rm Expand-Template.* Apply-Template.ps1 if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } git rm :/azure-pipelines/expand-template.yml if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } From 805c87a603471d8cb6af194e727304ae05d1579b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 19 Nov 2021 15:49:51 -0700 Subject: [PATCH 276/641] Build on VS 2022 agents --- azure-pipelines/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index cd39a76ab..a1f5e786d 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -1,6 +1,9 @@ parameters: - windowsPool: Hosted Windows 2019 with VS2019 - includeMacOS: +- name: windowsPool + type: object + default: + vmImage: windows-2022 +- name: includeMacOS jobs: - job: Windows From 4fb29c86e9d117361e15454ba5d82a2f4e39259b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 19 Nov 2021 16:27:20 -0700 Subject: [PATCH 277/641] Update Microsoft.SourceLink.GitHub package version --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0ce1cbb72..2e7716027 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -34,7 +34,7 @@ - + From 2eb1688704d5de2990fd51407b2ec64ac41019d3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 22 Nov 2021 15:48:47 -0700 Subject: [PATCH 278/641] Collect diagnostic test logs --- azure-pipelines/artifacts/testResults.ps1 | 20 +++++++++++++------- azure-pipelines/dotnet.yml | 6 +++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index 7895ddcaa..862155da7 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -1,12 +1,18 @@ +$result = @{} + if ($env:AGENT_TEMPDIRECTORY) { # The DotNetCoreCLI uses an alternate location to publish these files $guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$' - @{ - $env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\dotnet*.dmp","$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); - } -} else { + $result[$env:AGENT_TEMPDIRECTORY] = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\dotnet*.dmp","$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); +} +else { $testRoot = Resolve-Path "$PSScriptRoot\..\..\test" - @{ - $testRoot = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File); - } + $result[$testRoot] = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File) +} + +$testlogsPath = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\test_logs" +if (Test-Path $testlogsPath) { + $result[$testlogsPath] = Get-ChildItem "$testlogsPath\*"; } + +$result diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 50ba58f1d..70cd23ee0 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: dotnet test -f net472 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog" + arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net472.txt" testRunTitle: net472-$(Agent.JobName) condition: succeededOrFailed() @@ -18,7 +18,7 @@ steps: displayName: dotnet test -f netcoreapp3.1 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog" + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/netcoreapp3.1.txt" testRunTitle: netcoreapp3.1-$(Agent.JobName) condition: succeededOrFailed() @@ -26,7 +26,7 @@ steps: displayName: dotnet test -f net5.0 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog" + arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net5.0.txt" testRunTitle: net5.0-$(Agent.JobName) condition: succeededOrFailed() From df52bbc7da6d37808c1e0095bea0ba3e1905697d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 22 Nov 2021 15:49:06 -0700 Subject: [PATCH 279/641] Remove CA1508, which has too many false positives --- .editorconfig | 3 --- 1 file changed, 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index c561b3810..0d75b34a3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -164,9 +164,6 @@ csharp_prefer_braces = true:silent # SA1130: Use lambda syntax dotnet_diagnostic.SA1130.severity = silent -# CA1508: Avoid dead conditional code -dotnet_diagnostic.CA1508.severity = warning - # IDE1006: Naming Styles - StyleCop handles these for us dotnet_diagnostic.IDE1006.severity = none From c5db1efad8a160ec9869b4e1cf0b72b07b59526f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 25 Nov 2021 22:26:34 -0700 Subject: [PATCH 280/641] Fix ARM detection on Linux The `$env:PROCESSOR_ARCHITECTURE` environment variable simply isn't set on linux. --- tools/Install-DotNetSdk.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 427899307..f5a300a4e 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -29,8 +29,7 @@ $DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot # Look up actual required .NET Core SDK version from global.json $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1" -$arch = 'x64' -if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' } +$arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture # Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() From c9ed75c04a722207de4f79a2cb17f558b8ae4641 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 29 Nov 2021 16:17:37 -0700 Subject: [PATCH 281/641] Format whitespace in init.ps1 --- init.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/init.ps1 b/init.ps1 index cb86c6cac..774ead583 100755 --- a/init.ps1 +++ b/init.ps1 @@ -31,10 +31,10 @@ .PARAMETER AccessToken An optional access token for authenticating to Azure Artifacts authenticated feeds. #> -[CmdletBinding(SupportsShouldProcess=$true)] +[CmdletBinding(SupportsShouldProcess = $true)] Param ( - [ValidateSet('repo','user','machine')] - [string]$InstallLocality='user', + [ValidateSet('repo', 'user', 'machine')] + [string]$InstallLocality = 'user', [Parameter()] [switch]$NoPrerequisites, [Parameter()] @@ -68,8 +68,8 @@ if (!$NoPrerequisites) { } # Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines -$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20 -$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20 +$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS = 20 +$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS = 20 Push-Location $PSScriptRoot try { From b75b239dfc8258e7c5d8c60ea9b4bc338392293f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 1 Dec 2021 11:57:57 -0700 Subject: [PATCH 282/641] Suppress powershell interpreting of AzP macros --- azure-pipelines/publish-codecoverage.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 3667b976c..a0862be3f 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -18,10 +18,10 @@ steps: - powershell: | dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.8.5 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj - Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)" - $reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.*cobertura.xml" + Write-Host 'Substituting {reporoot} with $(System.DefaultWorkingDirectory)' + $reports = Get-ChildItem -Recurse '$(Pipeline.Workspace)/coverage.*cobertura.xml' $reports |% { - $content = Get-Content -Path $_ |% { $_.Replace("{reporoot}", "$(System.DefaultWorkingDirectory)") } + $content = Get-Content -Path $_ |% { $_.Replace('{reporoot}', '$(System.DefaultWorkingDirectory)') } Set-Content -Path $_ -Value $content -Encoding UTF8 } $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_ })) From e1fafe9b84943d228456c3595a547c2d62a8acc0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 2 Dec 2021 10:55:44 -0700 Subject: [PATCH 283/641] Secure p/invoke native library loads --- src/AssemblyInfo.cs | 6 ++++++ src/Directory.Build.targets | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 src/AssemblyInfo.cs diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs new file mode 100644 index 000000000..81feda271 --- /dev/null +++ b/src/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) COMPANY-PLACEHOLDER. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Runtime.InteropServices; + +[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)] diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index e7edee55a..566ab4fcf 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,3 +1,7 @@ + + + + From 1be4fa9788b5295754319602b6524de64f865a42 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 2 Dec 2021 16:50:33 -0700 Subject: [PATCH 284/641] Fix regression in platform detection in Windows Powershell --- tools/Install-DotNetSdk.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index f5a300a4e..3c82ee2b2 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -30,6 +30,10 @@ $DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1" $arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture +if (!$arch) { # Windows Powershell leaves this blank + $arch = 'x64' + if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' } +} # Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. $runtimeVersions = @() From 81634e306fd8a561434c42687ee7f3f84b4a0067 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 3 Dec 2021 06:40:03 -0700 Subject: [PATCH 285/641] Set basic version build variables in pipeline --- azure-pipelines/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index a1f5e786d..796be61d6 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -13,7 +13,7 @@ jobs: clean: true - template: install-dependencies.yml - - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud' + - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -c' displayName: Set build number - template: dotnet.yml From e4ef595f167a6848292a1c121bee85c7ae1cae09 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 3 Dec 2021 08:06:54 -0700 Subject: [PATCH 286/641] Patch AssemblyInfo.cs --- Apply-Template.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apply-Template.ps1 b/Apply-Template.ps1 index 544b7a7c0..0d3f3d8e2 100644 --- a/Apply-Template.ps1 +++ b/Apply-Template.ps1 @@ -22,6 +22,6 @@ robocopy /mir $PSScriptRoot/.github $Path/.github robocopy /mir $PSScriptRoot/.vscode $Path/.vscode robocopy /mir $PSScriptRoot/tools $Path/tools robocopy $PSScriptRoot $Path Directory.Build.* global.json init.* azure-pipelines.yml .gitignore .gitattributes .editorconfig -robocopy $PSScriptRoot/src $Path/src Directory.Build.* .editorconfig +robocopy $PSScriptRoot/src $Path/src Directory.Build.* .editorconfig AssemblyInfo.cs robocopy $PSScriptRoot/test $Path/test Directory.Build.* .editorconfig Remove-Item $Path/azure-pipelines/expand-template.yml From 52d37aebaa5b7f119810d2fba3977006f99ef289 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 3 Dec 2021 08:15:02 -0700 Subject: [PATCH 287/641] Update Nerdbank.GitVersioning --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2e7716027..3b2b143bb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -35,7 +35,7 @@ - + From c31f6ad1e0ffaf45e333da288419a9e17529f2b0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 13 Jan 2022 08:26:38 -0700 Subject: [PATCH 288/641] Fix Expand-Template to replace tokens in AssemblyInfo.cs --- Expand-Template.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Expand-Template.ps1 b/Expand-Template.ps1 index 9e4d49737..d203d85f0 100755 --- a/Expand-Template.ps1 +++ b/Expand-Template.ps1 @@ -145,6 +145,9 @@ try { 'Library'=$LibraryName 'COMPANY-PLACEHOLDER'=$Author } + Replace-Placeholders -Path "src/AssemblyInfo.cs" -Replacements @{ + 'COMPANY-PLACEHOLDER'=$Author + } Replace-Placeholders -Path "LICENSE" -Replacements @{ 'COMPANY-PLACEHOLDER'=$Author } From 6cf12a28d7447b8921e2854937ee09d1a10b8bbb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 13 Jan 2022 08:09:07 -0700 Subject: [PATCH 289/641] Enable publishing of artifacts in multiple passes When an artifact is not ready yet, but other artifacts are and must be prepared, we can now run `artifacts/_pipelines.ps1` multiple times in the pipeline. To opt out of an earlier pass, the artifact script need only produce 0 files. After an artifact script returns some files, that artifact will be published and will not be published again. This is similar to `variables/_pipelines.ps1` behavior, which we already run twice. --- azure-pipelines/artifacts/_all.ps1 | 84 ++++++++++++++---------- azure-pipelines/artifacts/_pipelines.ps1 | 5 ++ azure-pipelines/artifacts/_stage_all.ps1 | 2 +- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index db10c5ffa..afe42be30 100755 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -1,18 +1,24 @@ #!/usr/bin/env pwsh -# This script returns all the artifacts that should be collected after a build. -# -# Each powershell artifact is expressed as an object with these properties: -# Source - the full path to the source file -# ArtifactName - the name of the artifact to upload to -# ContainerFolder - the relative path within the artifact in which the file should appear -# -# Each artifact aggregating .ps1 script should return a hashtable: -# Key = path to the directory from which relative paths within the artifact should be calculated -# Value = an array of paths (absolute or relative to the BaseDirectory) to files to include in the artifact. -# FileInfo objects are also allowed. - -$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") +<# +.SYNOPSIS + This script returns all the artifacts that should be collected after a build. + Each powershell artifact is expressed as an object with these properties: + Source - the full path to the source file + ArtifactName - the name of the artifact to upload to + ContainerFolder - the relative path within the artifact in which the file should appear + Each artifact aggregating .ps1 script should return a hashtable: + Key = path to the directory from which relative paths within the artifact should be calculated + Value = an array of paths (absolute or relative to the BaseDirectory) to files to include in the artifact. + FileInfo objects are also allowed. +.PARAMETER Force + Executes artifact scripts even if they have already been uploaded. +#> + +param ( + [string]$ArtifactNameSuffix, + [switch]$Force +) Function EnsureTrailingSlash($path) { if ($path.length -gt 0 -and !$path.EndsWith('\') -and !$path.EndsWith('/')) { @@ -22,35 +28,43 @@ Function EnsureTrailingSlash($path) { $path.Replace('\', [IO.Path]::DirectorySeparatorChar) } -Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% { - $ArtifactName = $_.BaseName +Function Test-ArtifactUploaded($artifactName) { + $varName = "ARTIFACTUPLOADED_$($artifactName.ToUpper())" + Test-Path "env:$varName" +} - $totalFileCount = 0 - $fileGroups = & $_ - if ($fileGroups) { - $fileGroups.GetEnumerator() | % { - $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key.ToString()), [UriKind]::Absolute) - $_.Value | % { - if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) { - $_ = $_.FullName - } +Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse | % { + $ArtifactName = $_.BaseName + if ($Force -or !(Test-ArtifactUploaded($ArtifactName + $ArtifactNameSuffix))) { + $totalFileCount = 0 + $fileGroups = & $_ + if ($fileGroups) { + $fileGroups.GetEnumerator() | % { + $BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key.ToString()), [UriKind]::Absolute) + $_.Value | ? { $_ } | % { + if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) { + $_ = $_.FullName + } - $artifact = New-Object -TypeName PSObject - Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName + $artifact = New-Object -TypeName PSObject + Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName - $SourceFullPath = New-Object Uri ($BaseDirectory, $_) - Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath + $SourceFullPath = New-Object Uri ($BaseDirectory, $_) + Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath - $RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath)) - Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath) + $RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath)) + Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath) - Write-Output $artifact - $totalFileCount += 1 + Write-Output $artifact + $totalFileCount += 1 + } } } - } - if ($totalFileCount -eq 0) { - Write-Warning "No files found for the `"$ArtifactName`" artifact." + if ($totalFileCount -eq 0) { + Write-Warning "No files found for the `"$ArtifactName`" artifact." + } + } else { + Write-Host "Skipping $ArtifactName because it has already been uploaded." -ForegroundColor DarkGray } } diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 index 5bca7c6c1..73a3af0ac 100644 --- a/azure-pipelines/artifacts/_pipelines.ps1 +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -7,4 +7,9 @@ param ( & "$PSScriptRoot/_stage_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix |% { Write-Host "##vso[artifact.upload containerfolder=$($_.Name);artifactname=$($_.Name);]$($_.Path)" + + # Set a variable which will out-live this script so that a subsequent attempt to collect and upload artifacts + # will skip this one from a check in the _all.ps1 script. + $varName = "ARTIFACTUPLOADED_$($_.Name.ToUpper())" + Write-Host "##vso[task.setvariable variable=$varName]true" } diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index 4e6a6dbe0..4788a3f5b 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -38,7 +38,7 @@ function Create-SymbolicLink { } # Stage all artifacts -$Artifacts = & "$PSScriptRoot\_all.ps1" +$Artifacts = & "$PSScriptRoot\_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix $Artifacts |% { $DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\') $Name = "$(Split-Path $_.Source -Leaf)" From c01e120589f2d9642b78335c219f65540aad7adb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Feb 2022 08:24:29 -0700 Subject: [PATCH 290/641] Bump coverlet.msbuild from 3.1.0 to 3.1.1 (#134) Bumps [coverlet.msbuild](https://github.com/coverlet-coverage/coverlet) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/commits) --- updated-dependencies: - dependency-name: coverlet.msbuild dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index ebd5df8ff..b3fc51f0a 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From 88988319bebd9cdd5390de9f79e1000d34a24e88 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 1 Feb 2022 10:20:25 -0700 Subject: [PATCH 291/641] Update StyleCop.Analyzers Switch to the .Unstable package ID so that dependabot will help us keep it current even though it seems to be ever-unstable lately. --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3b2b143bb..f913d080b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,7 +37,7 @@ - + From ad7449bd60ea86c89861957843a7293d3b4a8e56 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 1 Feb 2022 10:52:26 -0700 Subject: [PATCH 292/641] Update sample test, which was sporting dead code --- test/Library.Tests/CalculatorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/CalculatorTests.cs b/test/Library.Tests/CalculatorTests.cs index 44e89aaa4..042e7d940 100644 --- a/test/Library.Tests/CalculatorTests.cs +++ b/test/Library.Tests/CalculatorTests.cs @@ -14,7 +14,7 @@ public CalculatorTests() public void AddOrSubtract() { // This tests aggregation of code coverage across test runs. -#if NETCOREAPP2_1 +#if NETCOREAPP3_1 Assert.Equal(3, Calculator.Add(1, 2)); #else Assert.Equal(-1, Calculator.Subtract(1, 2)); From 8ef6d0681b469e121d77080262383498fb22f96c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 2 Feb 2022 20:47:23 -0700 Subject: [PATCH 293/641] Update Nerdbank.GitVersioning --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index f913d080b..e6f1f4ad5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -35,7 +35,7 @@ - + From ae5e025248ae617c174e42fe5d934b07890f34e3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 2 Feb 2022 20:50:26 -0700 Subject: [PATCH 294/641] Add explanatory comment for using unstable stylecop id --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index e6f1f4ad5..a8f35b37b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,6 +37,7 @@ + From dcf939351c44b76905308cb5dbc85bb385e48f92 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 09:33:45 -0700 Subject: [PATCH 295/641] Capture netcoreapp3.1 TFM test crash dump naming pattern on linux --- azure-pipelines/artifacts/testResults.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index 862155da7..2f894c97b 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -3,7 +3,9 @@ $result = @{} if ($env:AGENT_TEMPDIRECTORY) { # The DotNetCoreCLI uses an alternate location to publish these files $guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$' - $result[$env:AGENT_TEMPDIRECTORY] = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\dotnet*.dmp","$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse }); + $result[$env:AGENT_TEMPDIRECTORY] = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { + Get-ChildItem "$($_.FullName)\dotnet*.dmp","$($_.FullName)\*_crashdump.dmp","$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse + }); } else { $testRoot = Resolve-Path "$PSScriptRoot\..\..\test" From 4a85ff84c82c79b9d800eadaa3a99c83b0e5ce3d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 09:12:58 -0700 Subject: [PATCH 296/641] Replace runsettings files with switches --- .github/workflows/Linux.runsettings | 12 ------------ .github/workflows/Windows.runsettings | 12 ------------ .github/workflows/build.yml | 2 +- .github/workflows/macOS.runsettings | 12 ------------ azure-pipelines/Darwin.runsettings | 12 ------------ azure-pipelines/Linux.runsettings | 12 ------------ azure-pipelines/Windows_NT.runsettings | 12 ------------ azure-pipelines/dotnet.yml | 6 +++--- 8 files changed, 4 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/Linux.runsettings delete mode 100644 .github/workflows/Windows.runsettings delete mode 100644 .github/workflows/macOS.runsettings delete mode 100644 azure-pipelines/Darwin.runsettings delete mode 100644 azure-pipelines/Linux.runsettings delete mode 100644 azure-pipelines/Windows_NT.runsettings diff --git a/.github/workflows/Linux.runsettings b/.github/workflows/Linux.runsettings deleted file mode 100644 index db20611f1..000000000 --- a/.github/workflows/Linux.runsettings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/.github/workflows/Windows.runsettings b/.github/workflows/Windows.runsettings deleted file mode 100644 index db20611f1..000000000 --- a/.github/workflows/Windows.runsettings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8499b90c..ba968ab8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ jobs: - name: pack run: dotnet pack --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog" - name: test - run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --settings "${{ github.workspace }}/.github/workflows/${{ runner.os }}.runsettings" + run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --blame-hang-timeout 30s --blame-crash" - name: Update pipeline variables based on build outputs run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh diff --git a/.github/workflows/macOS.runsettings b/.github/workflows/macOS.runsettings deleted file mode 100644 index db20611f1..000000000 --- a/.github/workflows/macOS.runsettings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/azure-pipelines/Darwin.runsettings b/azure-pipelines/Darwin.runsettings deleted file mode 100644 index db20611f1..000000000 --- a/azure-pipelines/Darwin.runsettings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/azure-pipelines/Linux.runsettings b/azure-pipelines/Linux.runsettings deleted file mode 100644 index db20611f1..000000000 --- a/azure-pipelines/Linux.runsettings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/azure-pipelines/Windows_NT.runsettings b/azure-pipelines/Windows_NT.runsettings deleted file mode 100644 index db20611f1..000000000 --- a/azure-pipelines/Windows_NT.runsettings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 70cd23ee0..506eb6450 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -10,7 +10,7 @@ steps: displayName: dotnet test -f net472 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net472.txt" + arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net472.txt;TraceLevel=info" testRunTitle: net472-$(Agent.JobName) condition: succeededOrFailed() @@ -18,7 +18,7 @@ steps: displayName: dotnet test -f netcoreapp3.1 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/netcoreapp3.1.txt" + arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/netcoreapp3.1.txt;TraceLevel=info" testRunTitle: netcoreapp3.1-$(Agent.JobName) condition: succeededOrFailed() @@ -26,7 +26,7 @@ steps: displayName: dotnet test -f net5.0 inputs: command: test - arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net5.0.txt" + arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net5.0.txt;TraceLevel=info" testRunTitle: net5.0-$(Agent.JobName) condition: succeededOrFailed() From 9fb050e9d04dc1eb1a0257c239fc557637d74efc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 12:32:40 -0700 Subject: [PATCH 297/641] Fix GitHub workflow file syntax error (#137) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba968ab8d..3be177466 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ jobs: - name: pack run: dotnet pack --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog" - name: test - run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --blame-hang-timeout 30s --blame-crash" + run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --blame-hang-timeout 30s --blame-crash - name: Update pipeline variables based on build outputs run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh From da8eef4ed65b12c824b3b2782a4c503fe1b68a4c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 12:39:56 -0700 Subject: [PATCH 298/641] Build and pack in one step --- .github/workflows/build.yml | 4 +--- azure-pipelines/dotnet.yml | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3be177466..574cf5242 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,9 +39,7 @@ jobs: run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh - name: build - run: dotnet build --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog" - - name: pack - run: dotnet pack --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog" + run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog" - name: test run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --blame-hang-timeout 30s --blame-crash - name: Update pipeline variables based on build outputs diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 506eb6450..d7469c643 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -1,11 +1,8 @@ steps: -- script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" +- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: dotnet build -- script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog" - displayName: dotnet pack - - task: DotNetCoreCLI@2 displayName: dotnet test -f net472 inputs: From 1699ddf88159c2fc54a8488592df939fb3708398 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 09:59:54 -0700 Subject: [PATCH 299/641] Replace several `DotNetCoreCLI` task with one `dotnet test` task Closes #136 --- .../Get-ArtifactsStagingDirectory.ps1 | 13 +++++++ azure-pipelines/artifacts/_stage_all.ps1 | 9 +---- azure-pipelines/dotnet-test-cloud.ps1 | 37 +++++++++++++++++++ azure-pipelines/dotnet.yml | 25 +------------ 4 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 azure-pipelines/Get-ArtifactsStagingDirectory.ps1 create mode 100644 azure-pipelines/dotnet-test-cloud.ps1 diff --git a/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 new file mode 100644 index 000000000..d96b16107 --- /dev/null +++ b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 @@ -0,0 +1,13 @@ +Param( + [switch]$CleanIfLocal +) +if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { + $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY +} else { + $ArtifactStagingFolder = Join-Path (Resolve-Path $PSScriptRoot/..) (Join-Path obj _artifacts) + if ($CleanIfLocal -and (Test-Path $ArtifactStagingFolder)) { + Remove-Item $ArtifactStagingFolder -Recurse -Force + } +} + +$ArtifactStagingFolder diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index 4788a3f5b..af398a2e6 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -7,14 +7,7 @@ param ( ) $RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..))) -if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { - $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY -} else { - $ArtifactStagingFolder = Join-Path $RepoRoot (Join-Path obj _artifacts) - if (Test-Path $ArtifactStagingFolder) { - Remove-Item $ArtifactStagingFolder -Recurse -Force - } -} +$ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1" -CleanIfLocal function Create-SymbolicLink { param ( diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 new file mode 100644 index 000000000..c8642453d --- /dev/null +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -0,0 +1,37 @@ +Param( + [string]$Configuration='Debug', + [string]$Agent='Local', + [switch]$PublishResults +) + +$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..') +$ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" + +dotnet test $RepoRoot ` + --no-build ` + -c $Configuration ` + --filter "TestCategory!=FailsInCloudTest" ` + -p:CollectCoverage=true ` + --blame-hang-timeout 30s ` + --blame-crash ` + -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` + --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` + --logger trx + +$unknownCounter = 0 +Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { + Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ + + if ($PublishResults) { + $x = [xml](Get-Content -Path $_) + $storage = $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')[0].storage -replace '\\','/' + if ($storage -match '/(?[^/]+)/(?[^/]+)\.dll$') { + $runTitle = "$($matches.lib) ($($matches.tfm), $Agent)" + } else { + $unknownCounter += 1; + $runTitle = "unknown$unknownCounter ($Agent)"; + } + + Write-Host "##vso[results.publish type=VSTest;runTitle=$runTitle;publishRunAttachments=true;resultFiles=$_;failTaskOnFailedTests=true;testRunSystem=VSTS - PTR;]" + } +} diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index d7469c643..2d2d70272 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -3,29 +3,8 @@ steps: - script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: dotnet build -- task: DotNetCoreCLI@2 - displayName: dotnet test -f net472 - inputs: - command: test - arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net472.txt;TraceLevel=info" - testRunTitle: net472-$(Agent.JobName) - condition: succeededOrFailed() - -- task: DotNetCoreCLI@2 - displayName: dotnet test -f netcoreapp3.1 - inputs: - command: test - arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/netcoreapp3.1.txt;TraceLevel=info" - testRunTitle: netcoreapp3.1-$(Agent.JobName) - condition: succeededOrFailed() - -- task: DotNetCoreCLI@2 - displayName: dotnet test -f net5.0 - inputs: - command: test - arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --blame-hang-timeout 30s --blame-crash /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog" --diag "$(Build.ArtifactStagingDirectory)/test_logs/net5.0.txt;TraceLevel=info" - testRunTitle: net5.0-$(Agent.JobName) - condition: succeededOrFailed() +- powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults + displayName: dotnet test - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true From 04f05d67b81aacbdfd9cd5c89c57425a55f2a727 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 13:29:25 -0700 Subject: [PATCH 300/641] Drop redundant build verbosity switch --- azure-pipelines/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 2d2d70272..86b7eb825 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -1,6 +1,6 @@ steps: -- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" +- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: dotnet build - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults From 849e4b8e01691f784a9a74385a225ec82c5e8068 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 15:25:48 -0700 Subject: [PATCH 301/641] Simplify Join-Path expressions --- azure-pipelines/Get-ArtifactsStagingDirectory.ps1 | 2 +- azure-pipelines/artifacts/Variables.ps1 | 8 ++++---- azure-pipelines/artifacts/_stage_all.ps1 | 3 +-- azure-pipelines/dotnet-test-cloud.ps1 | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 index d96b16107..723574f52 100644 --- a/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 +++ b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 @@ -4,7 +4,7 @@ Param( if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY } else { - $ArtifactStagingFolder = Join-Path (Resolve-Path $PSScriptRoot/..) (Join-Path obj _artifacts) + $ArtifactStagingFolder = [System.IO.Path]::GetFullPath("$PSScriptRoot/../obj/_artifacts") if ($CleanIfLocal -and (Test-Path $ArtifactStagingFolder)) { Remove-Item $ArtifactStagingFolder -Recurse -Force } diff --git a/azure-pipelines/artifacts/Variables.ps1 b/azure-pipelines/artifacts/Variables.ps1 index c6330cd38..4bc6d2165 100644 --- a/azure-pipelines/artifacts/Variables.ps1 +++ b/azure-pipelines/artifacts/Variables.ps1 @@ -2,13 +2,13 @@ # It "snaps" the values of these variables where we can compute them during the build, # and otherwise captures the scripts to run later during an Azure Pipelines environment release. -$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..))) -$ArtifactBasePath = Join-Path $RepoRoot (Join-Path obj _artifacts) +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot/../..") +$ArtifactBasePath = "$RepoRoot/obj/_artifacts" $VariablesArtifactPath = Join-Path $ArtifactBasePath variables if (-not (Test-Path $VariablesArtifactPath)) { New-Item -ItemType Directory -Path $VariablesArtifactPath | Out-Null } # Copy variables, either by value if the value is calculable now, or by script -Get-ChildItem -Path (Join-Path $PSScriptRoot (Join-Path .. variables)) |% { +Get-ChildItem "$PSScriptRoot/../variables" |% { $value = $null if (-not $_.BaseName.StartsWith('_')) { # Skip trying to interpret special scripts # First check the environment variables in case the variable was set in a queued build @@ -35,7 +35,7 @@ Get-ChildItem -Path (Join-Path $PSScriptRoot (Join-Path .. variables)) |% { $value = Get-Content -Path $_.FullName } - Set-Content -Path (Join-Path $VariablesArtifactPath $_.Name) -Value $value + Set-Content -Path "$VariablesArtifactPath/$($_.Name)" -Value $value } @{ diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index af398a2e6..87421d56a 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -6,7 +6,6 @@ param ( [string]$ArtifactNameSuffix ) -$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..))) $ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1" -CleanIfLocal function Create-SymbolicLink { @@ -33,7 +32,7 @@ function Create-SymbolicLink { # Stage all artifacts $Artifacts = & "$PSScriptRoot\_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix $Artifacts |% { - $DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\') + $DestinationFolder = [System.IO.Path]::GetFullPath("$ArtifactStagingFolder/$($_.ArtifactName)$ArtifactNameSuffix/$($_.ContainerFolder)").TrimEnd('\') $Name = "$(Split-Path $_.Source -Leaf)" #Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index c8642453d..a7a63a02b 100644 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -4,7 +4,7 @@ Param( [switch]$PublishResults ) -$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..') +$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" dotnet test $RepoRoot ` From e9df7075913bfea945429fa29f1322c2fcdc6e30 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 16:11:09 -0700 Subject: [PATCH 302/641] Collect and publish symbols from every build agent Accommodates https://github.com/microsoft/azure-pipelines-tasks/issues/13821 by publish symbols on a Windows agent Closes #135 --- azure-pipelines/Convert-PDB.ps1 | 43 ---------------- azure-pipelines/Get-SymbolFiles.ps1 | 20 ++------ azure-pipelines/artifacts/symbols.ps1 | 1 + azure-pipelines/artifacts/test_symbols.ps1 | 9 +--- azure-pipelines/build.yml | 6 ++- azure-pipelines/dotnet.yml | 18 ------- azure-pipelines/publish-symbols.yml | 59 ++++++++++++++++++++++ 7 files changed, 70 insertions(+), 86 deletions(-) delete mode 100644 azure-pipelines/Convert-PDB.ps1 create mode 100644 azure-pipelines/publish-symbols.yml diff --git a/azure-pipelines/Convert-PDB.ps1 b/azure-pipelines/Convert-PDB.ps1 deleted file mode 100644 index 2d394e72d..000000000 --- a/azure-pipelines/Convert-PDB.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -<# -.SYNOPSIS - Converts between Windows PDB and Portable PDB formats. -.PARAMETER DllPath - The path to the DLL whose PDB is to be converted. -.PARAMETER PdbPath - The path to the PDB to convert. May be omitted if the DLL was compiled on this machine and the PDB is still at its original path. -.PARAMETER OutputPath - The path of the output PDB to write. -#> -#Function Convert-PortableToWindowsPDB() { - Param( - [Parameter(Mandatory=$true,Position=0)] - [string]$DllPath, - [Parameter()] - [string]$PdbPath, - [Parameter(Mandatory=$true,Position=1)] - [string]$OutputPath - ) - - if ($IsMacOS -or $IsLinux) { - Write-Error "This script only works on Windows" - return - } - - $version = '1.1.0-beta2-21101-01' - $baseDir = "$PSScriptRoot/../obj/tools" - $pdb2pdbpath = "$baseDir/Microsoft.DiaSymReader.Pdb2Pdb.$version/tools/Pdb2Pdb.exe" - if (-not (Test-Path $pdb2pdbpath)) { - if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } - $baseDir = (Resolve-Path $baseDir).Path # Normalize it - Write-Verbose "& (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null" - & (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null - } - - $args = $DllPath,'/out',$OutputPath,'/nowarn','0021' - if ($PdbPath) { - $args += '/pdb',$PdbPath - } - - Write-Verbose "$pdb2pdbpath $args" - & $pdb2pdbpath $args -#} diff --git a/azure-pipelines/Get-SymbolFiles.ps1 b/azure-pipelines/Get-SymbolFiles.ps1 index 45afe7c2a..d4c5289ae 100644 --- a/azure-pipelines/Get-SymbolFiles.ps1 +++ b/azure-pipelines/Get-SymbolFiles.ps1 @@ -1,10 +1,10 @@ <# .SYNOPSIS - Collect the list of PDBs built in this repo, after converting them from portable to Windows PDBs. + Collect the list of PDBs built in this repo. .PARAMETER Path - The root path to recursively search for PDBs. + The directory to recursively search for PDBs. .PARAMETER Tests - A switch indicating to find test-related PDBs instead of product-only PDBs. + A switch indicating to find PDBs only for test binaries instead of only for shipping shipping binaries. #> [CmdletBinding()] param ( @@ -53,17 +53,5 @@ $PDBs |% { } Write-Output $BinaryImagePath - - if (-not ($IsMacOS -or $IsLinux)) { - # Convert the PDB to legacy Windows PDBs - Write-Host "Converting PDB for $_" -ForegroundColor DarkGray - $WindowsPdbDir = "$($_.Directory.FullName)\$WindowsPdbSubDirName" - if (!(Test-Path $WindowsPdbDir)) { mkdir $WindowsPdbDir | Out-Null } - & "$PSScriptRoot\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath "$WindowsPdbDir\$($_.BaseName).pdb" - if ($LASTEXITCODE -ne 0) { - Write-Warning "PDB conversion of `"$_`" failed." - } - - Write-Output "$WindowsPdbDir\$($_.BaseName).pdb" - } + Write-Output $_.FullName } diff --git a/azure-pipelines/artifacts/symbols.ps1 b/azure-pipelines/artifacts/symbols.ps1 index 8704571ec..9e2c7bd5b 100644 --- a/azure-pipelines/artifacts/symbols.ps1 +++ b/azure-pipelines/artifacts/symbols.ps1 @@ -1,4 +1,5 @@ $BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot/../../bin") +if (!(Test-Path $BinPath)) { return } $symbolfiles = & "$PSScriptRoot/../Get-SymbolFiles.ps1" -Path $BinPath | Get-Unique @{ diff --git a/azure-pipelines/artifacts/test_symbols.ps1 b/azure-pipelines/artifacts/test_symbols.ps1 index d65ad0ae5..ce2b6481c 100644 --- a/azure-pipelines/artifacts/test_symbols.ps1 +++ b/azure-pipelines/artifacts/test_symbols.ps1 @@ -1,11 +1,6 @@ -# This doesn't work off Windows, nor do we need to convert symbols on multiple OS agents -if ($IsMacOS -or $IsLinux) { - return; -} - -$BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\bin") +$BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot/../../bin") if (!(Test-Path $BinPath)) { return } -$symbolfiles = & "$PSScriptRoot\..\Get-SymbolFiles.ps1" -Path $BinPath -Tests | Get-Unique +$symbolfiles = & "$PSScriptRoot/../Get-SymbolFiles.ps1" -Path $BinPath -Tests | Get-Unique @{ "$BinPath" = $SymbolFiles; diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 796be61d6..f779fd12c 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -45,8 +45,7 @@ jobs: - Windows - Linux - macOS - pool: - vmImage: Ubuntu 20.04 + pool: ${{ parameters.windowsPool }} # Use Windows agent because PublishSymbols task requires it (https://github.com/microsoft/azure-pipelines-tasks/issues/13821). condition: succeededOrFailed() steps: - checkout: self @@ -54,6 +53,9 @@ jobs: - template: install-dependencies.yml parameters: initArgs: -NoRestore + - template: publish-symbols.yml + parameters: + includeMacOS: ${{ parameters.includeMacOS }} - template: publish-codecoverage.yml parameters: includeMacOS: ${{ parameters.includeMacOS }} diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 86b7eb825..a103adfd3 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -16,24 +16,6 @@ steps: displayName: Publish artifacts condition: succeededOrFailed() -- task: PublishSymbols@2 - inputs: - SymbolsFolder: $(Build.ArtifactStagingDirectory)/symbols-$(Agent.JobName) - SearchPattern: '**/*.pdb' - IndexSources: false - SymbolServerType: TeamServices - displayName: Publish symbols to symbol server - condition: eq(variables['Agent.OS'], 'Windows_NT') # Execute on failed test runs too. Windows-only till https://github.com/microsoft/azure-pipelines-tasks/issues/13821 is fixed. - -- task: PublishSymbols@2 - inputs: - SymbolsFolder: $(Build.ArtifactStagingDirectory)/test_symbols-$(Agent.JobName) - SearchPattern: '**/*.pdb' - IndexSources: false - SymbolServerType: TeamServices - displayName: Publish test symbols to symbol server - condition: and(failed(), eq(variables['Agent.OS'], 'Windows_NT')) # Execute on failed test runs only. - - bash: bash <(curl -s https://codecov.io/bash) displayName: Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') diff --git a/azure-pipelines/publish-symbols.yml b/azure-pipelines/publish-symbols.yml new file mode 100644 index 000000000..c45eff020 --- /dev/null +++ b/azure-pipelines/publish-symbols.yml @@ -0,0 +1,59 @@ +parameters: + includeMacOS: + +steps: +- task: DownloadPipelineArtifact@2 + inputs: + artifact: symbols-Windows + path: $(Pipeline.Workspace)/symbols/Windows + displayName: Download Windows symbols + continueOnError: true +- task: DownloadPipelineArtifact@2 + inputs: + artifact: symbols-Linux + path: $(Pipeline.Workspace)/symbols/Linux + displayName: Download Linux symbols + continueOnError: true +- task: DownloadPipelineArtifact@2 + inputs: + artifact: symbols-macOS + path: $(Pipeline.Workspace)/symbols/macOS + displayName: Download macOS symbols + continueOnError: true + condition: ${{ parameters.includeMacOS }} + +- task: DownloadPipelineArtifact@2 + inputs: + artifact: test_symbols-Windows + path: $(Pipeline.Workspace)/test_symbols/Windows + displayName: Download Windows test symbols + continueOnError: true +- task: DownloadPipelineArtifact@2 + inputs: + artifact: test_symbols-Linux + path: $(Pipeline.Workspace)/test_symbols/Linux + displayName: Download Linux test symbols + continueOnError: true +- task: DownloadPipelineArtifact@2 + inputs: + artifact: test_symbols-macOS + path: $(Pipeline.Workspace)/test_symbols/macOS + displayName: Download macOS test symbols + continueOnError: true + condition: ${{ parameters.includeMacOS }} + +- task: PublishSymbols@2 + inputs: + SymbolsFolder: $(Pipeline.Workspace)/symbols + SearchPattern: '**/*.pdb' + IndexSources: false + SymbolServerType: TeamServices + displayName: Publish symbols + +- task: PublishSymbols@2 + inputs: + SymbolsFolder: $(Pipeline.Workspace)/test_symbols + SearchPattern: '**/*.pdb' + IndexSources: false + SymbolServerType: TeamServices + displayName: Publish test symbols From 6ecd99be42bc60e4bb359e84e9ec12dadc863403 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 16:20:49 -0700 Subject: [PATCH 303/641] Do not include product symbols with test symbols --- azure-pipelines/Get-SymbolFiles.ps1 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/azure-pipelines/Get-SymbolFiles.ps1 b/azure-pipelines/Get-SymbolFiles.ps1 index d4c5289ae..fccb1bb13 100644 --- a/azure-pipelines/Get-SymbolFiles.ps1 +++ b/azure-pipelines/Get-SymbolFiles.ps1 @@ -13,19 +13,12 @@ param ( [switch]$Tests ) -$WindowsPdbSubDirName = "symstore" - $ActivityName = "Collecting symbols from $Path" Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files" -$PDBs = Get-ChildItem -rec "$Path/*.pdb" |? { $_.FullName -notmatch "\W$WindowsPdbSubDirName\W" } +$PDBs = Get-ChildItem -rec "$Path/*.pdb" # Filter PDBs to product OR test related. $testregex = "unittest|tests" -if ($Tests) { - $PDBs = $PDBs |? { $_.FullName -match $testregex } -} else { - $PDBs = $PDBs |? { $_.FullName -notmatch $testregex } -} Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" $PDBsByHash = @{} @@ -42,6 +35,12 @@ $PDBs |% { $PDBsByHash.Add($_.Hash, $_.FullName) Write-Output $_ } +} |? { + if ($Tests) { + $_.FullName -match $testregex + } else { + $_.FullName -notmatch $testregex + } } |% { # Collect the DLLs/EXEs as well. $dllPath = "$($_.Directory)/$($_.BaseName).dll" From e67a6e4b39d1625ebcea0dcf89f34c458984e1d4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 17:38:54 -0700 Subject: [PATCH 304/641] Update GitHub Actions to more closely resemble AzP --- .github/workflows/build.yml | 31 +++++++++++++------ .../Get-ArtifactsStagingDirectory.ps1 | 2 ++ azure-pipelines/artifacts/build_logs.ps1 | 11 ++----- azure-pipelines/dotnet-test-cloud.ps1 | 2 ++ 4 files changed, 29 insertions(+), 17 deletions(-) mode change 100644 => 100755 azure-pipelines/dotnet-test-cloud.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 574cf5242..18ae3e289 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,14 +34,20 @@ jobs: run: | ./init.ps1 -UpgradePrerequisites dotnet --info + + # Print mono version if it is present. + if (Get-Command mono -ErrorAction SilentlyContinue) { + mono --version + } shell: pwsh - name: Set pipeline variables based on source run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh - name: build - run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog" + run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"${{ runner.temp }}/_artifacts/build_logs/build.binlog" - name: test - run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --blame-hang-timeout 30s --blame-crash + run: azure-pipelines/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} + shell: pwsh - name: Update pipeline variables based on build outputs run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh @@ -54,46 +60,53 @@ jobs: uses: actions/upload-artifact@v1 with: name: projectAssetsJson-${{ runner.os }} - path: obj/_artifacts/projectAssetsJson + path: ${{ runner.temp }}/_artifacts/projectAssetsJson continue-on-error: true - name: Upload variables uses: actions/upload-artifact@v1 with: name: variables-${{ runner.os }} - path: obj/_artifacts/variables + path: ${{ runner.temp }}/_artifacts/Variables continue-on-error: true - name: Upload build_logs if: always() uses: actions/upload-artifact@v1 with: name: build_logs-${{ runner.os }} - path: obj/_artifacts/build_logs + path: ${{ runner.temp }}/_artifacts/build_logs + continue-on-error: true + - name: Upload test_logs + if: always() + uses: actions/upload-artifact@v1 + with: + name: test_logs-${{ runner.os }} + path: ${{ runner.temp }}/_artifacts/test_logs continue-on-error: true - name: Upload testResults if: always() uses: actions/upload-artifact@v1 with: name: testResults-${{ runner.os }} - path: obj/_artifacts/testResults + path: ${{ runner.temp }}/_artifacts/testResults continue-on-error: true - name: Upload coverageResults if: always() uses: actions/upload-artifact@v1 with: name: coverageResults-${{ runner.os }} - path: obj/_artifacts/coverageResults + path: ${{ runner.temp }}/_artifacts/coverageResults continue-on-error: true - name: Upload symbols uses: actions/upload-artifact@v1 with: name: symbols-${{ runner.os }} - path: obj/_artifacts/symbols + path: ${{ runner.temp }}/_artifacts/symbols continue-on-error: true - name: Upload deployables uses: actions/upload-artifact@v1 with: name: deployables-${{ runner.os }} - path: obj/_artifacts/deployables + path: ${{ runner.temp }}/_artifacts/deployables if: always() - name: Publish code coverage results to codecov.io run: bash <(curl -s https://codecov.io/bash) diff --git a/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 index 723574f52..391e5713a 100644 --- a/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 +++ b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 @@ -3,6 +3,8 @@ Param( ) if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY +} elseif ($env:RUNNER_TEMP) { + $ArtifactStagingFolder = "$env:RUNNER_TEMP\_artifacts" } else { $ArtifactStagingFolder = [System.IO.Path]::GetFullPath("$PSScriptRoot/../obj/_artifacts") if ($CleanIfLocal -and (Test-Path $ArtifactStagingFolder)) { diff --git a/azure-pipelines/artifacts/build_logs.ps1 b/azure-pipelines/artifacts/build_logs.ps1 index b55ba48f3..f05358e03 100644 --- a/azure-pipelines/artifacts/build_logs.ps1 +++ b/azure-pipelines/artifacts/build_logs.ps1 @@ -1,12 +1,7 @@ -if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { - $artifactsRoot = $env:BUILD_ARTIFACTSTAGINGDIRECTORY -} else { - $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") - $artifactsRoot = "$RepoRoot\bin" -} +$ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1" -if (!(Test-Path $artifactsRoot/build_logs)) { return } +if (!(Test-Path $ArtifactStagingFolder/build_logs)) { return } @{ - "$artifactsRoot/build_logs" = (Get-ChildItem -Recurse "$artifactsRoot/build_logs") + "$ArtifactStagingFolder/build_logs" = (Get-ChildItem -Recurse "$ArtifactStagingFolder/build_logs") } diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 old mode 100644 new mode 100755 index a7a63a02b..440bd8909 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/env pwsh + Param( [string]$Configuration='Debug', [string]$Agent='Local', From 8a837f711324dce3d66570271c9cc3a62dc8e2d0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 17 Feb 2022 09:09:17 -0700 Subject: [PATCH 305/641] Activate msbuild 17's platform negotiation feature Not that this template repo itself requires it, but it's a great baseline to start with as it means the repo will grow nicely as it gets more complicated for real projects. --- Directory.Build.props | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index a8f35b37b..935550c9e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,6 +13,10 @@ true true + + true + true + $(MSBuildThisFileDirectory) @@ -35,7 +39,7 @@ - + From a803831c66647bb775cf1febd2117966ad6b801d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 07:12:33 -0700 Subject: [PATCH 306/641] Bump Microsoft.NET.Test.Sdk from 17.0.0 to 17.1.0 (#143) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.0.0 to 17.1.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.0.0...v17.1.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index b3fc51f0a..e75f6ae8f 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -11,7 +11,7 @@ - + From 25fa06401e58cdd3037106914d3e9febe230f80f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 14:25:10 +0000 Subject: [PATCH 307/641] Bump coverlet.msbuild from 3.1.1 to 3.1.2 (#144) --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index e75f6ae8f..077d8d8f9 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From f1581aacb92bda75bce2bd68ed44a698f2bf1884 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 8 Mar 2022 09:02:53 -0700 Subject: [PATCH 308/641] Update .NET SDK to 6.0.200 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index e2af429b5..6bfbd1775 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "6.0.200", "rollForward": "patch", "allowPrerelease": false } From cfa18ae4623dae6215f666d02acd2d7cb856a3c6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 9 Mar 2022 17:14:01 -0700 Subject: [PATCH 309/641] Re-enable transitive P2Ps Because it isn't actually required for msbuild platform negotiation. --- Directory.Build.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 935550c9e..e70a74bb2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,7 +15,6 @@ true - true $(MSBuildThisFileDirectory) From e92074087c0087bcbdcbfe7bf86030d9f09f1bde Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 25 Mar 2022 09:22:42 -0600 Subject: [PATCH 310/641] Improve TargetFramework detection --- tools/Install-DotNetSdk.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 3c82ee2b2..d1da42503 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -42,12 +42,12 @@ Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*proj","$P $projXml = [xml](Get-Content -Path $_) $pg = $projXml.Project.PropertyGroup if ($pg) { - $targetFrameworks = $pg.TargetFramework - if (!$targetFrameworks) { - $targetFrameworks = $pg.TargetFrameworks - if ($targetFrameworks) { - $targetFrameworks = $targetFrameworks -Split ';' - } + $targetFrameworks = @() + $tf = $pg.TargetFramework + $targetFrameworks += $tf + $tfs = $pg.TargetFrameworks + if ($tfs) { + $targetFrameworks = $tfs -Split ';' } } $targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% { From 7e34288f4cf0fbb6f1f86c7a05199a7330b50eda Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 30 Mar 2022 07:20:08 -0600 Subject: [PATCH 311/641] Fix Install-DotNetSdk.ps1 for Windows machine-wide installations --- tools/Install-DotNetSdk.ps1 | 44 +++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 3c82ee2b2..6b584f1cf 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -72,6 +72,7 @@ Function Get-FileFromWeb([Uri]$Uri, $OutDir) { $OutFile = Join-Path $OutDir $Uri.Segments[-1] if (!(Test-Path $OutFile)) { Write-Verbose "Downloading $Uri..." + if (!(Test-Path $OutDir)) { mkdir $OutDir } try { (New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile) } finally { @@ -87,12 +88,51 @@ Function Get-InstallerExe($Version, [switch]$Runtime) { if ($Runtime) { $sdkOrRuntime = 'Runtime' } # Get the latest/actual version for the specified one - if (([Version]$Version).Build -eq -1) { + $TypedVersion = [Version]$Version + if ($TypedVersion.Build -eq -1) { $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/latest.version" -UseBasicParsing) $Version = $versionInfo[-1] } - Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-$arch.exe" -OutDir "$DotNetInstallScriptRoot" + $majorMinor = "$($TypedVersion.Major).$($TypedVersion.Minor)" + $ReleasesFile = Join-Path $DotNetInstallScriptRoot "$majorMinor\releases.json" + if (!(Test-Path $ReleasesFile)) { + Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/$majorMinor/releases.json" -OutDir (Split-Path $ReleasesFile) + } + + $releases = Get-Content $ReleasesFile | ConvertFrom-Json + $url = $null + foreach ($release in $releases.releases) { + $filesElement = $null + if ($Runtime) { + if ($release.runtime.version -eq $Version) { + $filesElement = $release.runtime.files + } + } else { + if ($release.sdk.version -eq $Version) { + $filesElement = $release.sdk.files + } + } + + if ($filesElement) { + foreach ($file in $filesElement) { + if ($file.rid -eq "win-$arch") { + $url = $file.url + Break + } + } + + if ($url) { + Break + } + } + } + + if ($url) { + Get-FileFromWeb -Uri $url -OutDir $DotNetInstallScriptRoot + } else { + Write-Error "Unable to find release of $sdkOrRuntime v$Version" + } } Function Install-DotNet($Version, [switch]$Runtime) { From 3aeff335e600bb8968e1fd7d1eb2d9a05900c328 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 30 Mar 2022 18:13:34 -0600 Subject: [PATCH 312/641] Ignore launchSettings.json --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d060a300b..716456084 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.user *.userosscache *.sln.docstates +launchSettings.json # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs From b917529de6555deb96fbcccda3ce986659259cd9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 31 Mar 2022 07:50:18 -0600 Subject: [PATCH 313/641] Replace deployments with ordinary jobs --- azure-pipelines/release.yml | 87 +++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index bfe5987cd..029b654df 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -13,60 +13,51 @@ stages: - stage: GitHubRelease displayName: GitHub Release jobs: - - deployment: create + - job: create pool: vmImage: ubuntu-latest - environment: No-Approval - strategy: - runOnce: - deploy: - steps: - - download: none - - powershell: | - Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" - displayName: Set pipeline name - - task: GitHubRelease@1 - displayName: GitHub release (create) - inputs: - gitHubConnection: # TODO: fill in service connection here - repositoryName: $(Build.Repository.Name) - target: $(resources.pipeline.CI.sourceCommit) - tagSource: userSpecifiedTag - tag: v$(resources.pipeline.CI.runName) - title: v$(resources.pipeline.CI.runName) - isDraft: true # After running this step, visit the new draft release, edit, and publish. - changeLogCompareToRelease: lastNonDraftRelease - changeLogType: issueBased - changeLogLabels: | - [ - { "label" : "bug", "displayName" : "Fixes", "state" : "closed" }, - { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } - ] + steps: + - powershell: | + Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" + displayName: Set pipeline name + - task: GitHubRelease@1 + displayName: GitHub release (create) + inputs: + gitHubConnection: # TODO: fill in service connection here + repositoryName: $(Build.Repository.Name) + target: $(resources.pipeline.CI.sourceCommit) + tagSource: userSpecifiedTag + tag: v$(resources.pipeline.CI.runName) + title: v$(resources.pipeline.CI.runName) + isDraft: true # After running this step, visit the new draft release, edit, and publish. + changeLogCompareToRelease: lastNonDraftRelease + changeLogType: issueBased + changeLogLabels: | + [ + { "label" : "bug", "displayName" : "Fixes", "state" : "closed" }, + { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } + ] - stage: nuget_org displayName: nuget.org dependsOn: GitHubRelease jobs: - - deployment: push + - job: push pool: vmImage: ubuntu-latest - environment: No-Approval - strategy: - runOnce: - deploy: - steps: - - download: CI - artifact: deployables-Windows - displayName: Download deployables-Windows artifact - patterns: 'deployables-Windows/*' - - task: NuGetToolInstaller@1 - displayName: Use NuGet 5.x - inputs: - versionSpec: 5.x - - task: NuGetCommand@2 - displayName: NuGet push - inputs: - command: push - packagesToPush: $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg - nuGetFeedType: external - publishFeedCredentials: # TODO: fill in service connection here + steps: + - download: CI + artifact: deployables-Windows + displayName: Download deployables-Windows artifact + patterns: 'deployables-Windows/*' + - task: NuGetToolInstaller@1 + displayName: Use NuGet 5.x + inputs: + versionSpec: 5.x + - task: NuGetCommand@2 + displayName: NuGet push + inputs: + command: push + packagesToPush: $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg + nuGetFeedType: external + publishFeedCredentials: # TODO: fill in service connection here From efe7fddda409bb2241a6a6aacdd1a91367c1585d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 31 Mar 2022 09:15:01 -0600 Subject: [PATCH 314/641] Simplify release and CI package push --- azure-pipelines.yml | 2 +- azure-pipelines/publish-deployables.yml | 13 +--- azure-pipelines/release.yml | 90 +++++++++++-------------- 3 files changed, 41 insertions(+), 64 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a1435d918..fe8363a2d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,7 +22,7 @@ variables: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BuildConfiguration: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ - ci_feed: CI # Azure Artifacts feed name + ci_feed: https://pkgs.dev.azure.com/andrewarnott/_packaging/CI/nuget/v3/index.json # Azure Artifacts feed URL NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages jobs: diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml index a4f8e593f..f8c1dfc9d 100644 --- a/azure-pipelines/publish-deployables.yml +++ b/azure-pipelines/publish-deployables.yml @@ -3,17 +3,6 @@ steps: displayName: Download deployables artifact: deployables-Windows -- task: NuGetToolInstaller@1 - displayName: Use NuGet 5.x - inputs: - versionSpec: 5.x - -- task: NuGetCommand@2 +- script: dotnet nuget push $(Pipeline.Workspace)/deployables-Windows/*.nupkg -s $(ci_feed) -k azdo --skip-duplicate displayName: Push packages to CI feed - inputs: - command: push - packagesToPush: $(Pipeline.Workspace)/deployables-Windows/*.nupkg - nuGetFeedType: internal - publishVstsFeed: $(ci_feed) - allowPackageConflicts: true condition: and(succeeded(), ne(variables['ci_feed'], ''), ne(variables['Build.Reason'], 'PullRequest')) diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index 029b654df..205c514bf 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -9,55 +9,43 @@ resources: tags: - auto-release -stages: -- stage: GitHubRelease - displayName: GitHub Release - jobs: - - job: create - pool: - vmImage: ubuntu-latest - steps: - - powershell: | - Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" - displayName: Set pipeline name - - task: GitHubRelease@1 - displayName: GitHub release (create) - inputs: - gitHubConnection: # TODO: fill in service connection here - repositoryName: $(Build.Repository.Name) - target: $(resources.pipeline.CI.sourceCommit) - tagSource: userSpecifiedTag - tag: v$(resources.pipeline.CI.runName) - title: v$(resources.pipeline.CI.runName) - isDraft: true # After running this step, visit the new draft release, edit, and publish. - changeLogCompareToRelease: lastNonDraftRelease - changeLogType: issueBased - changeLogLabels: | - [ - { "label" : "bug", "displayName" : "Fixes", "state" : "closed" }, - { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } - ] +variables: +- group: Publishing secrets -- stage: nuget_org - displayName: nuget.org - dependsOn: GitHubRelease - jobs: - - job: push - pool: - vmImage: ubuntu-latest - steps: - - download: CI - artifact: deployables-Windows - displayName: Download deployables-Windows artifact - patterns: 'deployables-Windows/*' - - task: NuGetToolInstaller@1 - displayName: Use NuGet 5.x - inputs: - versionSpec: 5.x - - task: NuGetCommand@2 - displayName: NuGet push - inputs: - command: push - packagesToPush: $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg - nuGetFeedType: external - publishFeedCredentials: # TODO: fill in service connection here +jobs: +- job: release + pool: + vmImage: ubuntu-latest + steps: + - checkout: none + - powershell: Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" + displayName: Set pipeline name + - task: UseDotNet@2 + displayName: Install .NET SDK + inputs: + packageType: sdk + version: 6.x + - task: GitHubRelease@1 + displayName: GitHub release (create) + inputs: + gitHubConnection: # TODO: fill in service connection here + repositoryName: $(Build.Repository.Name) + target: $(resources.pipeline.CI.sourceCommit) + tagSource: userSpecifiedTag + tag: v$(resources.pipeline.CI.runName) + title: v$(resources.pipeline.CI.runName) + isDraft: true # After running this step, visit the new draft release, edit, and publish. + changeLogCompareToRelease: lastNonDraftRelease + changeLogType: issueBased + changeLogLabels: | + [ + { "label" : "bug", "displayName" : "Fixes", "state" : "closed" }, + { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } + ] + - download: CI + artifact: deployables-Windows + displayName: Download deployables-Windows artifact + patterns: 'deployables-Windows/*' + - script: dotnet nuget push $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg -s https://api.nuget.org/v3/index.json --api-key $(NuGetOrgApiKey) --skip-duplicate + displayName: Push nuget packages + condition: and(succeeded(), ne(variables['NuGetOrgApiKey'], '')) From 52dcdc720bd044be13fa99e29d6d94b94d120559 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 31 Mar 2022 09:28:40 -0600 Subject: [PATCH 315/641] GitHub release enhancements - Set GitHub release prerelease flag - Include deployables as release artifacts --- azure-pipelines/release.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index 205c514bf..437ee65bb 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -18,13 +18,23 @@ jobs: vmImage: ubuntu-latest steps: - checkout: none - - powershell: Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" - displayName: Set pipeline name + - powershell: | + Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" + if ('$(resources.pipeline.CI.runName)'.Contains('-')) { + Write-Host "##vso[task.setvariable variable=IsPrerelease]true" + } else { + Write-Host "##vso[task.setvariable variable=IsPrerelease]false" + } + displayName: Set up pipeline - task: UseDotNet@2 displayName: Install .NET SDK inputs: packageType: sdk version: 6.x + - download: CI + artifact: deployables-Windows + displayName: Download deployables-Windows artifact + patterns: 'deployables-Windows/*' - task: GitHubRelease@1 displayName: GitHub release (create) inputs: @@ -35,6 +45,8 @@ jobs: tag: v$(resources.pipeline.CI.runName) title: v$(resources.pipeline.CI.runName) isDraft: true # After running this step, visit the new draft release, edit, and publish. + isPreRelease: $(IsPrerelease) + assets: $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg changeLogCompareToRelease: lastNonDraftRelease changeLogType: issueBased changeLogLabels: | @@ -42,10 +54,6 @@ jobs: { "label" : "bug", "displayName" : "Fixes", "state" : "closed" }, { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } ] - - download: CI - artifact: deployables-Windows - displayName: Download deployables-Windows artifact - patterns: 'deployables-Windows/*' - script: dotnet nuget push $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg -s https://api.nuget.org/v3/index.json --api-key $(NuGetOrgApiKey) --skip-duplicate displayName: Push nuget packages condition: and(succeeded(), ne(variables['NuGetOrgApiKey'], '')) From 05b8a491c03a9acb4268477a3e187a4c8ec9769e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 31 Mar 2022 10:37:02 -0600 Subject: [PATCH 316/641] Increase test timeout to 60s --- azure-pipelines/dotnet-test-cloud.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 440bd8909..08cd4d1fd 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -14,7 +14,7 @@ dotnet test $RepoRoot ` -c $Configuration ` --filter "TestCategory!=FailsInCloudTest" ` -p:CollectCoverage=true ` - --blame-hang-timeout 30s ` + --blame-hang-timeout 60s ` --blame-crash ` -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` From 34262db00810c6f0e48dfe12efbea0a69b1acf89 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 31 Mar 2022 13:34:19 -0600 Subject: [PATCH 317/641] Add recognition for RIDs in test paths --- azure-pipelines/dotnet-test-cloud.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 08cd4d1fd..7d5a4350a 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -27,8 +27,12 @@ Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { if ($PublishResults) { $x = [xml](Get-Content -Path $_) $storage = $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')[0].storage -replace '\\','/' - if ($storage -match '/(?[^/]+)/(?[^/]+)\.dll$') { - $runTitle = "$($matches.lib) ($($matches.tfm), $Agent)" + if ($storage -match '/(?net[^/]+)/(?:(?[^/]+)/)?(?[^/]+)\.dll$') { + if ($matches.rid) { + $runTitle = "$($matches.lib) ($($matches.tfm), $($matches.rid), $Agent)" + } else { + $runTitle = "$($matches.lib) ($($matches.tfm), $Agent)" + } } else { $unknownCounter += 1; $runTitle = "unknown$unknownCounter ($Agent)"; From 9d0b31316dbb66265441a80686c63dc7b1d45351 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 10 Apr 2022 09:19:59 -0600 Subject: [PATCH 318/641] Use appropriate slash for the agent OS Fixes #150 --- azure-pipelines/publish-deployables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml index f8c1dfc9d..9ccdc29e2 100644 --- a/azure-pipelines/publish-deployables.yml +++ b/azure-pipelines/publish-deployables.yml @@ -3,6 +3,6 @@ steps: displayName: Download deployables artifact: deployables-Windows -- script: dotnet nuget push $(Pipeline.Workspace)/deployables-Windows/*.nupkg -s $(ci_feed) -k azdo --skip-duplicate +- powershell: dotnet nuget push "$(Resolve-Path '$(Pipeline.Workspace)\deployables-Windows\')*.nupkg" -s $(ci_feed) -k azdo --skip-duplicate displayName: Push packages to CI feed condition: and(succeeded(), ne(variables['ci_feed'], ''), ne(variables['Build.Reason'], 'PullRequest')) From 3f11fb5dce7ba03f3753099c1314f15c9bc47b72 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 11 Apr 2022 13:46:40 -0600 Subject: [PATCH 319/641] Update devcontainer Dockerfile to match global.json --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c47acfaa9..234db6d1e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100-focal +FROM mcr.microsoft.com/dotnet/sdk:6.0.200-focal # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. From dd60e837b038dc6964181712275085332f5dfd83 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 11 Apr 2022 17:41:52 -0600 Subject: [PATCH 320/641] Remove explicit Microsoft.NETFramework.ReferenceAssemblies PackageReference --- Directory.Build.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index e70a74bb2..ecb971a7d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -36,7 +36,6 @@ - From 09516ca14922aadc4474d3f2e05cdef8a168dd75 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 12 Apr 2022 06:18:04 -0600 Subject: [PATCH 321/641] Tolerate trx files with test run failures --- azure-pipelines/dotnet-test-cloud.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 7d5a4350a..877f11ed3 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -26,16 +26,20 @@ Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { if ($PublishResults) { $x = [xml](Get-Content -Path $_) - $storage = $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')[0].storage -replace '\\','/' - if ($storage -match '/(?net[^/]+)/(?:(?[^/]+)/)?(?[^/]+)\.dll$') { + $runTitle = $null + if ($x.TestRun.TestDefinitions -and $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')) { + $storage = $x.TestRun.TestDefinitions.GetElementsByTagName('UnitTest')[0].storage -replace '\\','/' + if ($storage -match '/(?net[^/]+)/(?:(?[^/]+)/)?(?[^/]+)\.dll$') { if ($matches.rid) { $runTitle = "$($matches.lib) ($($matches.tfm), $($matches.rid), $Agent)" } else { $runTitle = "$($matches.lib) ($($matches.tfm), $Agent)" } - } else { - $unknownCounter += 1; - $runTitle = "unknown$unknownCounter ($Agent)"; + } + } + if (!$runTitle) { + $unknownCounter += 1; + $runTitle = "unknown$unknownCounter ($Agent)"; } Write-Host "##vso[results.publish type=VSTest;runTitle=$runTitle;publishRunAttachments=true;resultFiles=$_;failTaskOnFailedTests=true;testRunSystem=VSTS - PTR;]" From e21c1c1653f89510c77fc4f077d4fb4c2acc333a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 12 Apr 2022 08:30:10 -0600 Subject: [PATCH 322/641] Improve pipeline verbosity --- azure-pipelines/artifacts/_stage_all.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index 87421d56a..e4954c131 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -1,7 +1,7 @@ # This script links all the artifacts described by _all.ps1 # into a staging directory, reading for uploading to a cloud build artifact store. # It returns a sequence of objects with Name and Path properties. - +[CmdletBinding()] param ( [string]$ArtifactNameSuffix ) @@ -21,7 +21,6 @@ function Create-SymbolicLink { if (Test-Path $Link) { Remove-Item $Link } $LinkContainer = Split-Path $Link -Parent if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer } - Write-Verbose "Linking $Link to $Target" if ($IsMacOS -or $IsLinux) { ln $Target $Link | Out-Null } else { From 0ac22f889f6d001ba5e2e9b6a2ccecb6f393bc84 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Apr 2022 07:01:18 -0600 Subject: [PATCH 323/641] Document how to create a merge commit in a Library.Template based repo --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index 22d1091ef..0f9715f38 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,48 @@ Further customize your repo by: 1. Verify the license is suitable for your goal as it appears in the LICENSE and stylecop.json files and the Directory.Build.props file's `PackageLicenseExpression` property. 1. Reset or replace the badges at the top of this file. + +### Maintaining your repo based on this template + +The best way to keep your repo in sync with this template's evolving features and best practices is to periodically merge the template into your repo: + +```ps1 +git checkout main # your default branch +git pull # make sure you're at tip +git fetch libtemplate # fetch latest Library.Template +git merge libtemplate/main +``` + +There will frequently be merge conflicts to work out, but they will be easier to resolve than running the `Apply-Template.ps1` script every time, which simply blows away all your local changes with the latest from the template. + +If you do not already have Library.Template history in your repo or have never completed a merge before, the above steps may produce errors. +To get it working the first time, follow these steps: + +```ps1 +git remote add libtemplate https://github.com/AArnott/Library.Template.git +git fetch libtemplate +``` + +If the `git merge` step described earlier still fails for you, you may need to artificially create your first merge. +First, you must have a local clone of Library.Template on your box: + +```ps1 +git clone https://github.com/AArnott/Library.Template.git +``` + +Make sure you have either `main` checked out in that clone, as appropriate to match. +Use `git rev-parse HEAD` within the Library.Template repo and record the resulting commit as we'll use it later. + +Run the `Apply-Template.ps1` script, passing in the path to your own Library.Template-based repo. This will blow away most customizations you may have made to your repo's build authoring. You should *carefully* review all changes to your repo, staging those changes that you want to keep and reverting those that remove customizations you made. + +Now it's time to commit your changes. We do this in a very low-level way in order to have git record this as a *merge* commit even though it didn't start as a merge. +By doing this, git will allow future merges from `libtemplate/main` and only new changes will be brought down, which will be much easier than the `Apply-Template.ps1` script you just ran. +We create the merge commit with these commands: + +1. Be sure to have staged or reverted all the changes in your repo. +1. Run `git write-tree` within your repo. This will print out a git tree hash. +1. Run `git commit-tree -p HEAD -p A B -m "Merged latest Library.Template"`, where `A` is the output from `git rev-parse HEAD` that you recorded earlier, and `B` is the output from your prior `git write-tree` command. +1. Run `git merge X` where `X` is the output of the `git commit-tree` command. + +Congratulations. You're all done. +Next time you want to sync to latest from Library.Template, you can the simple `git merge` steps given at the start of this section. From 19515d7ca90ca669fa4c874af46977b7a3ebd6aa Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Apr 2022 09:36:30 -0600 Subject: [PATCH 324/641] Protect against misapplication of the Apply-Template script --- Apply-Template.ps1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Apply-Template.ps1 b/Apply-Template.ps1 index 0d3f3d8e2..d659670b3 100644 --- a/Apply-Template.ps1 +++ b/Apply-Template.ps1 @@ -15,6 +15,20 @@ Param( [string]$Path ) +Push-Location $Path +try { + # Look for our own initial commit in the target repo's history. + # If it's there, they've already switched to using git merge to freshen up. + # Using Apply-Template would just complicate future merges, so block it. + git log 05f49ce799c1f9cc696d53eea89699d80f59f833 ^HEAD | Out-Null + if ($LASTEXITCODE -eq 0) { + Write-Error 'The target repo already has Library.Template history merged into it. Use `git merge` instead of this script to freshen your repo. See the README.md file for details.' + exit 1 + } +} finally { + Pop-Location +} + Write-Host "Updating $Path" robocopy /mir $PSScriptRoot/azure-pipelines $Path/azure-pipelines robocopy /mir $PSScriptRoot/.devcontainer $Path/.devcontainer From 86a18ec2dd3772eefd6ef5d35ad2520382fe8d9c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 23 Apr 2022 10:02:34 -0600 Subject: [PATCH 325/641] Ignore .lutconfig files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 716456084..65f947769 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.user *.userosscache *.sln.docstates +*.lutconfig launchSettings.json # User-specific files (MonoDevelop/Xamarin Studio) From b656d1058f82d10de8e43e1c49f151f7ff4e3f88 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 26 Apr 2022 15:57:11 -0600 Subject: [PATCH 326/641] Clarify nuget push task --- azure-pipelines/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index 437ee65bb..6690cccfa 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -55,5 +55,5 @@ jobs: { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } ] - script: dotnet nuget push $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg -s https://api.nuget.org/v3/index.json --api-key $(NuGetOrgApiKey) --skip-duplicate - displayName: Push nuget packages + displayName: Push packages to nuget.org condition: and(succeeded(), ne(variables['NuGetOrgApiKey'], '')) From f39d7fc74bcd8b2625670bd68e0053b37b400d74 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 1 May 2022 14:35:13 -0600 Subject: [PATCH 327/641] Test on .NET 6 instead of .NET 5 .NET 5 falls out of Microsoft support in just a few days, so folks should focus testing on the currently supported platforms. --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 077d8d8f9..201086455 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -1,7 +1,7 @@ - net5.0;netcoreapp3.1;net472 + net6.0;netcoreapp3.1;net472 From 16d65511f7f92d18eb9dfb19fd40388e86e7a514 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 1 May 2022 15:59:52 -0600 Subject: [PATCH 328/641] Skip CI for release pipeline changes Also remove extra slash in snk path --- Directory.Build.props | 2 +- azure-pipelines.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index ecb971a7d..834e74573 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,7 +23,7 @@ embedded true - $(MSBuildThisFileDirectory)\strongname.snk + $(MSBuildThisFileDirectory)strongname.snk COMPANY-PLACEHOLDER COMPANY-PLACEHOLDER diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fe8363a2d..b7d86b455 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,6 +10,7 @@ trigger: - '*.md' - .vscode/ - .github/ + - azure-pipelines/release.yml parameters: - name: includeMacOS From e0d4ad51a33eacceb0ef1c20a43f7a8b75c79c9d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 1 May 2022 21:35:19 -0600 Subject: [PATCH 329/641] Add support for running 32-bit tests --- azure-pipelines/dotnet-test-cloud.ps1 | 45 ++++++++-- tools/Install-DotNetSdk.ps1 | 124 ++++++++++++++++++++------ 2 files changed, 138 insertions(+), 31 deletions(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 877f11ed3..43cdc3e00 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -1,15 +1,50 @@ #!/usr/bin/env pwsh +<# +.SYNOPSIS + Runs tests as they are run in cloud test runs. +.PARAMETER Configuration + The configuration within which to run tests +.PARAMETER Agent + The name of the agent. This is used in preparing test run titles. +.PARAMETER PublishResults + A switch to publish results to Azure Pipelines. +.PARAMETER x86 + A switch to run the tests in an x86 process. +.PARAMETER dotnet32 + The path to a 32-bit dotnet executable to use. +#> +[CmdletBinding()] Param( [string]$Configuration='Debug', [string]$Agent='Local', - [switch]$PublishResults + [switch]$PublishResults, + [switch]$x86, + [string]$dotnet32 ) $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" -dotnet test $RepoRoot ` +$dotnet = 'dotnet' +if ($x86) { + $x86RunTitleSuffix = ", x86" + if ($dotnet32) { + $dotnet = $dotnet32 + } else { + $dotnet32Possibilities = "$PSScriptRoot\../obj/tools/x86/.dotnet/dotnet.exe", "$env:AGENT_TOOLSDIRECTORY/x86/dotnet/dotnet.exe", "${env:ProgramFiles(x86)}\dotnet\dotnet.exe" + $dotnet32Matches = $dotnet32Possibilities |? { Test-Path $_ } + if ($dotnet32Matches) { + $dotnet = Resolve-Path @($dotnet32Matches)[0] + Write-Host "Running tests using `"$dotnet`"" -ForegroundColor DarkGray + } else { + Write-Error "Unable to find 32-bit dotnet.exe" + return 1 + } + } +} + +& $dotnet test $RepoRoot ` --no-build ` -c $Configuration ` --filter "TestCategory!=FailsInCloudTest" ` @@ -18,7 +53,7 @@ dotnet test $RepoRoot ` --blame-crash ` -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` - --logger trx + --logger trx ` $unknownCounter = 0 Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { @@ -33,13 +68,13 @@ Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { if ($matches.rid) { $runTitle = "$($matches.lib) ($($matches.tfm), $($matches.rid), $Agent)" } else { - $runTitle = "$($matches.lib) ($($matches.tfm), $Agent)" + $runTitle = "$($matches.lib) ($($matches.tfm)$x86RunTitleSuffix, $Agent)" } } } if (!$runTitle) { $unknownCounter += 1; - $runTitle = "unknown$unknownCounter ($Agent)"; + $runTitle = "unknown$unknownCounter ($Agent$x86RunTitleSuffix)"; } Write-Host "##vso[results.publish type=VSTest;runTitle=$runTitle;publishRunAttachments=true;resultFiles=$_;failTaskOnFailedTests=true;testRunSystem=VSTS - PTR;]" diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 7dcddc782..76a397f04 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -15,20 +15,28 @@ When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. +.PARAMETER IncludeX86 + Installs a x86 SDK and runtimes in addition to the x64 ones. Only supported on Windows. Ignored on others. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] Param ( [ValidateSet('repo','user','machine')] - [string]$InstallLocality='user' + [string]$InstallLocality='user', + [switch]$IncludeX86 ) $DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools" if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot -WhatIf:$false | Out-Null } $DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot -# Look up actual required .NET Core SDK version from global.json +# Look up actual required .NET SDK version from global.json $sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1" +If ($IncludeX86 -and ($IsMacOS -or $IsLinux)) { + Write-Verbose "Ignoring -IncludeX86 switch because 32-bit runtimes are only supported on Windows." + $IncludeX86 = $false +} + $arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture if (!$arch) { # Windows Powershell leaves this blank $arch = 'x64' @@ -72,7 +80,7 @@ Function Get-FileFromWeb([Uri]$Uri, $OutDir) { $OutFile = Join-Path $OutDir $Uri.Segments[-1] if (!(Test-Path $OutFile)) { Write-Verbose "Downloading $Uri..." - if (!(Test-Path $OutDir)) { mkdir $OutDir } + if (!(Test-Path $OutDir)) { New-Item -ItemType Directory -Path $OutDir } try { (New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile) } finally { @@ -83,7 +91,7 @@ Function Get-FileFromWeb([Uri]$Uri, $OutDir) { $OutFile } -Function Get-InstallerExe($Version, [switch]$Runtime) { +Function Get-InstallerExe($Version, $Architecture, [switch]$Runtime) { $sdkOrRuntime = 'Sdk' if ($Runtime) { $sdkOrRuntime = 'Runtime' } @@ -116,7 +124,7 @@ Function Get-InstallerExe($Version, [switch]$Runtime) { if ($filesElement) { foreach ($file in $filesElement) { - if ($file.rid -eq "win-$arch") { + if ($file.rid -eq "win-$Architecture") { $url = $file.url Break } @@ -135,22 +143,20 @@ Function Get-InstallerExe($Version, [switch]$Runtime) { } } -Function Install-DotNet($Version, [switch]$Runtime) { +Function Install-DotNet($Version, $Architecture, [switch]$Runtime) { if ($Runtime) { $sdkSubstring = '' } else { $sdkSubstring = 'SDK ' } Write-Host "Downloading .NET Core $sdkSubstring$Version..." - $Installer = Get-InstallerExe -Version $Version -Runtime:$Runtime + $Installer = Get-InstallerExe -Version $Version -Architecture $Architecture -Runtime:$Runtime Write-Host "Installing .NET Core $sdkSubstring$Version..." cmd /c start /wait $Installer /install /passive /norestart if ($LASTEXITCODE -eq 3010) { Write-Verbose "Restart required" } elseif ($LASTEXITCODE -ne 0) { - throw "Failure to install .NET Core SDK" + throw "Failure to install .NET SDK" } } -$switches = @( - '-Architecture',$arch -) +$switches = @() $envVars = @{ # For locally installed dotnet, skip first time experience which takes a long time 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true'; @@ -161,15 +167,25 @@ if ($InstallLocality -eq 'machine') { $DotNetInstallDir = '/usr/share/dotnet' } else { $restartRequired = $false - if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { - Install-DotNet -Version $sdkVersion + if ($PSCmdlet.ShouldProcess(".NET SDK $sdkVersion", "Install")) { + Install-DotNet -Version $sdkVersion -Architecture $arch $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + + if ($IncludeX86) { + Install-DotNet -Version $sdkVersion -Architecture x86 + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + } } $runtimeVersions | Get-Unique |% { if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - Install-DotNet -Version $_ -Runtime + Install-DotNet -Version $_ -Architecture $arch -Runtime $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + + if ($IncludeX86) { + Install-DotNet -Version $_ -Architecture x86 -Runtime + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + } } } @@ -182,20 +198,34 @@ if ($InstallLocality -eq 'machine') { } } elseif ($InstallLocality -eq 'repo') { $DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet" + $DotNetX86InstallDir = "$DotNetInstallScriptRoot/x86/.dotnet" } elseif ($env:AGENT_TOOLSDIRECTORY) { $DotNetInstallDir = "$env:AGENT_TOOLSDIRECTORY/dotnet" + $DotNetX86InstallDir = "$env:AGENT_TOOLSDIRECTORY/x86/dotnet" } else { $DotNetInstallDir = Join-Path $HOME .dotnet } -Write-Host "Installing .NET Core SDK and runtimes to $DotNetInstallDir" -ForegroundColor Blue - if ($DotNetInstallDir) { - $switches += '-InstallDir',"`"$DotNetInstallDir`"" + if (!(Test-Path $DotNetInstallDir)) { New-Item -ItemType Directory -Path $DotNetInstallDir } + $DotNetInstallDir = Resolve-Path $DotNetInstallDir + Write-Host "Installing .NET SDK and runtimes to $DotNetInstallDir" -ForegroundColor Blue $envVars['DOTNET_MULTILEVEL_LOOKUP'] = '0' $envVars['DOTNET_ROOT'] = $DotNetInstallDir } +if ($IncludeX86) { + if ($DotNetX86InstallDir) { + if (!(Test-Path $DotNetX86InstallDir)) { New-Item -ItemType Directory -Path $DotNetX86InstallDir } + $DotNetX86InstallDir = Resolve-Path $DotNetX86InstallDir + Write-Host "Installing x86 .NET SDK and runtimes to $DotNetX86InstallDir" -ForegroundColor Blue + } else { + # Only machine-wide or repo-wide installations can handle two unique dotnet.exe architectures. + Write-Error "The installation location or OS isn't supported for x86 installation. Try a different -InstallLocality value." + return 1 + } +} + if ($IsMacOS -or $IsLinux) { $DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.sh" $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" @@ -219,47 +249,89 @@ $DotNetInstallScriptPathExpression = "& '$DotNetInstallScriptPathExpression'" $anythingInstalled = $false $global:LASTEXITCODE = 0 -if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { +if ($PSCmdlet.ShouldProcess(".NET SDK $sdkVersion", "Install")) { $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion $switches" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion -Architecture $arch -InstallDir $DotNetInstallDir $switches" if ($LASTEXITCODE -ne 0) { Write-Error ".NET SDK installation failure: $LASTEXITCODE" exit $LASTEXITCODE } } else { - Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion $switches -DryRun" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion -Architecture $arch -InstallDir $DotNetInstallDir $switches -DryRun" +} + +if ($IncludeX86) { + if ($PSCmdlet.ShouldProcess(".NET x86 SDK $sdkVersion", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion -Architecture x86 -InstallDir $DotNetX86InstallDir $switches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET x86 SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } + } else { + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Version $sdkVersion -Architecture x86 -InstallDir $DotNetX86InstallDir $switches -DryRun" + } } $dotnetRuntimeSwitches = $switches + '-Runtime','dotnet' $runtimeVersions | Sort-Object -Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET Core $Arch runtime $_", "Install")) { $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $dotnetRuntimeSwitches" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $dotnetRuntimeSwitches" if ($LASTEXITCODE -ne 0) { Write-Error ".NET SDK installation failure: $LASTEXITCODE" exit $LASTEXITCODE } } else { - Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $dotnetRuntimeSwitches -DryRun" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $dotnetRuntimeSwitches -DryRun" + } + + if ($IncludeX86) { + if ($PSCmdlet.ShouldProcess(".NET Core x86 runtime $_", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $dotnetRuntimeSwitches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } + } else { + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $dotnetRuntimeSwitches -DryRun" + } } } $windowsDesktopRuntimeSwitches = $switches + '-Runtime','windowsdesktop' $windowsDesktopRuntimeVersions | Sort-Object -Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop runtime $_", "Install")) { + if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop $arch runtime $_", "Install")) { $anythingInstalled = $true - Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $windowsDesktopRuntimeSwitches" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $windowsDesktopRuntimeSwitches" if ($LASTEXITCODE -ne 0) { Write-Error ".NET SDK installation failure: $LASTEXITCODE" exit $LASTEXITCODE } } else { - Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ $windowsDesktopRuntimeSwitches -DryRun" + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $windowsDesktopRuntimeSwitches -DryRun" + } + + if ($IncludeX86) { + if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop x86 runtime $_", "Install")) { + $anythingInstalled = $true + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $windowsDesktopRuntimeSwitches" + + if ($LASTEXITCODE -ne 0) { + Write-Error ".NET SDK installation failure: $LASTEXITCODE" + exit $LASTEXITCODE + } + } else { + Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $windowsDesktopRuntimeSwitches -DryRun" + } } } From 78cba24937d03e10c3266e7421b1aef038d0e354 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 5 May 2022 21:07:12 -0600 Subject: [PATCH 330/641] Shift to `using` directives outside the namespace This is a concession from StyleCop defaults, but it's just too hard to paddle upstream with the C# language team, which doesn't consistently test their refactoring features when `using` is inside the namespace. --- stylecop.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stylecop.json b/stylecop.json index 379189493..6cd455746 100644 --- a/stylecop.json +++ b/stylecop.json @@ -10,6 +10,9 @@ }, "fileNamingConvention": "metadata", "xmlHeader": false + }, + "orderingRules": { + "usingDirectivesPlacement": "outsideNamespace" } } } From c82cc3463cb88e1591401059e127a1d84c4317f9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 5 May 2022 21:07:33 -0600 Subject: [PATCH 331/641] Permit attribute lists with multiple attributes in tests --- test/.editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/.editorconfig b/test/.editorconfig index 8aa791bef..74dd4a1fa 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -50,3 +50,6 @@ dotnet_diagnostic.CA2007.severity = none # SA1401: Fields should be private dotnet_diagnostic.SA1401.severity = silent + +# SA1133: Do not combine attributes +dotnet_diagnostic.SA1133.severity = silent From 0a6f58c3cc425ca7a8612acb9129e730fce8507c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 5 May 2022 21:22:34 -0600 Subject: [PATCH 332/641] Update Nerdbank.GitVersioning dependency --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 834e74573..2e13d76f0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,7 +37,7 @@ - + From 9dde17ff42c902d3be0951021e049b7c8fc6fec1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 5 May 2022 21:32:22 -0600 Subject: [PATCH 333/641] Use icons for all task display names --- azure-pipelines/build.yml | 2 +- azure-pipelines/dotnet.yml | 10 +++++----- azure-pipelines/expand-template.yml | 6 +++--- azure-pipelines/install-dependencies.yml | 6 +++--- azure-pipelines/publish-codecoverage.yml | 10 +++++----- azure-pipelines/publish-deployables.yml | 4 ++-- azure-pipelines/publish-symbols.yml | 16 ++++++++-------- azure-pipelines/release.yml | 10 +++++----- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index f779fd12c..5bfd95f53 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -14,7 +14,7 @@ jobs: - template: install-dependencies.yml - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -c' - displayName: Set build number + displayName: ⚙ Set build number - template: dotnet.yml - template: expand-template.yml diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index a103adfd3..1d7d9de76 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -1,23 +1,23 @@ steps: - script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" - displayName: dotnet build + displayName: 🛠 dotnet build - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults - displayName: dotnet test + displayName: 🧪 dotnet test - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true - displayName: Update pipeline variables based on build outputs + displayName: ⚙ Update pipeline variables based on build outputs condition: succeededOrFailed() - powershell: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)" failOnStderr: true - displayName: Publish artifacts + displayName: 📢 Publish artifacts condition: succeededOrFailed() - bash: bash <(curl -s https://codecov.io/bash) - displayName: Publish code coverage results to codecov.io + displayName: 📢 Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') timeoutInMinutes: 3 continueOnError: true diff --git a/azure-pipelines/expand-template.yml b/azure-pipelines/expand-template.yml index ed510de3e..d843f1eac 100644 --- a/azure-pipelines/expand-template.yml +++ b/azure-pipelines/expand-template.yml @@ -2,13 +2,13 @@ steps: - script: | dotnet build-server shutdown git clean -fdx - displayName: Cleaning repo for template expansion + displayName: 🧹 Cleaning repo for template expansion - powershell: | git config user.name "test user" git config user.email "andrewarnott@gmail.com" ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott" - displayName: Expanding template + displayName: 🧪 Expanding template failOnStderr: true # TODO: Verify that all changes are staged to the git index - script: dotnet build - displayName: dotnet build (expanded template) + displayName: 🛠 dotnet build (expanded template) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 4f848b099..3993f1043 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -4,7 +4,7 @@ parameters: steps: - task: NuGetAuthenticate@0 - displayName: Authenticate NuGet feeds + displayName: 🔏 Authenticate NuGet feeds inputs: forceReinstallCredentialProvider: true @@ -17,9 +17,9 @@ steps: if (Get-Command mono -ErrorAction SilentlyContinue) { mono --version } - displayName: Install prerequisites + displayName: ⚙ Install prerequisites - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true - displayName: Set pipeline variables based on source + displayName: ⚙ Set pipeline variables based on source name: SetPipelineVariables diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index a0862be3f..423e12fce 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -4,15 +4,15 @@ parameters: steps: - download: current artifact: coverageResults-Windows - displayName: Download Windows code coverage results + displayName: 🔻 Download Windows code coverage results continueOnError: true - download: current artifact: coverageResults-Linux - displayName: Download Linux code coverage results + displayName: 🔻 Download Linux code coverage results continueOnError: true - download: current artifact: coverageResults-macOS - displayName: Download macOS code coverage results + displayName: 🔻 Download macOS code coverage results continueOnError: true condition: ${{ parameters.includeMacOS }} - powershell: | @@ -26,9 +26,9 @@ steps: } $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_ })) obj/reportgenerator -reports:"$Inputs" -targetdir:coveragereport -reporttypes:Cobertura - displayName: Merge coverage + displayName: ⚙ Merge coverage - task: PublishCodeCoverageResults@1 - displayName: Publish code coverage results to Azure DevOps + displayName: 📢 Publish code coverage results to Azure DevOps inputs: codeCoverageTool: cobertura summaryFileLocation: 'coveragereport/Cobertura.xml' diff --git a/azure-pipelines/publish-deployables.yml b/azure-pipelines/publish-deployables.yml index 9ccdc29e2..31e80a437 100644 --- a/azure-pipelines/publish-deployables.yml +++ b/azure-pipelines/publish-deployables.yml @@ -1,8 +1,8 @@ steps: - download: current - displayName: Download deployables + displayName: 🔻 Download deployables artifact: deployables-Windows - powershell: dotnet nuget push "$(Resolve-Path '$(Pipeline.Workspace)\deployables-Windows\')*.nupkg" -s $(ci_feed) -k azdo --skip-duplicate - displayName: Push packages to CI feed + displayName: 📦 Push packages to CI feed condition: and(succeeded(), ne(variables['ci_feed'], ''), ne(variables['Build.Reason'], 'PullRequest')) diff --git a/azure-pipelines/publish-symbols.yml b/azure-pipelines/publish-symbols.yml index c45eff020..00c188fc3 100644 --- a/azure-pipelines/publish-symbols.yml +++ b/azure-pipelines/publish-symbols.yml @@ -6,19 +6,19 @@ steps: inputs: artifact: symbols-Windows path: $(Pipeline.Workspace)/symbols/Windows - displayName: Download Windows symbols + displayName: 🔻 Download Windows symbols continueOnError: true - task: DownloadPipelineArtifact@2 inputs: artifact: symbols-Linux path: $(Pipeline.Workspace)/symbols/Linux - displayName: Download Linux symbols + displayName: 🔻 Download Linux symbols continueOnError: true - task: DownloadPipelineArtifact@2 inputs: artifact: symbols-macOS path: $(Pipeline.Workspace)/symbols/macOS - displayName: Download macOS symbols + displayName: 🔻 Download macOS symbols continueOnError: true condition: ${{ parameters.includeMacOS }} @@ -26,19 +26,19 @@ steps: inputs: artifact: test_symbols-Windows path: $(Pipeline.Workspace)/test_symbols/Windows - displayName: Download Windows test symbols + displayName: 🔻 Download Windows test symbols continueOnError: true - task: DownloadPipelineArtifact@2 inputs: artifact: test_symbols-Linux path: $(Pipeline.Workspace)/test_symbols/Linux - displayName: Download Linux test symbols + displayName: 🔻 Download Linux test symbols continueOnError: true - task: DownloadPipelineArtifact@2 inputs: artifact: test_symbols-macOS path: $(Pipeline.Workspace)/test_symbols/macOS - displayName: Download macOS test symbols + displayName: 🔻 Download macOS test symbols continueOnError: true condition: ${{ parameters.includeMacOS }} @@ -48,7 +48,7 @@ steps: SearchPattern: '**/*.pdb' IndexSources: false SymbolServerType: TeamServices - displayName: Publish symbols + displayName: 📢 Publish symbols - task: PublishSymbols@2 inputs: @@ -56,4 +56,4 @@ steps: SearchPattern: '**/*.pdb' IndexSources: false SymbolServerType: TeamServices - displayName: Publish test symbols + displayName: 📢 Publish test symbols diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index 6690cccfa..2679b24e7 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -25,18 +25,18 @@ jobs: } else { Write-Host "##vso[task.setvariable variable=IsPrerelease]false" } - displayName: Set up pipeline + displayName: ⚙ Set up pipeline - task: UseDotNet@2 - displayName: Install .NET SDK + displayName: ⚙ Install .NET SDK inputs: packageType: sdk version: 6.x - download: CI artifact: deployables-Windows - displayName: Download deployables-Windows artifact + displayName: 🔻 Download deployables-Windows artifact patterns: 'deployables-Windows/*' - task: GitHubRelease@1 - displayName: GitHub release (create) + displayName: 📢 GitHub release (create) inputs: gitHubConnection: # TODO: fill in service connection here repositoryName: $(Build.Repository.Name) @@ -55,5 +55,5 @@ jobs: { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } ] - script: dotnet nuget push $(Pipeline.Workspace)/CI/deployables-Windows/*.nupkg -s https://api.nuget.org/v3/index.json --api-key $(NuGetOrgApiKey) --skip-duplicate - displayName: Push packages to nuget.org + displayName: 📦 Push packages to nuget.org condition: and(succeeded(), ne(variables['NuGetOrgApiKey'], '')) From 9805678248d0fbda63f97982f37e35de71890d2f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 12 May 2022 08:41:05 -0600 Subject: [PATCH 334/641] Fix NUGET_PACKAGES path in pipelines Be default the NUGET_PACKAGES path has a trailing slash. In our override, we should do this as well or the msbuild property that gets generated is missing the slash, which can break some builds. --- .github/workflows/build.yml | 2 +- azure-pipelines.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18ae3e289..4db43f53c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BUILDCONFIGURATION: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ - NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/ jobs: build: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b7d86b455..d98ed107d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,7 +24,7 @@ variables: BuildConfiguration: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ ci_feed: https://pkgs.dev.azure.com/andrewarnott/_packaging/CI/nuget/v3/index.json # Azure Artifacts feed URL - NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages + NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages/ jobs: - template: azure-pipelines/build.yml From da08e901c94c416cbbdfa980020ced9ed9612851 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 12 May 2022 16:08:56 -0600 Subject: [PATCH 335/641] Add ability to split stage and publish artifact steps --- azure-pipelines/artifacts/_all.ps1 | 10 +++---- azure-pipelines/artifacts/_pipelines.ps1 | 35 ++++++++++++++++++++---- azure-pipelines/artifacts/_stage_all.ps1 | 8 +++++- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index afe42be30..c9182a45a 100755 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -12,7 +12,7 @@ Value = an array of paths (absolute or relative to the BaseDirectory) to files to include in the artifact. FileInfo objects are also allowed. .PARAMETER Force - Executes artifact scripts even if they have already been uploaded. + Executes artifact scripts even if they have already been staged. #> param ( @@ -28,14 +28,14 @@ Function EnsureTrailingSlash($path) { $path.Replace('\', [IO.Path]::DirectorySeparatorChar) } -Function Test-ArtifactUploaded($artifactName) { - $varName = "ARTIFACTUPLOADED_$($artifactName.ToUpper())" +Function Test-ArtifactStaged($artifactName) { + $varName = "ARTIFACTSTAGED_$($artifactName.ToUpper())" Test-Path "env:$varName" } Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse | % { $ArtifactName = $_.BaseName - if ($Force -or !(Test-ArtifactUploaded($ArtifactName + $ArtifactNameSuffix))) { + if ($Force -or !(Test-ArtifactStaged($ArtifactName + $ArtifactNameSuffix))) { $totalFileCount = 0 $fileGroups = & $_ if ($fileGroups) { @@ -65,6 +65,6 @@ Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse | % { Write-Warning "No files found for the `"$ArtifactName`" artifact." } } else { - Write-Host "Skipping $ArtifactName because it has already been uploaded." -ForegroundColor DarkGray + Write-Host "Skipping $ArtifactName because it has already been staged." -ForegroundColor DarkGray } } diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 index 73a3af0ac..a62d2675b 100644 --- a/azure-pipelines/artifacts/_pipelines.ps1 +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -2,14 +2,39 @@ # into commands that instruct Azure Pipelines to actually collect those artifacts. param ( - [string]$ArtifactNameSuffix + [string]$ArtifactNameSuffix, + [switch]$StageOnly ) -& "$PSScriptRoot/_stage_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix |% { - Write-Host "##vso[artifact.upload containerfolder=$($_.Name);artifactname=$($_.Name);]$($_.Path)" +Function Set-PipelineVariable($name, $value) { + if ((Test-Path "Env:\$name") -and (Get-Item "Env:\$name").Value -eq $value) { + return # already set + } + + #New-Item -Path "Env:\$name".ToUpper() -Value $value -Force | Out-Null + Write-Host "##vso[task.setvariable variable=$name]$value" +} + +Function Test-ArtifactUploaded($artifactName) { + $varName = "ARTIFACTUPLOADED_$($artifactName.ToUpper())" + Test-Path "env:$varName" +} +& "$PSScriptRoot/_stage_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix |% { # Set a variable which will out-live this script so that a subsequent attempt to collect and upload artifacts # will skip this one from a check in the _all.ps1 script. - $varName = "ARTIFACTUPLOADED_$($_.Name.ToUpper())" - Write-Host "##vso[task.setvariable variable=$varName]true" + Set-PipelineVariable "ARTIFACTSTAGED_$($_.Name.ToUpper())" 'true' + Write-Host "Staged artifact $($_.Name) to $($_.Path)" + + if (!$StageOnly) { + if (Test-ArtifactUploaded $_.Name) { + Write-Host "Skipping $($_.Name) because it has already been uploaded." -ForegroundColor DarkGray + } else { + Write-Host "##vso[artifact.upload containerfolder=$($_.Name);artifactname=$($_.Name);]$($_.Path)" + + # Set a variable which will out-live this script so that a subsequent attempt to collect and upload artifacts + # will skip this one from a check in the _all.ps1 script. + Set-PipelineVariable "ARTIFACTUPLOADED_$($_.Name.ToUpper())" 'true' + } + } } diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index e4954c131..b7166b4eb 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -42,7 +42,13 @@ $Artifacts |% { } } -$Artifacts |% { "$($_.ArtifactName)$ArtifactNameSuffix" } | Get-Unique |% { +$ArtifactNames = $Artifacts |% { "$($_.ArtifactName)$ArtifactNameSuffix" } +$ArtifactNames += Get-ChildItem env:ARTIFACTSTAGED_* |% { + # Return from ALLCAPS to the actual capitalization used for the artifact. + $artifactNameAllCaps = "$($_.Name.Substring('ARTIFACTSTAGED_'.Length))" + (Get-ChildItem $ArtifactStagingFolder\$artifactNameAllCaps* -Filter $artifactNameAllCaps).Name +} +$ArtifactNames | Get-Unique |% { $artifact = New-Object -TypeName PSObject Add-Member -InputObject $artifact -MemberType NoteProperty -Name Name -Value $_ Add-Member -InputObject $artifact -MemberType NoteProperty -Name Path -Value (Join-Path $ArtifactStagingFolder $_) From c268a9e8d99bfed18778aaecea828720522c6dea Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 18 May 2022 16:18:24 -0600 Subject: [PATCH 336/641] Fix several Install-DotNetSdk issues * Stop popping Windows Explorer dialogs * Stop installing the same .NET runtime versions multiple times. * Install WindowsDesktop too. --- tools/Install-DotNetSdk.ps1 | 57 +++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 76a397f04..2bac3b9bc 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -80,7 +80,7 @@ Function Get-FileFromWeb([Uri]$Uri, $OutDir) { $OutFile = Join-Path $OutDir $Uri.Segments[-1] if (!(Test-Path $OutFile)) { Write-Verbose "Downloading $Uri..." - if (!(Test-Path $OutDir)) { New-Item -ItemType Directory -Path $OutDir } + if (!(Test-Path $OutDir)) { New-Item -ItemType Directory -Path $OutDir | Out-Null } try { (New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile) } finally { @@ -91,35 +91,31 @@ Function Get-FileFromWeb([Uri]$Uri, $OutDir) { $OutFile } -Function Get-InstallerExe($Version, $Architecture, [switch]$Runtime) { - $sdkOrRuntime = 'Sdk' - if ($Runtime) { $sdkOrRuntime = 'Runtime' } - +Function Get-InstallerExe( + $Version, + $Architecture, + [ValidateSet('Sdk','Runtime','WindowsDesktop')] + [string]$sku +) { # Get the latest/actual version for the specified one $TypedVersion = [Version]$Version if ($TypedVersion.Build -eq -1) { - $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/latest.version" -UseBasicParsing) + $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sku/$Version/latest.version" -UseBasicParsing) $Version = $versionInfo[-1] } $majorMinor = "$($TypedVersion.Major).$($TypedVersion.Minor)" $ReleasesFile = Join-Path $DotNetInstallScriptRoot "$majorMinor\releases.json" if (!(Test-Path $ReleasesFile)) { - Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/$majorMinor/releases.json" -OutDir (Split-Path $ReleasesFile) + Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/$majorMinor/releases.json" -OutDir (Split-Path $ReleasesFile) | Out-Null } $releases = Get-Content $ReleasesFile | ConvertFrom-Json $url = $null foreach ($release in $releases.releases) { $filesElement = $null - if ($Runtime) { - if ($release.runtime.version -eq $Version) { - $filesElement = $release.runtime.files - } - } else { - if ($release.sdk.version -eq $Version) { - $filesElement = $release.sdk.files - } + if ($release.$sku.version -eq $Version) { + $filesElement = $release.$sku.files } if ($filesElement) { @@ -139,15 +135,14 @@ Function Get-InstallerExe($Version, $Architecture, [switch]$Runtime) { if ($url) { Get-FileFromWeb -Uri $url -OutDir $DotNetInstallScriptRoot } else { - Write-Error "Unable to find release of $sdkOrRuntime v$Version" + Write-Error "Unable to find release of $sku v$Version" } } -Function Install-DotNet($Version, $Architecture, [switch]$Runtime) { - if ($Runtime) { $sdkSubstring = '' } else { $sdkSubstring = 'SDK ' } - Write-Host "Downloading .NET Core $sdkSubstring$Version..." - $Installer = Get-InstallerExe -Version $Version -Architecture $Architecture -Runtime:$Runtime - Write-Host "Installing .NET Core $sdkSubstring$Version..." +Function Install-DotNet($Version, $Architecture, [ValidateSet('Sdk','Runtime','WindowsDesktop')][string]$sku = 'Sdk') { + Write-Host "Downloading .NET Core $sku $Version..." + $Installer = Get-InstallerExe -Version $Version -Architecture $Architecture -sku $sku + Write-Host "Installing .NET Core $sku $Version..." cmd /c start /wait $Installer /install /passive /norestart if ($LASTEXITCODE -eq 3010) { Write-Verbose "Restart required" @@ -177,13 +172,25 @@ if ($InstallLocality -eq 'machine') { } } - $runtimeVersions | Get-Unique |% { - if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { - Install-DotNet -Version $_ -Architecture $arch -Runtime + $runtimeVersions | Sort-Object | Get-Unique |% { + if ($PSCmdlet.ShouldProcess(".NET runtime $_", "Install")) { + Install-DotNet -Version $_ -sku Runtime -Architecture $arch + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + + if ($IncludeX86) { + Install-DotNet -Version $_ -sku Runtime -Architecture x86 + $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) + } + } + } + + $windowsDesktopRuntimeVersions | Sort-Object | Get-Unique |% { + if ($PSCmdlet.ShouldProcess(".NET Windows Desktop $_", "Install")) { + Install-DotNet -Version $_ -sku WindowsDesktop -Architecture $arch $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) if ($IncludeX86) { - Install-DotNet -Version $_ -Architecture x86 -Runtime + Install-DotNet -Version $_ -sku WindowsDesktop -Architecture x86 $restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010) } } From 7bf4e22b5ab48ca5b0b3992804f685d9b857dad1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 May 2022 14:06:55 -0600 Subject: [PATCH 337/641] Fix Apply-Template merge check --- Apply-Template.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apply-Template.ps1 b/Apply-Template.ps1 index d659670b3..12bfaa129 100644 --- a/Apply-Template.ps1 +++ b/Apply-Template.ps1 @@ -20,7 +20,7 @@ try { # Look for our own initial commit in the target repo's history. # If it's there, they've already switched to using git merge to freshen up. # Using Apply-Template would just complicate future merges, so block it. - git log 05f49ce799c1f9cc696d53eea89699d80f59f833 ^HEAD | Out-Null + git merge-base --is-ancestor 05f49ce799c1f9cc696d53eea89699d80f59f833 HEAD | Out-Null if ($LASTEXITCODE -eq 0) { Write-Error 'The target repo already has Library.Template history merged into it. Use `git merge` instead of this script to freshen your repo. See the README.md file for details.' exit 1 From 5abdd709c599b95cb6f584eef289fe665031116a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jun 2022 08:24:16 -0600 Subject: [PATCH 338/641] Bump Microsoft.NET.Test.Sdk from 17.1.0 to 17.2.0 (#159) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.1.0 to 17.2.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.1.0...v17.2.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 201086455..7dd444b67 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -11,7 +11,7 @@ - + From 311e766eea33c9ea74f6b6b444fa2cb6463722c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jun 2022 14:24:39 +0000 Subject: [PATCH 339/641] Bump Nerdbank.GitVersioning from 3.5.103 to 3.5.107 (#157) --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2e13d76f0..a2da14f66 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,7 +37,7 @@ - + From 6a1593c66812b348812be702b41320290839ce0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jun 2022 14:24:49 +0000 Subject: [PATCH 340/641] Bump StyleCop.Analyzers.Unstable from 1.2.0.406 to 1.2.0.435 (#156) --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index a2da14f66..22c1b94de 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -40,7 +40,7 @@ - + From a91a2f1e2331902ab7515f1d317cf105892b9cb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jun 2022 14:31:58 +0000 Subject: [PATCH 341/641] Bump xunit.runner.visualstudio from 2.4.3 to 2.4.5 (#158) --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 7dd444b67..402468a83 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -12,7 +12,7 @@ - + From 8f2ed5eaf2436e9e49e741650308c0b45b4a53df Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 7 Jun 2022 15:50:23 -0600 Subject: [PATCH 342/641] Update SDK to 6.0.300 --- .devcontainer/Dockerfile | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 234db6d1e..b13ca0aca 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.200-focal +FROM mcr.microsoft.com/dotnet/sdk:6.0.300-focal # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/global.json b/global.json index 6bfbd1775..954a92e75 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.200", + "version": "6.0.300", "rollForward": "patch", "allowPrerelease": false } From 8c6b68ecdd6cb98a02bc89e762d4cf8851e0148b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Jun 2022 08:48:38 -0600 Subject: [PATCH 343/641] Add adoption caution about github issues being closed --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0f9715f38..8cab6b7af 100644 --- a/README.md +++ b/README.md @@ -79,5 +79,9 @@ We create the merge commit with these commands: 1. Run `git commit-tree -p HEAD -p A B -m "Merged latest Library.Template"`, where `A` is the output from `git rev-parse HEAD` that you recorded earlier, and `B` is the output from your prior `git write-tree` command. 1. Run `git merge X` where `X` is the output of the `git commit-tree` command. +**CAUTION**: when merging this for the first time, a github-hosted repo may close issues in your repo with the same number as issues that this repo closed in git commit messages. +Verify after completing your PR by visiting your github closed issues, sorted by recently updated, and reactivate any that were inadvertently closed by this merge. +This shouldn't be a recurring issue because going forward, we will avoid referencing github issues with simple `#123` syntax in this repo's history. + Congratulations. You're all done. Next time you want to sync to latest from Library.Template, you can the simple `git merge` steps given at the start of this section. From f678dd36be37f69272b6346b4ba3acb7472ec418 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Jun 2022 12:12:42 -0600 Subject: [PATCH 344/641] Install the nuget cred provider for .NET 6 and .NET Framework Recently we've only been getting the .NET Core 3.1 plugin, which leaves .NET Framework-based nuget tools un-authenticated. --- tools/Install-NuGetCredProvider.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Install-NuGetCredProvider.ps1 b/tools/Install-NuGetCredProvider.ps1 index 6d3100349..496049a29 100755 --- a/tools/Install-NuGetCredProvider.ps1 +++ b/tools/Install-NuGetCredProvider.ps1 @@ -33,7 +33,7 @@ if ($IsMacOS -or $IsLinux) { $installerScript = Join-Path $toolsPath $installerScript -if (!(Test-Path $installerScript)) { +if (!(Test-Path $installerScript) -or $Force) { Invoke-WebRequest $sourceUrl -OutFile $installerScript } @@ -43,7 +43,7 @@ if ($IsMacOS -or $IsLinux) { chmod u+x $installerScript } -& $installerScript -Force:$Force +& $installerScript -Force:$Force -AddNetfx -InstallNet6 if ($AccessToken) { $endpoints = @() From d8f567ef793329d7ff8cc09cf43922d2d00316c9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Jun 2022 08:58:02 -0600 Subject: [PATCH 345/641] Avoid truncated code coverage data Apply workaround for microsoft/vstest issue 3724. --- azure-pipelines/artifacts/coverageResults.ps1 | 7 +-- azure-pipelines/dotnet-test-cloud.ps1 | 3 +- azure-pipelines/publish-codecoverage.yml | 7 +-- azure-pipelines/test.runsettings | 44 +++++++++++++++++++ test/Directory.Build.targets | 7 --- test/Library.Tests/Library.Tests.csproj | 1 - 6 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 azure-pipelines/test.runsettings diff --git a/azure-pipelines/artifacts/coverageResults.ps1 b/azure-pipelines/artifacts/coverageResults.ps1 index 8fdb3f720..b3a08891b 100644 --- a/azure-pipelines/artifacts/coverageResults.ps1 +++ b/azure-pipelines/artifacts/coverageResults.ps1 @@ -1,10 +1,11 @@ $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") +$coverageFiles = @(Get-ChildItem "$RepoRoot/test/*.cobertura.xml" -Recurse) + # Prepare code coverage reports for merging on another machine if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`"" - $reports = Get-ChildItem "$RepoRoot/bin/coverage.*cobertura.xml" -Recurse - $reports |% { + $coverageFiles |% { $content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" } Set-Content -Path $_ -Value $content -Encoding UTF8 } @@ -16,7 +17,7 @@ if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return } @{ $RepoRoot = ( - @(Get-ChildItem "$RepoRoot\bin\coverage.*cobertura.xml" -Recurse) + + $coverageFiles + (Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse) ); } diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 43cdc3e00..24bf812a1 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -48,7 +48,8 @@ if ($x86) { --no-build ` -c $Configuration ` --filter "TestCategory!=FailsInCloudTest" ` - -p:CollectCoverage=true ` + --collect "Code Coverage;Format=cobertura" ` + --settings "$PSScriptRoot/test.runsettings" ` --blame-hang-timeout 60s ` --blame-crash ` -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 423e12fce..4bc1b3bb7 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -16,14 +16,15 @@ steps: continueOnError: true condition: ${{ parameters.includeMacOS }} - powershell: | - dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.8.5 --configfile azure-pipelines/justnugetorg.nuget.config + dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 5.1.9 --configfile azure-pipelines/justnugetorg.nuget.config Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj Write-Host 'Substituting {reporoot} with $(System.DefaultWorkingDirectory)' - $reports = Get-ChildItem -Recurse '$(Pipeline.Workspace)/coverage.*cobertura.xml' + $reports = Get-ChildItem -Recurse '$(Pipeline.Workspace)/*.cobertura.xml' $reports |% { $content = Get-Content -Path $_ |% { $_.Replace('{reporoot}', '$(System.DefaultWorkingDirectory)') } Set-Content -Path $_ -Value $content -Encoding UTF8 } + $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_ })) obj/reportgenerator -reports:"$Inputs" -targetdir:coveragereport -reporttypes:Cobertura displayName: ⚙ Merge coverage @@ -31,5 +32,5 @@ steps: displayName: 📢 Publish code coverage results to Azure DevOps inputs: codeCoverageTool: cobertura - summaryFileLocation: 'coveragereport/Cobertura.xml' + summaryFileLocation: coveragereport/Cobertura.xml failIfCoverageEmpty: true diff --git a/azure-pipelines/test.runsettings b/azure-pipelines/test.runsettings new file mode 100644 index 000000000..c69022fc0 --- /dev/null +++ b/azure-pipelines/test.runsettings @@ -0,0 +1,44 @@ + + + + + + + + + \.dll$ + \.exe$ + + + xunit\..* + + + + + ^System\.Diagnostics\.DebuggerHiddenAttribute$ + ^System\.Diagnostics\.DebuggerNonUserCodeAttribute$ + ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$ + ^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$ + + + + + True + + True + + True + + False + + True + + True + + True + + + + + + diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index 2faab3754..e7edee55a 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -1,10 +1,3 @@ - - cobertura - [xunit.*]* - - $(OutputPath)/ - - diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 402468a83..92062dc79 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,6 @@ - From f064b9a150eb529716d393fc0f1f60b55a301eb4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Jun 2022 16:22:01 -0600 Subject: [PATCH 346/641] Normalize slashes in coverage --- azure-pipelines/publish-codecoverage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 4bc1b3bb7..23e88a6e8 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -21,7 +21,8 @@ steps: Write-Host 'Substituting {reporoot} with $(System.DefaultWorkingDirectory)' $reports = Get-ChildItem -Recurse '$(Pipeline.Workspace)/*.cobertura.xml' $reports |% { - $content = Get-Content -Path $_ |% { $_.Replace('{reporoot}', '$(System.DefaultWorkingDirectory)') } + # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. + $content = Get-Content -Path $_ |% { [Regex]::Replace($_, '{reporoot}([^"]+)', { '$(System.DefaultWorkingDirectory)' + $args[0].groups[1].value.replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) }) } Set-Content -Path $_ -Value $content -Encoding UTF8 } From e903112e9ebff59ebad913bf6c89b14f97f707b1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Jun 2022 13:20:10 -0600 Subject: [PATCH 347/641] Include only unique coverage reports in artifact The test runner is creating *two* cobertura.xml files for each test run. Besides doubling the size of the coverageResults artifact, this makes the `publish-codecoverage.yml` pipeline step do much more work which can take *minutes* instead of seconds. --- azure-pipelines/artifacts/coverageResults.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/artifacts/coverageResults.ps1 b/azure-pipelines/artifacts/coverageResults.ps1 index b3a08891b..280ff9ae0 100644 --- a/azure-pipelines/artifacts/coverageResults.ps1 +++ b/azure-pipelines/artifacts/coverageResults.ps1 @@ -1,6 +1,6 @@ $RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..") -$coverageFiles = @(Get-ChildItem "$RepoRoot/test/*.cobertura.xml" -Recurse) +$coverageFiles = @(Get-ChildItem "$RepoRoot/test/*.cobertura.xml" -Recurse | Where {$_.FullName -notlike "*/In/*" -and $_.FullName -notlike "*\In\*" }) # Prepare code coverage reports for merging on another machine if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { From 704388174c49b5ae5c3c32107861710d63cd5de8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Jun 2022 13:49:49 -0600 Subject: [PATCH 348/641] Build 2.5-alpha --- .../Assets/Scripts/MessagePack/package.json | 2 +- version.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json index 19011e4fc..192c852aa 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/package.json @@ -1,7 +1,7 @@ { "name": "com.neuecc.messagepack", "displayName": "MessagePack", - "version": "2.4.25", + "version": "2.5.1-alpha", "unity": "2018.4", "description": "Extremely Fast MessagePack Serializer for C#.", "keywords": [ diff --git a/version.json b/version.json index fff14ab3f..f4ce47089 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.4", + "version": "2.5-alpha", "publicReleaseRefSpec": [ "^refs/heads/master$", "^refs/heads/v1\\.x$", From c881dcad9590e33952a956950d6a2e4c4249c0ef Mon Sep 17 00:00:00 2001 From: Steve Bush Date: Wed, 15 Jun 2022 09:02:52 -0700 Subject: [PATCH 349/641] CodeCov binary uploader Replaces the bash CodeCov uploader with the latest binary version. A PowerShell script downloads the latest codecov binary. Another PowerShell script collects and uploads code coverage artifact files to CodeCov.io. You can pass flags and a coverage report name as parameters. --- .github/workflows/build.yml | 5 ++-- azure-pipelines/Get-CodeCovTool.ps1 | 38 ++++++++++++++++++++++++++ azure-pipelines/dotnet.yml | 5 +++- azure-pipelines/publish-CodeCov.ps1 | 42 +++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 azure-pipelines/Get-CodeCovTool.ps1 create mode 100644 azure-pipelines/publish-CodeCov.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4db43f53c..cde83cd9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,7 +109,8 @@ jobs: path: ${{ runner.temp }}/_artifacts/deployables if: always() - name: Publish code coverage results to codecov.io - run: bash <(curl -s https://codecov.io/bash) - shell: bash + run: ./azure-pipelines/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}Host,${{ env.BUILDCONFIGURATION }}" + shell: pwsh timeout-minutes: 3 continue-on-error: true + if: always() diff --git a/azure-pipelines/Get-CodeCovTool.ps1 b/azure-pipelines/Get-CodeCovTool.ps1 new file mode 100644 index 000000000..d6ca157bf --- /dev/null +++ b/azure-pipelines/Get-CodeCovTool.ps1 @@ -0,0 +1,38 @@ +<# +.SYNOPSIS + Downloads the CodeCov.io uploader tool and returns the path to it. +#> +[CmdletBinding()] +Param( +) + +$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1" +$binaryToolsPath = Join-Path $toolsPath codecov +if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath } + +if ($IsMacOS) +{ + $codeCovPath = Join-Path $binaryToolsPath codecov + $codeCovUrl = "https://uploader.codecov.io/latest/macos/codecov" +} +elseif ($IsLinux) +{ + $codeCovPath = Join-Path $binaryToolsPath codecov + $codeCovUrl = "https://uploader.codecov.io/latest/linux/codecov" +} +else +{ + $codeCovPath = Join-Path $binaryToolsPath codecov.exe + $codeCovUrl = "https://uploader.codecov.io/latest/windows/codecov.exe" +} + +if (!(Test-Path $codeCovPath)) { + Write-Host "Downloading latest codeconv..." -ForegroundColor Yellow + (New-Object System.Net.WebClient).DownloadFile($codeCovUrl, $codeCovPath) +} + +if ($IsMacOS -or $IsLinux) { + chmod u+x $codeCovPath +} + +return (Resolve-Path $codeCovPath).Path diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 1d7d9de76..a461c147d 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -16,7 +16,10 @@ steps: displayName: 📢 Publish artifacts condition: succeededOrFailed() -- bash: bash <(curl -s https://codecov.io/bash) +- powershell: | + $ArtifactStagingFolder = & "azure-pipelines/Get-ArtifactsStagingDirectory.ps1" + $CoverageResultsFolder = Join-Path $ArtifactStagingFolder "coverageResults-$(Agent.JobName)" + azure-pipelines/publish-CodeCov.ps1 -CodeCovToken "$(codecov_token)" -PathToCodeCoverage "$CoverageResultsFolder" -Name "$(Agent.JobName) Coverage Results" -Flags "$(Agent.JobName)Host,$(BuildConfiguration)" displayName: 📢 Publish code coverage results to codecov.io condition: ne(variables['codecov_token'], '') timeoutInMinutes: 3 diff --git a/azure-pipelines/publish-CodeCov.ps1 b/azure-pipelines/publish-CodeCov.ps1 new file mode 100644 index 000000000..ec550e7aa --- /dev/null +++ b/azure-pipelines/publish-CodeCov.ps1 @@ -0,0 +1,42 @@ +<# +.SYNOPSIS + Uploads code coverage to codecov.io +.PARAMETER CodeCovToken + Code coverage token to use +.PARAMETER PathToCodeCoverage + Path to root of code coverage files +.PARAMETER Name + Optional name to upload with codecoverge +.PARAMETER Flags + Optional flags to upload with codecoverge +#> +[CmdletBinding()] +Param ( + [string]$CodeCovToken, + [string]$PathToCodeCoverage, + [string]$Name="", + [string]$Flags="" +) + +$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path +$CodeCoveragePathWildcard = (Join-Path $PathToCodeCoverage "*.cobertura.xml") + +Write-Host "RepoRoot: $RepoRoot" -ForegroundColor Yellow +Write-Host "CodeCoveragePathWildcard: $CodeCoveragePathWildcard" -ForegroundColor Yellow + +Get-ChildItem -Recurse -Path $CodeCoveragePathWildcard | % { + + if ($IsMacOS -or $IsLinux) + { + $relativeFilePath = Resolve-Path -relative $_ + } + else + { + $relativeFilePath = Resolve-Path -relative (Get-ChildItem $_ | Select-Object -ExpandProperty Target) + } + + Write-Host "Uploading: $relativeFilePath" -ForegroundColor Yellow + Write-Host "Flags: $Flags$TargetFrameworkFlag$TestTypeFlag$OSTypeFlag" -ForegroundColor Yellow + + & (& "$PSScriptRoot/Get-CodeCovTool.ps1") -t "$CodeCovToken" -f "$relativeFilePath" -R "$RepoRoot" -F "$Flags" -n "$Name" +} From 79a441098f323457a8033a09a843300b00631de3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Jun 2022 13:08:50 -0600 Subject: [PATCH 350/641] Add completions for dotnet-test-cloud script --- azure-pipelines/dotnet-test-cloud.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 24bf812a1..d07f1ad8f 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -16,6 +16,7 @@ #> [CmdletBinding()] Param( + [ValidateSet('Debug', 'Release')] [string]$Configuration='Debug', [string]$Agent='Local', [switch]$PublishResults, From 85d970c258bafda482b003ba79f4510a491a570d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 15 Jun 2022 13:09:08 -0600 Subject: [PATCH 351/641] Move coverage merge script to a ps1 that can be locally invoked --- .gitignore | 1 + azure-pipelines/Merge-CodeCoverage.ps1 | 42 ++++++++++++++++++++++++ azure-pipelines/publish-codecoverage.yml | 14 +------- 3 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 azure-pipelines/Merge-CodeCoverage.ps1 diff --git a/.gitignore b/.gitignore index 65f947769..3bb499198 100644 --- a/.gitignore +++ b/.gitignore @@ -140,6 +140,7 @@ _TeamCity* # Visual Studio code coverage results *.coverage *.coveragexml +/coveragereport/ # NCrunch _NCrunch_* diff --git a/azure-pipelines/Merge-CodeCoverage.ps1 b/azure-pipelines/Merge-CodeCoverage.ps1 new file mode 100644 index 000000000..6672b94cd --- /dev/null +++ b/azure-pipelines/Merge-CodeCoverage.ps1 @@ -0,0 +1,42 @@ +#!/usr/bin/env pwsh + +<# +.SYNOPSIS + Merges code coverage reports. +.PARAMETER Path + The path(s) to search for Cobertura code coverage reports. +.PARAMETER Format + The format for the merged result. The default is Cobertura +.PARAMETER OutputDir + The directory the merged result will be written to. The default is `coveragereport` in the root of this repo. +#> +[CmdletBinding()] +Param( + [Parameter(Mandatory=$true)] + [string[]]$Path, + [ValidateSet('Badges', 'Clover', 'Cobertura', 'CsvSummary', 'Html', 'Html_Dark', 'Html_Light', 'HtmlChart', 'HtmlInline', 'HtmlInline_AzurePipelines', 'HtmlInline_AzurePipelines_Dark', 'HtmlInline_AzurePipelines_Light', 'HtmlSummary', 'JsonSummary', 'Latex', 'LatexSummary', 'lcov', 'MarkdownSummary', 'MHtml', 'PngChart', 'SonarQube', 'TeamCitySummary', 'TextSummary', 'Xml', 'XmlSummary')] + [string]$Format='Cobertura', + [string]$OutputDir=("$PSScriptRoot/../coveragereport") +) + +$RepoRoot = [string](Resolve-Path $PSScriptRoot/..) + +if (!(Test-Path $RepoRoot/obj/reportgenerator*)) { + dotnet tool install --tool-path $RepoRoot/obj dotnet-reportgenerator-globaltool --version 5.1.9 --configfile $PSScriptRoot/justnugetorg.nuget.config +} + +Write-Verbose "Searching $Path for *.cobertura.xml files" +$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml + +if ($reports) { + $reports |% { $_.FullName } |% { + # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. + $content = Get-Content -Path $_ |% { [Regex]::Replace($_, '{reporoot}([^"]+)', { $RepoRoot + $args[0].groups[1].value.replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) }) } + Set-Content -Path $_ -Value $content -Encoding UTF8 + } + + $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_.FullName })) + & "$RepoRoot/obj/reportgenerator" -reports:"$Inputs" -targetdir:$OutputDir -reporttypes:$Format +} else { + Write-Error "No reports found to merge." +} diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 23e88a6e8..6e7ef21bd 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -15,19 +15,7 @@ steps: displayName: 🔻 Download macOS code coverage results continueOnError: true condition: ${{ parameters.includeMacOS }} -- powershell: | - dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 5.1.9 --configfile azure-pipelines/justnugetorg.nuget.config - Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj - Write-Host 'Substituting {reporoot} with $(System.DefaultWorkingDirectory)' - $reports = Get-ChildItem -Recurse '$(Pipeline.Workspace)/*.cobertura.xml' - $reports |% { - # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. - $content = Get-Content -Path $_ |% { [Regex]::Replace($_, '{reporoot}([^"]+)', { '$(System.DefaultWorkingDirectory)' + $args[0].groups[1].value.replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) }) } - Set-Content -Path $_ -Value $content -Encoding UTF8 - } - - $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_ })) - obj/reportgenerator -reports:"$Inputs" -targetdir:coveragereport -reporttypes:Cobertura +- powershell: azure-pipelines/Merge-CodeCoverage.ps1 -Path '$(Pipeline.Workspace)' -OutputDir coveragereport -Format Cobertura -Verbose displayName: ⚙ Merge coverage - task: PublishCodeCoverageResults@1 displayName: 📢 Publish code coverage results to Azure DevOps From ac247b8566c88e201f1df92013048ce7f3a30772 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 17 Jun 2022 15:44:22 -0600 Subject: [PATCH 352/641] Revert "Add completions for dotnet-test-cloud script" It was problematic since it disallowed non-default config names. This reverts commit 79a441098f323457a8033a09a843300b00631de3. --- azure-pipelines/dotnet-test-cloud.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index d07f1ad8f..24bf812a1 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -16,7 +16,6 @@ #> [CmdletBinding()] Param( - [ValidateSet('Debug', 'Release')] [string]$Configuration='Debug', [string]$Agent='Local', [switch]$PublishResults, From 6156061d6576a32b150393a22787c24629ef1545 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 18 Jun 2022 12:15:07 -0600 Subject: [PATCH 353/641] Touch-up formatting and simplify/correct a bit --- azure-pipelines/Get-CodeCovTool.ps1 | 11 ++++------- azure-pipelines/publish-CodeCov.ps1 | 30 +++++++++-------------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/azure-pipelines/Get-CodeCovTool.ps1 b/azure-pipelines/Get-CodeCovTool.ps1 index d6ca157bf..63b5d3f3c 100644 --- a/azure-pipelines/Get-CodeCovTool.ps1 +++ b/azure-pipelines/Get-CodeCovTool.ps1 @@ -10,24 +10,21 @@ $toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1" $binaryToolsPath = Join-Path $toolsPath codecov if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath } -if ($IsMacOS) -{ +if ($IsMacOS) { $codeCovPath = Join-Path $binaryToolsPath codecov $codeCovUrl = "https://uploader.codecov.io/latest/macos/codecov" } -elseif ($IsLinux) -{ +elseif ($IsLinux) { $codeCovPath = Join-Path $binaryToolsPath codecov $codeCovUrl = "https://uploader.codecov.io/latest/linux/codecov" } -else -{ +else { $codeCovPath = Join-Path $binaryToolsPath codecov.exe $codeCovUrl = "https://uploader.codecov.io/latest/windows/codecov.exe" } if (!(Test-Path $codeCovPath)) { - Write-Host "Downloading latest codeconv..." -ForegroundColor Yellow + Write-Host "Downloading latest codecov upload tool..." -ForegroundColor Yellow (New-Object System.Net.WebClient).DownloadFile($codeCovUrl, $codeCovPath) } diff --git a/azure-pipelines/publish-CodeCov.ps1 b/azure-pipelines/publish-CodeCov.ps1 index ec550e7aa..1f4d3790f 100644 --- a/azure-pipelines/publish-CodeCov.ps1 +++ b/azure-pipelines/publish-CodeCov.ps1 @@ -6,37 +6,25 @@ .PARAMETER PathToCodeCoverage Path to root of code coverage files .PARAMETER Name - Optional name to upload with codecoverge + Name to upload with codecoverge .PARAMETER Flags - Optional flags to upload with codecoverge + Flags to upload with codecoverge #> [CmdletBinding()] Param ( + [Parameter(Mandatory=$true)] [string]$CodeCovToken, + [Parameter(Mandatory=$true)] [string]$PathToCodeCoverage, - [string]$Name="", - [string]$Flags="" + [string]$Name, + [string]$Flags ) $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path -$CodeCoveragePathWildcard = (Join-Path $PathToCodeCoverage "*.cobertura.xml") -Write-Host "RepoRoot: $RepoRoot" -ForegroundColor Yellow -Write-Host "CodeCoveragePathWildcard: $CodeCoveragePathWildcard" -ForegroundColor Yellow - -Get-ChildItem -Recurse -Path $CodeCoveragePathWildcard | % { - - if ($IsMacOS -or $IsLinux) - { - $relativeFilePath = Resolve-Path -relative $_ - } - else - { - $relativeFilePath = Resolve-Path -relative (Get-ChildItem $_ | Select-Object -ExpandProperty Target) - } +Get-ChildItem -Recurse -Path $PathToCodeCoverage -Filter "*.cobertura.xml" | % { + $relativeFilePath = Resolve-Path -relative $_ Write-Host "Uploading: $relativeFilePath" -ForegroundColor Yellow - Write-Host "Flags: $Flags$TargetFrameworkFlag$TestTypeFlag$OSTypeFlag" -ForegroundColor Yellow - - & (& "$PSScriptRoot/Get-CodeCovTool.ps1") -t "$CodeCovToken" -f "$relativeFilePath" -R "$RepoRoot" -F "$Flags" -n "$Name" + & (& "$PSScriptRoot/Get-CodeCovTool.ps1") -t $CodeCovToken -f $relativeFilePath -R $RepoRoot -F $Flags -n $Name } From 50d35dfde8113caedeca40f6c14d8b93686b3055 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 18 Jun 2022 15:22:38 -0600 Subject: [PATCH 354/641] fixup --- azure-pipelines/publish-CodeCov.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/publish-CodeCov.ps1 b/azure-pipelines/publish-CodeCov.ps1 index 1f4d3790f..9926f0188 100644 --- a/azure-pipelines/publish-CodeCov.ps1 +++ b/azure-pipelines/publish-CodeCov.ps1 @@ -23,7 +23,7 @@ Param ( $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path Get-ChildItem -Recurse -Path $PathToCodeCoverage -Filter "*.cobertura.xml" | % { - $relativeFilePath = Resolve-Path -relative $_ + $relativeFilePath = Resolve-Path -relative $_.FullName Write-Host "Uploading: $relativeFilePath" -ForegroundColor Yellow & (& "$PSScriptRoot/Get-CodeCovTool.ps1") -t $CodeCovToken -f $relativeFilePath -R $RepoRoot -F $Flags -n $Name From 8abd437547653f0c2a01eb96dcf75d9945829cf0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 18 Jun 2022 14:54:27 -0600 Subject: [PATCH 355/641] Add signature validation --- azure-pipelines/Get-CodeCovTool.ps1 | 77 ++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/azure-pipelines/Get-CodeCovTool.ps1 b/azure-pipelines/Get-CodeCovTool.ps1 index 63b5d3f3c..ca580b4db 100644 --- a/azure-pipelines/Get-CodeCovTool.ps1 +++ b/azure-pipelines/Get-CodeCovTool.ps1 @@ -1,35 +1,86 @@ <# .SYNOPSIS Downloads the CodeCov.io uploader tool and returns the path to it. +.PARAMETER AllowSkipVerify + Allows skipping signature verification of the downloaded tool if gpg is not installed. #> [CmdletBinding()] Param( + [switch]$AllowSkipVerify ) -$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1" -$binaryToolsPath = Join-Path $toolsPath codecov -if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath } - if ($IsMacOS) { - $codeCovPath = Join-Path $binaryToolsPath codecov $codeCovUrl = "https://uploader.codecov.io/latest/macos/codecov" + $toolName = 'codecov' } elseif ($IsLinux) { - $codeCovPath = Join-Path $binaryToolsPath codecov $codeCovUrl = "https://uploader.codecov.io/latest/linux/codecov" + $toolName = 'codecov' } else { - $codeCovPath = Join-Path $binaryToolsPath codecov.exe $codeCovUrl = "https://uploader.codecov.io/latest/windows/codecov.exe" + $toolName = 'codecov.exe' } -if (!(Test-Path $codeCovPath)) { - Write-Host "Downloading latest codecov upload tool..." -ForegroundColor Yellow - (New-Object System.Net.WebClient).DownloadFile($codeCovUrl, $codeCovPath) +$shaSuffix = ".SHA256SUM" +$sigSuffix = $shaSuffix + ".sig" + +Function Get-FileFromWeb([Uri]$Uri, $OutDir) { + $OutFile = Join-Path $OutDir $Uri.Segments[-1] + if (!(Test-Path $OutFile)) { + Write-Verbose "Downloading $Uri..." + if (!(Test-Path $OutDir)) { New-Item -ItemType Directory -Path $OutDir | Out-Null } + try { + (New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile) + } finally { + # This try/finally causes the script to abort + } + } + + $OutFile } -if ($IsMacOS -or $IsLinux) { - chmod u+x $codeCovPath +$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1" +$binaryToolsPath = Join-Path $toolsPath codecov +$testingPath = Join-Path $binaryToolsPath unverified +$finalToolPath = Join-Path $binaryToolsPath $toolName + +if (!(Test-Path $finalToolPath)) { + if (Test-Path $testingPath) { + Remove-Item -Recurse -Force $testingPath # ensure we download all matching files + } + $tool = Get-FileFromWeb $codeCovUrl $testingPath + $sha = Get-FileFromWeb "$codeCovUrl$shaSuffix" $testingPath + $sig = Get-FileFromWeb "$codeCovUrl$sigSuffix" $testingPath + $key = Get-FileFromWeb https://keybase.io/codecovsecurity/pgp_keys.asc $testingPath + + if ((Get-Command gpg -ErrorAction SilentlyContinue)) { + Write-Host "Importing codecov key" -ForegroundColor Yellow + gpg --import $key + Write-Host "Verifying signature on codecov hash" -ForegroundColor Yellow + gpg --verify $sig $sha + } else { + if ($AllowSkipVerify) { + Write-Warning "gpg not found. Unable to verify hash signature." + } else { + throw "gpg not found. Unable to verify hash signature. Install gpg or add -AllowSkipVerify to override." + } + } + + Write-Host "Verifying hash on downloaded tool" -ForegroundColor Yellow + $actualHash = (Get-FileHash -Path $tool -Algorithm SHA256).Hash + $expectedHash = (Get-Content $sha).Split()[0] + if ($actualHash -ne $expectedHash) { + # Validation failed. Delete the tool so we can't execute it. + #Remove-Item $codeCovPath + throw "codecov uploader tool failed signature validation." + } + + Copy-Item $tool $finalToolPath + + if ($IsMacOS -or $IsLinux) { + chmod u+x $finalToolPath + } } -return (Resolve-Path $codeCovPath).Path +return $finalToolPath From d0b0b55b461068eb2b7cc3c5e440880cf5203b75 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 18 Jun 2022 17:57:28 -0600 Subject: [PATCH 356/641] Fix perf scaling issue in merging coverage reports --- azure-pipelines/Merge-CodeCoverage.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/Merge-CodeCoverage.ps1 b/azure-pipelines/Merge-CodeCoverage.ps1 index 6672b94cd..91ab67ab3 100644 --- a/azure-pipelines/Merge-CodeCoverage.ps1 +++ b/azure-pipelines/Merge-CodeCoverage.ps1 @@ -31,8 +31,12 @@ $reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml if ($reports) { $reports |% { $_.FullName } |% { # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. - $content = Get-Content -Path $_ |% { [Regex]::Replace($_, '{reporoot}([^"]+)', { $RepoRoot + $args[0].groups[1].value.replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) }) } - Set-Content -Path $_ -Value $content -Encoding UTF8 + $xml = [xml](Get-Content -Path $_) + $xml.coverage.packages.package.classes.class |? { $_.filename} |% { + $_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) + } + + $xml.Save($_) } $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_.FullName })) From fa0ac399504747ba4f8b71bfab31a974698811a6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Jun 2022 08:44:04 -0600 Subject: [PATCH 357/641] Log _pipelines scripts verbosely --- azure-pipelines/artifacts/_all.ps1 | 1 + azure-pipelines/artifacts/_pipelines.ps1 | 8 ++++++-- azure-pipelines/artifacts/_stage_all.ps1 | 10 +++++++--- azure-pipelines/artifacts/testResults.ps1 | 4 ++++ azure-pipelines/dotnet.yml | 2 +- azure-pipelines/variables/_all.ps1 | 11 +++++++++-- azure-pipelines/variables/_pipelines.ps1 | 15 +++++++++++---- 7 files changed, 39 insertions(+), 12 deletions(-) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index c9182a45a..033cc87c9 100755 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -15,6 +15,7 @@ Executes artifact scripts even if they have already been staged. #> +[CmdletBinding(SupportsShouldProcess = $true)] param ( [string]$ArtifactNameSuffix, [switch]$Force diff --git a/azure-pipelines/artifacts/_pipelines.ps1 b/azure-pipelines/artifacts/_pipelines.ps1 index a62d2675b..2d3338b24 100644 --- a/azure-pipelines/artifacts/_pipelines.ps1 +++ b/azure-pipelines/artifacts/_pipelines.ps1 @@ -1,6 +1,10 @@ -# This script translates all the artifacts described by _all.ps1 -# into commands that instruct Azure Pipelines to actually collect those artifacts. +<# +.SYNOPSIS + This script translates all the artifacts described by _all.ps1 + into commands that instruct Azure Pipelines to actually collect those artifacts. +#> +[CmdletBinding()] param ( [string]$ArtifactNameSuffix, [switch]$StageOnly diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index b7166b4eb..d81d16d46 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -1,6 +1,10 @@ -# This script links all the artifacts described by _all.ps1 -# into a staging directory, reading for uploading to a cloud build artifact store. -# It returns a sequence of objects with Name and Path properties. +<# +.SYNOPSIS + This script links all the artifacts described by _all.ps1 + into a staging directory, reading for uploading to a cloud build artifact store. + It returns a sequence of objects with Name and Path properties. +#> + [CmdletBinding()] param ( [string]$ArtifactNameSuffix diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index 2f894c97b..4fa0fe62b 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -1,3 +1,7 @@ +[CmdletBinding()] +Param( +) + $result = @{} if ($env:AGENT_TEMPDIRECTORY) { diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index a461c147d..ca9fc9b8a 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -11,7 +11,7 @@ steps: displayName: ⚙ Update pipeline variables based on build outputs condition: succeededOrFailed() -- powershell: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)" +- powershell: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)" -Verbose failOnStderr: true displayName: 📢 Publish artifacts condition: succeededOrFailed() diff --git a/azure-pipelines/variables/_all.ps1 b/azure-pipelines/variables/_all.ps1 index 0407d307e..cc6e88105 100755 --- a/azure-pipelines/variables/_all.ps1 +++ b/azure-pipelines/variables/_all.ps1 @@ -1,7 +1,14 @@ #!/usr/bin/env pwsh -# This script returns a hashtable of build variables that should be set -# at the start of a build or release definition's execution. +<# +.SYNOPSIS + This script returns a hashtable of build variables that should be set + at the start of a build or release definition's execution. +#> + +[CmdletBinding(SupportsShouldProcess = $true)] +param ( +) $vars = @{} diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 867b7fc8b..951106d2d 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -1,8 +1,15 @@ -# This script translates the variables returned by the _all.ps1 script -# into commands that instruct Azure Pipelines to actually set those variables for other pipeline tasks to consume. +<# +.SYNOPSIS + This script translates the variables returned by the _all.ps1 script + into commands that instruct Azure Pipelines to actually set those variables for other pipeline tasks to consume. -# The build or release definition may have set these variables to override -# what the build would do. So only set them if they have not already been set. + The build or release definition may have set these variables to override + what the build would do. So only set them if they have not already been set. +#> + +[CmdletBinding()] +param ( +) (& "$PSScriptRoot\_all.ps1").GetEnumerator() |% { # Always use ALL CAPS for env var names since Azure Pipelines converts variable names to all caps and on non-Windows OS, env vars are case sensitive. From cb730eacdd53e4ca06b7f9c74b06da74f44db3a9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Jun 2022 08:46:30 -0600 Subject: [PATCH 358/641] Collect test results from the right directory The dump files used to be written to an agent TEMP directory. Somewhere along the lines they moved to the TestResults directory within the repo itself. Fixes AArnott/Library.Template#167 --- azure-pipelines/artifacts/testResults.ps1 | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/azure-pipelines/artifacts/testResults.ps1 b/azure-pipelines/artifacts/testResults.ps1 index 4fa0fe62b..301a43763 100644 --- a/azure-pipelines/artifacts/testResults.ps1 +++ b/azure-pipelines/artifacts/testResults.ps1 @@ -4,17 +4,8 @@ Param( $result = @{} -if ($env:AGENT_TEMPDIRECTORY) { - # The DotNetCoreCLI uses an alternate location to publish these files - $guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$' - $result[$env:AGENT_TEMPDIRECTORY] = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { - Get-ChildItem "$($_.FullName)\dotnet*.dmp","$($_.FullName)\*_crashdump.dmp","$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse - }); -} -else { - $testRoot = Resolve-Path "$PSScriptRoot\..\..\test" - $result[$testRoot] = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File) -} +$testRoot = Resolve-Path "$PSScriptRoot\..\..\test" +$result[$testRoot] = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File) $testlogsPath = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\test_logs" if (Test-Path $testlogsPath) { From 540ea6a9b78c8c2a8e99ffb553ba523defaa7e81 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Jun 2022 16:25:12 -0600 Subject: [PATCH 359/641] Prepare release notes with breaking changes --- azure-pipelines/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index 2679b24e7..4c9db860a 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -51,6 +51,7 @@ jobs: changeLogType: issueBased changeLogLabels: | [ + { "label" : "breaking change", "displayName" : "Breaking changes", "state" : "closed" }, { "label" : "bug", "displayName" : "Fixes", "state" : "closed" }, { "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" } ] From c5683bea1c776521445818e010a656a96d58b873 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 21 Jul 2022 21:14:22 -0600 Subject: [PATCH 360/641] Fix symbol file collection when the dll or exe is missing --- azure-pipelines/Get-SymbolFiles.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/Get-SymbolFiles.ps1 b/azure-pipelines/Get-SymbolFiles.ps1 index fccb1bb13..9183c340e 100644 --- a/azure-pipelines/Get-SymbolFiles.ps1 +++ b/azure-pipelines/Get-SymbolFiles.ps1 @@ -49,8 +49,13 @@ $PDBs |% { $BinaryImagePath = $dllPath } elseif (Test-Path $exePath) { $BinaryImagePath = $exePath + } else { + Write-Warning "`"$_`" found with no matching binary file." + $BinaryImagePath = $null } - Write-Output $BinaryImagePath - Write-Output $_.FullName + if ($BinaryImagePath) { + Write-Output $BinaryImagePath + Write-Output $_.FullName + } } From 61d196d2f402a801021181af67f52422e82b72fd Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Jul 2022 08:03:59 -0600 Subject: [PATCH 361/641] Add disabled test for supporting Union on concrete classes A step toward fixing #1465 --- .../Tests/ShareTests/UnionResolverTest.cs | 71 ++++++++++++++++--- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/UnionResolverTest.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/UnionResolverTest.cs index 27f265dc0..2a365c1a6 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/UnionResolverTest.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/UnionResolverTest.cs @@ -109,23 +109,44 @@ public void Union2() } [Fact] - public void ClassUnion() + public void AbstractClassUnion() { - ////var a = new RootUnionType() { MyProperty = 10 }; var b = new SubUnionType1() { MyProperty = 11, MyProperty1 = 100 }; var c = new SubUnionType2() { MyProperty = 12, MyProperty2 = 200 }; - //// var binA = MessagePackSerializer.Serialize(a); var binB = MessagePackSerializer.Serialize(b); var binC = MessagePackSerializer.Serialize(c); - var b2 = MessagePackSerializer.Deserialize(binB) as SubUnionType1; - var c2 = MessagePackSerializer.Deserialize(binC) as SubUnionType2; + var dB = (SubUnionType1)MessagePackSerializer.Deserialize(binB); + Assert.Equal(11, dB.MyProperty); + Assert.Equal(100, dB.MyProperty1); - b2.MyProperty.Is(11); - b2.MyProperty1.Is(100); - c2.MyProperty.Is(12); - c2.MyProperty2.Is(200); + var dC = (SubUnionType2)MessagePackSerializer.Deserialize(binC); + Assert.Equal(12, dC.MyProperty); + Assert.Equal(200, dC.MyProperty2); + } + + [Fact(Skip = "Not implemented. See https://github.com/neuecc/MessagePack-CSharp/issues/1465")] + public void ConcreteClassUnion() + { + var a = new ConcreteClassUnion.RootUnionType() { MyProperty = 10 }; + var b = new ConcreteClassUnion.SubUnionType1() { MyProperty = 11, MyProperty1 = 100 }; + var c = new ConcreteClassUnion.SubUnionType2() { MyProperty = 12, MyProperty2 = 200 }; + + var binA = MessagePackSerializer.Serialize(a); + var binB = MessagePackSerializer.Serialize(b); + var binC = MessagePackSerializer.Serialize(c); + + var dA = MessagePackSerializer.Deserialize(binA); + Assert.Equal(10, dA.MyProperty); + + var dB = (ConcreteClassUnion.SubUnionType1)MessagePackSerializer.Deserialize(binB); + Assert.Equal(11, dB.MyProperty); + Assert.Equal(100, dB.MyProperty1); + + var dC = (ConcreteClassUnion.SubUnionType2)MessagePackSerializer.Deserialize(binC); + Assert.Equal(12, dC.MyProperty); + Assert.Equal(200, dC.MyProperty2); } [Theory] @@ -363,8 +384,9 @@ public class C2WithStringSubType : B2WithStringSubType namespace ClassUnion { - [Union(0, typeof(SubUnionType1))] - [Union(1, typeof(SubUnionType2))] + [Union(0, typeof(RootUnionType))] + [Union(1, typeof(SubUnionType1))] + [Union(2, typeof(SubUnionType2))] [MessagePackObject] public abstract class RootUnionType { @@ -387,6 +409,33 @@ public class SubUnionType2 : RootUnionType } } +namespace ConcreteClassUnion +{ + [Union(0, typeof(RootUnionType))] + [Union(1, typeof(SubUnionType1))] + [Union(2, typeof(SubUnionType2))] + [MessagePackObject] + public class RootUnionType + { + [Key(0)] + public int MyProperty { get; set; } + } + + [MessagePackObject] + public class SubUnionType1 : RootUnionType + { + [Key(1)] + public int MyProperty1 { get; set; } + } + + [MessagePackObject] + public class SubUnionType2 : RootUnionType + { + [Key(1)] + public int MyProperty2 { get; set; } + } +} + namespace UnionWithStrings { [Union(0, "UnionWithStrings.MySubUnion1WithStringSubType, MessagePack.Tests")] From 0bb373adc92cdaca099a82d4dcdb1d59c8f73ffe Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 27 Jul 2022 13:58:05 -0600 Subject: [PATCH 362/641] Fix WPF workaround This presumably broke when the intermediate directory was changed to include the relative path to the project directory. --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 22c1b94de..dcf31a292 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -75,7 +75,7 @@ It's also not necessary to generate these assets. --> - <_WpfTempProjectNuGetFilePathNoExt>$(RepoRootPath)obj\$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g + <_WpfTempProjectNuGetFilePathNoExt>$(BaseIntermediateOutputPath)..\$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g false false From 3ec6f43d2500784af5585714d411cbf33d9bd55c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 12:25:45 -0600 Subject: [PATCH 363/641] Bump Nullable from 1.3.0 to 1.3.1 (#172) Bumps [Nullable](https://github.com/manuelroemer/Nullable) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/manuelroemer/Nullable/releases) - [Changelog](https://github.com/manuelroemer/Nullable/blob/master/CHANGELOG.md) - [Commits](https://github.com/manuelroemer/Nullable/commits) --- updated-dependencies: - dependency-name: Nullable dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index dcf31a292..c2b4b004f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -38,7 +38,7 @@ - + From 45948958aece65a9048c74443139f5ce5fed952d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 18:33:20 +0000 Subject: [PATCH 364/641] Bump Nerdbank.GitVersioning from 3.5.107 to 3.5.108 (#171) --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index c2b4b004f..d13dbc489 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,7 +37,7 @@ - + From b39494e5d1115a599f4ed01565bc5419a8dace36 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Aug 2022 09:16:02 -0600 Subject: [PATCH 365/641] Make running tests in a pipeline optional --- azure-pipelines.yml | 5 +++++ azure-pipelines/build.yml | 16 +++++++++++++--- azure-pipelines/dotnet.yml | 4 ++++ azure-pipelines/publish-codecoverage.yml | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d98ed107d..2cac17bd9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,6 +17,10 @@ parameters: displayName: Build on macOS type: boolean default: false # macOS is often bogged down in Azure Pipelines +- name: RunTests + displayName: Run tests + type: boolean + default: true variables: TreatWarningsAsErrors: true @@ -30,3 +34,4 @@ jobs: - template: azure-pipelines/build.yml parameters: includeMacOS: ${{ parameters.includeMacOS }} + RunTests: ${{ parameters.RunTests }} diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 5bfd95f53..cb4899493 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -4,6 +4,9 @@ parameters: default: vmImage: windows-2022 - name: includeMacOS +- name: RunTests + type: boolean + default: true jobs: - job: Windows @@ -17,6 +20,8 @@ jobs: displayName: ⚙ Set build number - template: dotnet.yml + parameters: + RunTests: ${{ parameters.RunTests }} - template: expand-template.yml - job: Linux @@ -27,6 +32,8 @@ jobs: clean: true - template: install-dependencies.yml - template: dotnet.yml + parameters: + RunTests: ${{ parameters.RunTests }} - template: expand-template.yml - job: macOS @@ -38,6 +45,8 @@ jobs: clean: true - template: install-dependencies.yml - template: dotnet.yml + parameters: + RunTests: ${{ parameters.RunTests }} - template: expand-template.yml - job: WrapUp @@ -56,7 +65,8 @@ jobs: - template: publish-symbols.yml parameters: includeMacOS: ${{ parameters.includeMacOS }} - - template: publish-codecoverage.yml - parameters: - includeMacOS: ${{ parameters.includeMacOS }} + - ${{ if parameters.RunTests }}: + - template: publish-codecoverage.yml + parameters: + includeMacOS: ${{ parameters.includeMacOS }} - template: publish-deployables.yml diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index ca9fc9b8a..055d44e90 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -1,3 +1,6 @@ +parameters: + RunTests: + steps: - script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" @@ -5,6 +8,7 @@ steps: - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults displayName: 🧪 dotnet test + condition: and(succeeded(), ${{ parameters.RunTests }}) - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 6e7ef21bd..11de8ffa1 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -14,7 +14,7 @@ steps: artifact: coverageResults-macOS displayName: 🔻 Download macOS code coverage results continueOnError: true - condition: ${{ parameters.includeMacOS }} + condition: and(succeeded(), ${{ parameters.includeMacOS }}) - powershell: azure-pipelines/Merge-CodeCoverage.ps1 -Path '$(Pipeline.Workspace)' -OutputDir coveragereport -Format Cobertura -Verbose displayName: ⚙ Merge coverage - task: PublishCodeCoverageResults@1 From 13d3a5635b19b6c4f7078059ebe042d3b38be9a3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 4 Aug 2022 12:42:45 -0600 Subject: [PATCH 366/641] Detect more test assemblies --- azure-pipelines/Get-SymbolFiles.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/Get-SymbolFiles.ps1 b/azure-pipelines/Get-SymbolFiles.ps1 index 9183c340e..0ce229fc2 100644 --- a/azure-pipelines/Get-SymbolFiles.ps1 +++ b/azure-pipelines/Get-SymbolFiles.ps1 @@ -18,7 +18,7 @@ Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files" $PDBs = Get-ChildItem -rec "$Path/*.pdb" # Filter PDBs to product OR test related. -$testregex = "unittest|tests" +$testregex = "unittest|tests|\.test\." Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" $PDBsByHash = @{} From d69d108c08c1e70399920a54e06aa5cfc050dd47 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 5 Aug 2022 08:43:45 -0600 Subject: [PATCH 367/641] Hide the codecov publish task if it won't run Instead of showing it as a skipped task, just hide it if we won't run it because no codecov_token is provided. --- .github/workflows/build.yml | 2 +- azure-pipelines/dotnet.yml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cde83cd9b..2c4ba94c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ env: TreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BUILDCONFIGURATION: Release - codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ + # codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/ jobs: diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 055d44e90..79babd4d4 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -20,11 +20,11 @@ steps: displayName: 📢 Publish artifacts condition: succeededOrFailed() -- powershell: | - $ArtifactStagingFolder = & "azure-pipelines/Get-ArtifactsStagingDirectory.ps1" - $CoverageResultsFolder = Join-Path $ArtifactStagingFolder "coverageResults-$(Agent.JobName)" - azure-pipelines/publish-CodeCov.ps1 -CodeCovToken "$(codecov_token)" -PathToCodeCoverage "$CoverageResultsFolder" -Name "$(Agent.JobName) Coverage Results" -Flags "$(Agent.JobName)Host,$(BuildConfiguration)" - displayName: 📢 Publish code coverage results to codecov.io - condition: ne(variables['codecov_token'], '') - timeoutInMinutes: 3 - continueOnError: true +- ${{ if and(ne(variables['codecov_token'], ''), parameters.RunTests) }}: + - powershell: | + $ArtifactStagingFolder = & "azure-pipelines/Get-ArtifactsStagingDirectory.ps1" + $CoverageResultsFolder = Join-Path $ArtifactStagingFolder "coverageResults-$(Agent.JobName)" + azure-pipelines/publish-CodeCov.ps1 -CodeCovToken "$(codecov_token)" -PathToCodeCoverage "$CoverageResultsFolder" -Name "$(Agent.JobName) Coverage Results" -Flags "$(Agent.JobName)Host,$(BuildConfiguration)" + displayName: 📢 Publish code coverage results to codecov.io + timeoutInMinutes: 3 + continueOnError: true From 615d9494c8795052df21a2b8d1b6cc28ee378f79 Mon Sep 17 00:00:00 2001 From: petris Date: Fri, 19 Aug 2022 23:23:10 +0200 Subject: [PATCH 368/641] Enable SPAN_BUILTIN code for Unity 2021.2+ --- .../Scripts/MessagePack/Formatters/StringInterningFormatter.cs | 2 +- .../Assets/Scripts/MessagePack/StreamPolyfillExtensions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs index 9e07521b7..6839f5a30 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs @@ -31,7 +31,7 @@ public string Deserialize(ref MessagePackReader reader, MessagePackSerializerOpt Span chars = stackalloc char[bytes.Length]; int charLength; -#if SPAN_BUILTIN +#if SPAN_BUILTIN || UNITY_2021_2_OR_NEWER charLength = StringEncoding.UTF8.GetChars(bytes, chars); #else unsafe diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/StreamPolyfillExtensions.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/StreamPolyfillExtensions.cs index 2b6222c89..83389cec2 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/StreamPolyfillExtensions.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/StreamPolyfillExtensions.cs @@ -13,7 +13,7 @@ namespace MessagePack { -#if !SPAN_BUILTIN +#if !SPAN_BUILTIN && !UNITY_2021_2_OR_NEWER internal static class StreamPolyfillExtensions { /// From 68e3d617808b4558af4f940fe926e45c04715d0f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 22 Aug 2022 08:53:58 -0600 Subject: [PATCH 369/641] Add warning about squashing a Lib.Template update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8cab6b7af..d3b5acf07 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ We create the merge commit with these commands: 1. Run `git commit-tree -p HEAD -p A B -m "Merged latest Library.Template"`, where `A` is the output from `git rev-parse HEAD` that you recorded earlier, and `B` is the output from your prior `git write-tree` command. 1. Run `git merge X` where `X` is the output of the `git commit-tree` command. +**IMPORTANT**: If using a pull request to get your changes into your repo, you must *merge* your PR. If you *squash* your PR, history will be lost and you will have to repeatedly resolve the same merge conflicts at the next Library.Template update. + **CAUTION**: when merging this for the first time, a github-hosted repo may close issues in your repo with the same number as issues that this repo closed in git commit messages. Verify after completing your PR by visiting your github closed issues, sorted by recently updated, and reactivate any that were inadvertently closed by this merge. This shouldn't be a recurring issue because going forward, we will avoid referencing github issues with simple `#123` syntax in this repo's history. From 672d1d1dbea7478962dfa730302d17a27776155b Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sun, 21 Aug 2022 18:18:36 +0300 Subject: [PATCH 370/641] Support string interning on deserialization when target property is object --- .../Formatters/PrimitiveObjectFormatter.cs | 3 ++- .../Scripts/Tests/ShareTests/StringInterningTests.cs | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs index 7cf007ea1..e665c1bce 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs @@ -263,7 +263,8 @@ public object Deserialize(ref MessagePackReader reader, MessagePackSerializerOpt } case MessagePackType.String: - return reader.ReadString(); + var stringFormatter = resolver.GetFormatter(); + return stringFormatter.Deserialize(ref reader, options); case MessagePackType.Binary: // We must copy the sequence returned by ReadBytes since the reader's sequence is only valid during deserialization. return reader.ReadBytes()?.ToArray(); diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs index d4e98f77a..e76718a91 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs @@ -65,14 +65,16 @@ public void EquivalentStringsGetSharedInstance(int length) [Fact] public void StringMemberInterning() { - ClassOfStrings before = new ClassOfStrings { InternedString = "abc", OrdinaryString = "def" }; + ClassOfStrings before = new ClassOfStrings { InternedString = "abc", OrdinaryString = "def", ObjectString = "obj" }; ClassOfStrings after1 = MessagePackSerializer.Deserialize(MessagePackSerializer.Serialize(before, MessagePackSerializerOptions.Standard), MessagePackSerializerOptions.Standard); ClassOfStrings after2 = MessagePackSerializer.Deserialize(MessagePackSerializer.Serialize(before, MessagePackSerializerOptions.Standard), MessagePackSerializerOptions.Standard); Assert.Equal(after1.InternedString, after2.InternedString); Assert.Equal(after1.OrdinaryString, after2.OrdinaryString); + Assert.Equal(after1.ObjectString, after2.ObjectString); Assert.Same(after1.InternedString, after2.InternedString); Assert.NotSame(after1.OrdinaryString, after2.OrdinaryString); + Assert.NotSame(after1.ObjectString, after2.ObjectString); } [Fact] @@ -83,14 +85,16 @@ public void StringMemberInterning_CustomResolver() new IMessagePackFormatter[] { new StringInterningFormatter() }, new IFormatterResolver[] { StandardResolver.Instance })); - ClassOfStrings before = new ClassOfStrings { InternedString = "abc", OrdinaryString = "def" }; + ClassOfStrings before = new ClassOfStrings { InternedString = "abc", OrdinaryString = "def", ObjectString = "obj" }; ClassOfStrings after1 = MessagePackSerializer.Deserialize(MessagePackSerializer.Serialize(before, options), options); ClassOfStrings after2 = MessagePackSerializer.Deserialize(MessagePackSerializer.Serialize(before, options), options); Assert.Equal(after1.InternedString, after2.InternedString); Assert.Equal(after1.OrdinaryString, after2.OrdinaryString); + Assert.Equal(after1.ObjectString, after2.ObjectString); Assert.Same(after1.InternedString, after2.InternedString); Assert.Same(after1.OrdinaryString, after2.OrdinaryString); + Assert.Same(after1.ObjectString, after2.ObjectString); } [MessagePackObject] @@ -102,6 +106,9 @@ public class ClassOfStrings [Key(1)] public string OrdinaryString { get; set; } + + [Key(2)] + public object ObjectString { get; set; } } } } From 164a2bd266c313dc03f7c794471ce0051217a2d0 Mon Sep 17 00:00:00 2001 From: Iman Navidi Date: Thu, 25 Aug 2022 16:31:38 +0430 Subject: [PATCH 371/641] removing extra double quotation mark --- .../Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs index 38e39985d..877109d6f 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs @@ -432,7 +432,7 @@ private static void ToJsonCore(ref MessagePackReader reader, TextWriter writer, } else { - writer.Write("{\"$type\":\"" + typeNameTokenBuilder.ToString() + "}"); + writer.Write("{\"$type\":" + typeNameTokenBuilder.ToString() + "}"); } } #endif From 8c56d91a1d1967e520e21ce55c87255780b7a798 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:25:43 -0600 Subject: [PATCH 372/641] Bump Microsoft.NET.Test.Sdk from 17.2.0 to 17.3.1 (#175) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.2.0 to 17.3.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.2.0...v17.3.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 92062dc79..a707cebea 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From 4dfc0ba9854c87eb8d310cfe337290c9c7bb5aeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:25:57 -0600 Subject: [PATCH 373/641] Bump Nerdbank.GitVersioning from 3.5.108 to 3.5.109 (#174) Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.5.108 to 3.5.109. - [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases) - [Commits](https://github.com/dotnet/Nerdbank.GitVersioning/compare/v3.5.108...v3.5.109) --- updated-dependencies: - dependency-name: Nerdbank.GitVersioning dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index d13dbc489..35f7d62a6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,7 +37,7 @@ - + From 2bcf967f7d8f19620077021f61219938478635e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:26:07 -0600 Subject: [PATCH 374/641] Bump xunit from 2.4.1 to 2.4.2 (#173) Bumps [xunit](https://github.com/xunit/xunit) from 2.4.1 to 2.4.2. - [Release notes](https://github.com/xunit/xunit/releases) - [Commits](https://github.com/xunit/xunit/compare/2.4.1...2.4.2) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Library.Tests/Library.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index a707cebea..2c1c3e8e5 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -12,7 +12,7 @@ - + From e16106d6686cf153c57064d2d55b77a9484f29d6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 6 Sep 2022 13:38:06 -0600 Subject: [PATCH 375/641] Update doc links --- CONTRIBUTING.md | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36424c42d..e56631ddf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ You should install the version specified in `global.json` or a later version wit the same major.minor.Bxx "hundreds" band. For example if 2.2.300 is specified, you may install 2.2.300, 2.2.301, or 2.2.310 while the 2.2.400 version would not be considered compatible by .NET SDK. -See [.NET Core Versioning](https://docs.microsoft.com/en-us/dotnet/core/versions/) for more information. +See [.NET Core Versioning](https://docs.microsoft.com/dotnet/core/versions/) for more information. ## Package restore @@ -39,4 +39,4 @@ This repository can be built on Windows, Linux, and OSX. Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.). -[pwsh]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 +[pwsh]: https://docs.microsoft.com/powershell/scripting/install/installing-powershell?view=powershell-6 diff --git a/README.md b/README.md index d3b5acf07..33ddbfab6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ * Follow the best and simplest patterns of build, pack and test with dotnet CLI. * Init script that installs prerequisites and auth helpers, supporting both non-elevation and elevation modes. -* Static analyzers: [FxCop](https://docs.microsoft.com/en-us/visualstudio/code-quality/fxcop-analyzers?view=vs-2019) and [StyleCop](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) +* Static analyzers: default [Code Analysis](https://docs.microsoft.com/dotnet/fundamentals/code-analysis/overview) and [StyleCop](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) * Read-only source tree (builds to top-level bin/obj folders) * Auto-versioning (via [Nerdbank.GitVersioning](https://github.com/dotnet/nerdbank.gitversioning)) * Builds with a "pinned" .NET Core SDK to ensure reproducible builds across machines and across time. From 78dcd86c8d021793d9af5052a808980fda451698 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 7 Sep 2022 16:12:39 -0600 Subject: [PATCH 376/641] Remove a few dependencies from unity package Unity 2021.2 and later already include these assemblies, and our inclusion of them causes failures because unity will prefer the 'app-local' copy over its own. Fixes #1475 --- src/MessagePack.UnityClient/copy_assets.bat | 3 --- src/MessagePack.UnityClient/copy_assets.sh | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/MessagePack.UnityClient/copy_assets.bat b/src/MessagePack.UnityClient/copy_assets.bat index c2b03f0e0..02ae53e6b 100644 --- a/src/MessagePack.UnityClient/copy_assets.bat +++ b/src/MessagePack.UnityClient/copy_assets.bat @@ -8,10 +8,7 @@ @pushd %~dp0 -echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Buffers.dll" ".\Assets\Plugins\System.Buffers.dll" /Y /I -echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Memory.dll" ".\Assets\Plugins\System.Memory.dll" /Y /I echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Runtime.CompilerServices.Unsafe.dll" ".\Assets\Plugins\System.Runtime.CompilerServices.Unsafe.dll" /Y /I echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\Microsoft.NET.StringTools.dll" ".\Assets\Plugins\Microsoft.NET.StringTools.dll" /Y /I -echo F | xcopy "..\..\bin\MessagePack\release\netstandard2.0\publish\System.Threading.Tasks.Extensions.dll" ".\Assets\Plugins\System.Threading.Tasks.Extensions.dll" /Y /I @popd diff --git a/src/MessagePack.UnityClient/copy_assets.sh b/src/MessagePack.UnityClient/copy_assets.sh index 7743fd666..2e19e9254 100755 --- a/src/MessagePack.UnityClient/copy_assets.sh +++ b/src/MessagePack.UnityClient/copy_assets.sh @@ -18,8 +18,5 @@ if ! [[ -d "${SCRIPT_DIR}/Assets/Plugins" ]] ; then mkdir -p ${SCRIPT_DIR}/Assets/Plugins fi -cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Buffers.dll ${SCRIPT_DIR}/Assets/Plugins/System.Buffers.dll -cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Memory.dll ${SCRIPT_DIR}/Assets/Plugins/System.Memory.dll cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Runtime.CompilerServices.Unsafe.dll ${SCRIPT_DIR}/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/Microsoft.NET.StringTools.dll ${SCRIPT_DIR}/Assets/Plugins/Microsoft.NET.StringTools.dll -cp ${SCRIPT_DIR}/../../bin/MessagePack/${BUILDCONFIGURATION}/netstandard2.0/publish/System.Threading.Tasks.Extensions.dll ${SCRIPT_DIR}/Assets/Plugins/System.Threading.Tasks.Extensions.dll From fd08b2a828fe189c435b407ba55b05a02d20c8f2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 7 Sep 2022 16:19:57 -0600 Subject: [PATCH 377/641] Fix incremental build in unity build scripts --- src/MessagePack.UnityClient/build.bat | 2 +- src/MessagePack.UnityClient/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MessagePack.UnityClient/build.bat b/src/MessagePack.UnityClient/build.bat index ba55d83b3..920248baa 100644 --- a/src/MessagePack.UnityClient/build.bat +++ b/src/MessagePack.UnityClient/build.bat @@ -1,7 +1,7 @@ @echo off setlocal -IF NOT EXIST "%~dp0Assets/Microsoft.VisualStudio.Threading.dll" CALL "%~dp0copy_assets.bat" +IF NOT EXIST "%~dp0Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll" CALL "%~dp0copy_assets.bat" IF "%Build_ArtifactStagingDirectory%"=="" ( SET LogDirectory=%~dp0..\..\bin\build_logs diff --git a/src/MessagePack.UnityClient/build.sh b/src/MessagePack.UnityClient/build.sh index 31618b648..7993d7636 100755 --- a/src/MessagePack.UnityClient/build.sh +++ b/src/MessagePack.UnityClient/build.sh @@ -8,7 +8,7 @@ done SCRIPT_DIR=$(dirname "$(realpath $0)") -if ! [[ -e "${SCRIPT_DIR}/Assets/Plugins/System.Memory.dll" ]] ; then +if ! [[ -e "${SCRIPT_DIR}/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll" ]] ; then ${SCRIPT_DIR}/copy_assets.sh fi From f42870232c04383ccbc28e885abce2a09e9beff5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 9 Sep 2022 08:41:14 -0600 Subject: [PATCH 378/641] Improve error messages in exceptions thrown from `PrimitiveObjectFormatter` --- .../Formatters/PrimitiveObjectFormatter.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs index 7cf007ea1..298efd0f5 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs @@ -4,7 +4,7 @@ using System; using System.Buffers; using System.Collections.Generic; -using System.Net.Security; +using System.Globalization; using System.Reflection; namespace MessagePack.Formatters @@ -202,9 +202,7 @@ public void Serialize(ref MessagePackWriter writer, object value, MessagePackSer public object Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { - MessagePackType type = reader.NextMessagePackType; - IFormatterResolver resolver = options.Resolver; - switch (type) + switch (reader.NextMessagePackType) { case MessagePackType.Integer: var code = reader.NextCode; @@ -249,7 +247,7 @@ public object Deserialize(ref MessagePackReader reader, MessagePackSerializerOpt return reader.ReadUInt64(); } - throw new MessagePackSerializationException("Invalid primitive bytes."); + throw new MessagePackSerializationException(string.Format(CultureInfo.CurrentCulture, "Unrecognized primitive code 0x{0:x2} for integer type.", code)); case MessagePackType.Boolean: return reader.ReadBoolean(); case MessagePackType.Float: @@ -269,12 +267,12 @@ public object Deserialize(ref MessagePackReader reader, MessagePackSerializerOpt return reader.ReadBytes()?.ToArray(); case MessagePackType.Extension: ExtensionHeader ext = reader.ReadExtensionFormatHeader(); - if (ext.TypeCode == ReservedMessagePackExtensionTypeCode.DateTime) + switch (ext.TypeCode) { - return reader.ReadDateTime(ext); + case ReservedMessagePackExtensionTypeCode.DateTime: return reader.ReadDateTime(ext); + default: throw new MessagePackSerializationException(string.Format(CultureInfo.CurrentCulture, "Extension type code 0x{0:x2} is not supported by the {1}.", ext.TypeCode, nameof(PrimitiveObjectFormatter))); } - throw new MessagePackSerializationException("Invalid primitive bytes."); case MessagePackType.Array: { var length = reader.ReadArrayHeader(); @@ -283,7 +281,7 @@ public object Deserialize(ref MessagePackReader reader, MessagePackSerializerOpt return Array.Empty(); } - IMessagePackFormatter objectFormatter = resolver.GetFormatter(); + IMessagePackFormatter objectFormatter = options.Resolver.GetFormatter(); var array = new object[length]; options.Security.DepthStep(ref reader); try @@ -320,7 +318,7 @@ public object Deserialize(ref MessagePackReader reader, MessagePackSerializerOpt reader.ReadNil(); return null; default: - throw new MessagePackSerializationException("Invalid primitive bytes."); + throw new MessagePackSerializationException(string.Format(CultureInfo.CurrentCulture, "Unrecognized code: 0x{0:X2}.", reader.NextCode)); } } From 5d14d2cecbb3fd3caa6a421da1525d8480baef8b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 13 Sep 2022 09:47:18 -0600 Subject: [PATCH 379/641] Force non-shallow clones Fixes issue 176 --- azure-pipelines/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index cb4899493..23b312218 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -13,6 +13,7 @@ jobs: pool: ${{ parameters.windowsPool }} steps: - checkout: self + fetchDepth: 0 # avoid shallow clone so nbgv can do its work. clean: true - template: install-dependencies.yml @@ -29,6 +30,7 @@ jobs: vmImage: Ubuntu 20.04 steps: - checkout: self + fetchDepth: 0 # avoid shallow clone so nbgv can do its work. clean: true - template: install-dependencies.yml - template: dotnet.yml @@ -42,6 +44,7 @@ jobs: vmImage: macOS-10.15 steps: - checkout: self + fetchDepth: 0 # avoid shallow clone so nbgv can do its work. clean: true - template: install-dependencies.yml - template: dotnet.yml @@ -58,6 +61,7 @@ jobs: condition: succeededOrFailed() steps: - checkout: self + fetchDepth: 0 # avoid shallow clone so nbgv can do its work. clean: true - template: install-dependencies.yml parameters: From 34f4c9f3058c9757647f61869bd7f226a32b7d14 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 13 Sep 2022 10:56:39 -0600 Subject: [PATCH 380/641] Switch to using dotnet-coverage Now that the merge bug has been fixed, this should provide a better report than `dotnet-reportgenerator-globaltool` because methods with `#if` blocks will now still be merged in the report instead of being listed multiple times. --- azure-pipelines/Merge-CodeCoverage.ps1 | 15 ++++++++++----- azure-pipelines/publish-codecoverage.yml | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/azure-pipelines/Merge-CodeCoverage.ps1 b/azure-pipelines/Merge-CodeCoverage.ps1 index 91ab67ab3..9fe925cf6 100644 --- a/azure-pipelines/Merge-CodeCoverage.ps1 +++ b/azure-pipelines/Merge-CodeCoverage.ps1 @@ -16,13 +16,13 @@ Param( [string[]]$Path, [ValidateSet('Badges', 'Clover', 'Cobertura', 'CsvSummary', 'Html', 'Html_Dark', 'Html_Light', 'HtmlChart', 'HtmlInline', 'HtmlInline_AzurePipelines', 'HtmlInline_AzurePipelines_Dark', 'HtmlInline_AzurePipelines_Light', 'HtmlSummary', 'JsonSummary', 'Latex', 'LatexSummary', 'lcov', 'MarkdownSummary', 'MHtml', 'PngChart', 'SonarQube', 'TeamCitySummary', 'TextSummary', 'Xml', 'XmlSummary')] [string]$Format='Cobertura', - [string]$OutputDir=("$PSScriptRoot/../coveragereport") + [string]$OutputFile=("$PSScriptRoot/../coveragereport/merged.cobertura.xml") ) $RepoRoot = [string](Resolve-Path $PSScriptRoot/..) -if (!(Test-Path $RepoRoot/obj/reportgenerator*)) { - dotnet tool install --tool-path $RepoRoot/obj dotnet-reportgenerator-globaltool --version 5.1.9 --configfile $PSScriptRoot/justnugetorg.nuget.config +if (!(Test-Path $RepoRoot/obj/dotnet-coverage*)) { + dotnet tool install --tool-path $RepoRoot/obj dotnet-coverage --version 17.4.3 --configfile $PSScriptRoot/justnugetorg.nuget.config } Write-Verbose "Searching $Path for *.cobertura.xml files" @@ -39,8 +39,13 @@ if ($reports) { $xml.Save($_) } - $Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_.FullName })) - & "$RepoRoot/obj/reportgenerator" -reports:"$Inputs" -targetdir:$OutputDir -reporttypes:$Format + $Inputs = $reports |% { Resolve-Path -relative $_.FullName } + + if (Split-Path $OutputFile) { + New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null + } + + & "$RepoRoot/obj/dotnet-coverage" merge $Inputs -o $OutputFile -f cobertura } else { Write-Error "No reports found to merge." } diff --git a/azure-pipelines/publish-codecoverage.yml b/azure-pipelines/publish-codecoverage.yml index 11de8ffa1..fbb6a39a7 100644 --- a/azure-pipelines/publish-codecoverage.yml +++ b/azure-pipelines/publish-codecoverage.yml @@ -15,11 +15,11 @@ steps: displayName: 🔻 Download macOS code coverage results continueOnError: true condition: and(succeeded(), ${{ parameters.includeMacOS }}) -- powershell: azure-pipelines/Merge-CodeCoverage.ps1 -Path '$(Pipeline.Workspace)' -OutputDir coveragereport -Format Cobertura -Verbose +- powershell: azure-pipelines/Merge-CodeCoverage.ps1 -Path '$(Pipeline.Workspace)' -OutputFile coveragereport/merged.cobertura.xml -Format Cobertura -Verbose displayName: ⚙ Merge coverage - task: PublishCodeCoverageResults@1 displayName: 📢 Publish code coverage results to Azure DevOps inputs: codeCoverageTool: cobertura - summaryFileLocation: coveragereport/Cobertura.xml + summaryFileLocation: coveragereport/merged.cobertura.xml failIfCoverageEmpty: true From 16f2a9a766f476d402fb4ba5ffa491b8f9df7661 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 14 Sep 2022 09:41:37 -0600 Subject: [PATCH 381/641] Update NuGetAuthenticate task version --- azure-pipelines/install-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 3993f1043..817826689 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -3,7 +3,7 @@ parameters: steps: -- task: NuGetAuthenticate@0 +- task: NuGetAuthenticate@1 displayName: 🔏 Authenticate NuGet feeds inputs: forceReinstallCredentialProvider: true From 02c28ce1702c3ed08cc8808073cd522c1b2f9086 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 20 Sep 2022 08:00:47 -0600 Subject: [PATCH 382/641] Close stale issues as 'not planned' --- .github/workflows/stale.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index e625d1164..1c28881b0 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/stale@v1 + - uses: actions/stale@v5.2.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} days-before-stale: 90 @@ -21,3 +21,5 @@ jobs: stale-pr-message: 'This pull request is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.' stale-pr-label: 'no-pr-activity' exempt-pr-label: 'awaiting-approval' + close-issue-reason: not_planned + From 164e775a4446075245a74c0d5449ddd3f1c2b870 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 20 Sep 2022 08:02:45 -0600 Subject: [PATCH 383/641] Allow manual triggering of the stale workflow --- .github/workflows/stale.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 1c28881b0..a43ba9ed4 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -3,6 +3,7 @@ name: Mark stale issues and pull requests on: schedule: - cron: "0 0 * * *" + workflow_dispatch: jobs: stale: From 8295c968db3fbc31654e93e25499bdc68da5c8cf Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 20 Sep 2022 08:05:43 -0600 Subject: [PATCH 384/641] Update workflow inputs --- .github/workflows/stale.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index a43ba9ed4..27e7f9cf0 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -18,9 +18,9 @@ jobs: days-before-close: 5 stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.' stale-issue-label: 'no-issue-activity' - exempt-issue-label: 'awaiting-approval' + exempt-issue-labels: awaiting-approval stale-pr-message: 'This pull request is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.' stale-pr-label: 'no-pr-activity' - exempt-pr-label: 'awaiting-approval' + exempt-pr-labels: awaiting-approval close-issue-reason: not_planned From 12bda8587b4e368ff2417711f6c2d29928c00b12 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 20 Sep 2022 17:21:42 -0600 Subject: [PATCH 385/641] Update macOS agent to OS12 --- azure-pipelines/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 23b312218..c8687859b 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -41,7 +41,7 @@ jobs: - job: macOS condition: ${{ parameters.includeMacOS }} pool: - vmImage: macOS-10.15 + vmImage: macOS-12 steps: - checkout: self fetchDepth: 0 # avoid shallow clone so nbgv can do its work. From 34412f06a0e3a69eed70eedd8e8323d75e2d338b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 21 Sep 2022 10:36:48 -0600 Subject: [PATCH 386/641] Add more analyzers --- .editorconfig | 9 +++++++++ Directory.Build.props | 2 ++ 2 files changed, 11 insertions(+) diff --git a/.editorconfig b/.editorconfig index 0d75b34a3..c8b5de9ac 100644 --- a/.editorconfig +++ b/.editorconfig @@ -167,5 +167,14 @@ dotnet_diagnostic.SA1130.severity = silent # IDE1006: Naming Styles - StyleCop handles these for us dotnet_diagnostic.IDE1006.severity = none +dotnet_diagnostic.DOC100.severity = silent +dotnet_diagnostic.DOC104.severity = warning +dotnet_diagnostic.DOC105.severity = warning +dotnet_diagnostic.DOC106.severity = warning +dotnet_diagnostic.DOC107.severity = warning +dotnet_diagnostic.DOC108.severity = warning +dotnet_diagnostic.DOC200.severity = warning +dotnet_diagnostic.DOC202.severity = warning + [*.sln] indent_style = tab diff --git a/Directory.Build.props b/Directory.Build.props index 35f7d62a6..f13158c00 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -41,6 +41,8 @@ + + From 2678ec5fa3e3d854140405cd980f241df8da617e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 28 Sep 2022 08:39:19 -0600 Subject: [PATCH 387/641] Use static graph restore It's faster, and the future. --- Directory.Build.props | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index f13158c00..3170d14b1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -16,6 +16,9 @@ true + + true + $(MSBuildThisFileDirectory) From 0552ddca8b22548fe1e331a64ebe430fe6a80008 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 30 Sep 2022 22:48:21 -0600 Subject: [PATCH 388/641] Update dependencies --- Directory.Build.props | 2 +- test/Library.Tests/Library.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3170d14b1..8cada6c76 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -40,7 +40,7 @@ - + diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 2c1c3e8e5..4e9a7a4c4 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,7 +10,7 @@ - + From 2eaf0fb8f261f978f6d60bef5fde8c87d5eb8640 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Oct 2022 11:48:02 -0600 Subject: [PATCH 389/641] Update .NET SDK to 6.0.401 --- .devcontainer/Dockerfile | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b13ca0aca..5c1bdc7ab 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.300-focal +FROM mcr.microsoft.com/dotnet/sdk:6.0.401-focal # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/global.json b/global.json index 954a92e75..7bf6fc99a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.300", + "version": "6.0.401", "rollForward": "patch", "allowPrerelease": false } From fec0f19d7254fbd3ff40b32dafd86dbe41805749 Mon Sep 17 00:00:00 2001 From: Vitalii Zabrodin Date: Wed, 5 Oct 2022 23:43:12 +0300 Subject: [PATCH 390/641] Fix ASP.NET Core output formatter to support null ObjectType --- .../MessagePackOutputFormatter.cs | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs b/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs index 409981148..9dd8c0750 100644 --- a/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs +++ b/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs @@ -25,42 +25,40 @@ public MessagePackOutputFormatter(MessagePackSerializerOptions options) public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context) { - if (context.ObjectType == typeof(object)) + if (context.Object == null) { - if (context.Object == null) - { #if NETSTANDARD2_0 + context.HttpContext.Response.Body.WriteByte(MessagePackCode.Nil); + return Task.CompletedTask; +#else + var writer = context.HttpContext.Response.BodyWriter; + if (writer == null) + { context.HttpContext.Response.Body.WriteByte(MessagePackCode.Nil); return Task.CompletedTask; -#else - var writer = context.HttpContext.Response.BodyWriter; - if (writer == null) - { - context.HttpContext.Response.Body.WriteByte(MessagePackCode.Nil); - return Task.CompletedTask; - } + } - var span = writer.GetSpan(1); - span[0] = MessagePackCode.Nil; - writer.Advance(1); - return writer.FlushAsync().AsTask(); + var span = writer.GetSpan(1); + span[0] = MessagePackCode.Nil; + writer.Advance(1); + return writer.FlushAsync().AsTask(); #endif - } - else - { + } + + if (context.ObjectType == null || context.ObjectType == typeof(object)) + { #if NETSTANDARD2_0 - return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); + return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); #else - var writer = context.HttpContext.Response.BodyWriter; - if (writer == null) - { - return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); - } + var writer = context.HttpContext.Response.BodyWriter; + if (writer == null) + { + return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); + } - MessagePackSerializer.Serialize(context.Object.GetType(), writer, context.Object, this.options, context.HttpContext.RequestAborted); - return writer.FlushAsync().AsTask(); + MessagePackSerializer.Serialize(context.Object.GetType(), writer, context.Object, this.options, context.HttpContext.RequestAborted); + return writer.FlushAsync().AsTask(); #endif - } } else { From 87fd1d1915844692a2c29d5f40780177d7f3f177 Mon Sep 17 00:00:00 2001 From: Vitalii Zabrodin Date: Wed, 5 Oct 2022 23:44:59 +0300 Subject: [PATCH 391/641] Refactor ASP.NET Core output formatter --- .../MessagePackOutputFormatter.cs | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs b/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs index 9dd8c0750..222422a96 100644 --- a/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs +++ b/src/MessagePack.AspNetCoreMvcFormatter/MessagePackOutputFormatter.cs @@ -44,34 +44,19 @@ public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context) return writer.FlushAsync().AsTask(); #endif } - - if (context.ObjectType == null || context.ObjectType == typeof(object)) - { -#if NETSTANDARD2_0 - return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); -#else - var writer = context.HttpContext.Response.BodyWriter; - if (writer == null) - { - return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); - } - - MessagePackSerializer.Serialize(context.Object.GetType(), writer, context.Object, this.options, context.HttpContext.RequestAborted); - return writer.FlushAsync().AsTask(); -#endif - } else { + var objectType = context.ObjectType == null || context.ObjectType == typeof(object) ? context.Object.GetType() : context.ObjectType; #if NETSTANDARD2_0 - return MessagePackSerializer.SerializeAsync(context.ObjectType, context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); + return MessagePackSerializer.SerializeAsync(objectType, context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); #else var writer = context.HttpContext.Response.BodyWriter; if (writer == null) { - return MessagePackSerializer.SerializeAsync(context.ObjectType, context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); + return MessagePackSerializer.SerializeAsync(objectType, context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted); } - MessagePackSerializer.Serialize(context.ObjectType, writer, context.Object, this.options, context.HttpContext.RequestAborted); + MessagePackSerializer.Serialize(objectType, writer, context.Object, this.options, context.HttpContext.RequestAborted); return writer.FlushAsync().AsTask(); #endif } From 5b802812e6e0291f76725b990ef18685af0af59e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Oct 2022 08:34:01 -0600 Subject: [PATCH 392/641] Update Microsoft.NET.StringTools dependency to 17.3.1 --- sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj | 2 +- src/MessagePack/MessagePack.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj index 0daf9da44..6d0c4cdec 100644 --- a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj +++ b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj @@ -144,6 +144,6 @@ - + diff --git a/src/MessagePack/MessagePack.csproj b/src/MessagePack/MessagePack.csproj index 801ab7de1..6dc057b89 100644 --- a/src/MessagePack/MessagePack.csproj +++ b/src/MessagePack/MessagePack.csproj @@ -34,7 +34,7 @@ - + From abab1d849933ee85cb6f026026f28e481db1bc64 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 20 Oct 2022 16:06:44 -0600 Subject: [PATCH 393/641] Fix variable detection on linux Linux can have empty values for environment variables. Windows evidently doesn't tend to have those. --- azure-pipelines/variables/_pipelines.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 951106d2d..11748b81b 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -14,7 +14,7 @@ param ( (& "$PSScriptRoot\_all.ps1").GetEnumerator() |% { # Always use ALL CAPS for env var names since Azure Pipelines converts variable names to all caps and on non-Windows OS, env vars are case sensitive. $keyCaps = $_.Key.ToUpper() - if (Test-Path -Path "env:$keyCaps") { + if ((Test-Path "env:$keyCaps") -and (Get-Content "env:$keyCaps")) { Write-Host "Skipping setting $keyCaps because variable is already set to '$(Get-Content env:$keyCaps)'." -ForegroundColor Cyan } else { Write-Host "$keyCaps=$($_.Value)" -ForegroundColor Yellow From cffffa4afb7b44d45896d8138d6464bc92650fbe Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 24 Oct 2022 14:17:43 -0600 Subject: [PATCH 394/641] Update Nerdbank.GitVersioning version --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8cada6c76..abdb9d8b1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -40,7 +40,7 @@ - + From 2a5a528133ac007b2facba8b53cfbdb86f0f0b67 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 31 Oct 2022 08:51:51 -0600 Subject: [PATCH 395/641] Improve verbose output of artifact collection --- azure-pipelines/artifacts/_all.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines/artifacts/_all.ps1 b/azure-pipelines/artifacts/_all.ps1 index 033cc87c9..9a22a1d08 100755 --- a/azure-pipelines/artifacts/_all.ps1 +++ b/azure-pipelines/artifacts/_all.ps1 @@ -38,6 +38,7 @@ Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse | % { $ArtifactName = $_.BaseName if ($Force -or !(Test-ArtifactStaged($ArtifactName + $ArtifactNameSuffix))) { $totalFileCount = 0 + Write-Verbose "Collecting file list for artifact $($_.BaseName)" $fileGroups = & $_ if ($fileGroups) { $fileGroups.GetEnumerator() | % { From 77fcd3de2d9f7c6368cc0baeb6cf6e23a204bdaa Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Nov 2022 08:16:02 -0600 Subject: [PATCH 396/641] Switch to NuGet's central package versioning --- Directory.Build.props | 13 ++++++------- Directory.Packages.props | 17 +++++++++++++++++ test/Library.Tests/Library.Tests.csproj | 6 +++--- 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 Directory.Packages.props diff --git a/Directory.Build.props b/Directory.Build.props index abdb9d8b1..8f186a7c7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -39,13 +39,12 @@ - - - - - - - + + + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 000000000..8bec0397a --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,17 @@ + + + + true + + + + + + + + + + + + + diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 4e9a7a4c4..39650b7d7 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,9 +10,9 @@ - - - + + + From b894b8a9901dfcbec1030860da30bf6c7507bd19 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Nov 2022 08:22:12 -0600 Subject: [PATCH 397/641] Update to the .NET 7.0.100-rc.2 SDK This removes the warning about using NuGet CPVM, "a preview feature". --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 7bf6fc99a..01e689ed8 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.401", + "version": "7.0.100-rc.2.22477.23", "rollForward": "patch", "allowPrerelease": false } From ab4fb10d210dd404d8d04aa14c706af271129d0e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Nov 2022 08:29:15 -0600 Subject: [PATCH 398/641] Switch to using GlobalPackageReference --- Directory.Build.props | 9 --------- Directory.Packages.props | 14 ++++++++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8f186a7c7..301047d1e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -38,15 +38,6 @@ snupkg - - - - - - - - - diff --git a/Directory.Packages.props b/Directory.Packages.props index 8bec0397a..2b94d74d9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,14 +4,16 @@ true - - - - - - + + + + + + + + From 318aaadd6dc4f2b674e5f7c18e9940550a1b3e43 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Nov 2022 08:45:31 -0600 Subject: [PATCH 399/641] Move GitHub-specific package ref to its own group This is to reduce merge conflicts with the microbuild branch where nearby lines change a lot. --- Directory.Packages.props | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 2b94d74d9..c33a3beb0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,9 +11,11 @@ - + + + From 253e62c08488d57a5b740fb68475501353713cdd Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Nov 2022 12:02:25 -0600 Subject: [PATCH 400/641] Simplify parent import pattern --- src/Directory.Build.props | 2 +- src/Directory.Build.targets | 2 +- test/Directory.Build.props | 2 +- test/Directory.Build.targets | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 77d947658..052fe3ef0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,3 +1,3 @@ - + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 566ab4fcf..c1d929a5b 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -3,5 +3,5 @@ - + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 449a06e45..ad4a4b6c5 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,5 +1,5 @@ - + false diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index e7edee55a..052fe3ef0 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -1,3 +1,3 @@ - + From f91a0e871d9f794cc36020341f358718d6b07f83 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Nov 2022 14:19:46 -0600 Subject: [PATCH 401/641] Avoid .NET 7 SDK till it's stable Otherwise, msbuild.exe fails on VS 17.3, which is the latest stable release. We need to wait till folks can use VS 17.4 to use the .NET 7 SDK. --- Directory.Packages.props | 24 ++++++++++++++++++------ global.json | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index c33a3beb0..8c1e8f80a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,14 +8,26 @@ + - - - - - + + + + + - + + + + + + + + + + + diff --git a/global.json b/global.json index 01e689ed8..3ce46e096 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.100-rc.2.22477.23", + "version": "6.0.402", "rollForward": "patch", "allowPrerelease": false } From c32551d1365873cdf6c26bec81c07481fa2b28fe Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 7 Nov 2022 08:59:40 -0700 Subject: [PATCH 402/641] Add Directory.Packages.props as a solution item --- Library.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/Library.sln b/Library.sln index 606811aaf..638efb568 100644 --- a/Library.sln +++ b/Library.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets + Directory.Packages.props = Directory.Packages.props global.json = global.json nuget.config = nuget.config README.md = README.md From 295d06694b9fd0993197bb6c1ea94731c2b4bb05 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 10 Nov 2022 17:26:57 +0000 Subject: [PATCH 403/641] Use static code coverage preview This is in an attempt to fix #180 --- Directory.Packages.props | 1 + azure-pipelines/test.runsettings | 6 ++++-- nuget.config | 1 + test/Library.Tests/Library.Tests.csproj | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 8c1e8f80a..d12266917 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,6 +4,7 @@ true + diff --git a/azure-pipelines/test.runsettings b/azure-pipelines/test.runsettings index c69022fc0..975b71233 100644 --- a/azure-pipelines/test.runsettings +++ b/azure-pipelines/test.runsettings @@ -31,11 +31,13 @@ False - True + False - True + False True + True + False diff --git a/nuget.config b/nuget.config index 22f7b8098..9454ec025 100644 --- a/nuget.config +++ b/nuget.config @@ -7,6 +7,7 @@ + diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index 39650b7d7..2eb4afe1e 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -10,6 +10,7 @@ + From ad6e2422bed202dfd0e95a567635809eb9b3a2f3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Nov 2022 15:19:51 +0000 Subject: [PATCH 404/641] Resolve NU1507 warning --- nuget.config | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nuget.config b/nuget.config index 9454ec025..6ce7cfd05 100644 --- a/nuget.config +++ b/nuget.config @@ -13,4 +13,12 @@ + + + + + + + + From 66a302c4e7c60633ad09c232f0b8cd105ab1f795 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 14 Nov 2022 12:17:50 -0700 Subject: [PATCH 405/641] Update Microsoft.NET.Test.Sdk --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index d12266917..924f4b4e0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ - + @@ -31,4 +31,4 @@ - + \ No newline at end of file From 5a138c417afdf891358e4885c0f81fca3fa032bd Mon Sep 17 00:00:00 2001 From: Tatsuya Honda Date: Sat, 19 Nov 2022 23:39:37 +0900 Subject: [PATCH 406/641] fix duplicate registration of named tuples (#1464) * fix duplicate registration of named tuples * fix: avoid unnecessary conversion --- .../CodeAnalysis/TypeCollector.cs | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs index eeedbdadc..da68130aa 100644 --- a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs @@ -252,12 +252,15 @@ public class TypeCollector private readonly List collectedGenericInfo = new(); private readonly List collectedUnionInfo = new(); + private readonly Compilation compilation; + public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, Action logger) { this.typeReferences = new ReferenceSymbols(compilation, logger); this.disallowInternal = disallowInternal; this.isForceUseMap = isForceUseMap; this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); + this.compilation = compilation; targetTypes = compilation.GetNamedTypeSymbols() .Where(x => @@ -329,7 +332,7 @@ private void CollectCore(ITypeSymbol typeSymbol) if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) { - this.CollectArray(arrayTypeSymbol); + this.CollectArray((IArrayTypeSymbol)ToTupleUnderlyingType(arrayTypeSymbol)); return; } @@ -357,13 +360,7 @@ private void CollectCore(ITypeSymbol typeSymbol) if (type.IsGenericType) { - this.CollectGeneric(type); - return; - } - - if (type.TupleUnderlyingType != null) - { - CollectGeneric(type.TupleUnderlyingType); + this.CollectGeneric((INamedTypeSymbol)ToTupleUnderlyingType(type)); return; } @@ -459,6 +456,28 @@ private void CollectArray(IArrayTypeSymbol array) this.collectedGenericInfo.Add(info); } + private ITypeSymbol ToTupleUnderlyingType(ITypeSymbol typeSymbol) + { + if (typeSymbol is IArrayTypeSymbol array) + { + return compilation.CreateArrayTypeSymbol(ToTupleUnderlyingType(array.ElementType), array.Rank); + } + + if (typeSymbol is not INamedTypeSymbol namedType || !namedType.IsGenericType) + { + return typeSymbol; + } + + namedType = namedType.TupleUnderlyingType ?? namedType; + var newTypeArguments = namedType.TypeArguments.Select(ToTupleUnderlyingType).ToArray(); + if (!namedType.TypeArguments.SequenceEqual(newTypeArguments)) + { + return namedType.ConstructedFrom.Construct(newTypeArguments); + } + + return namedType; + } + private void CollectGeneric(INamedTypeSymbol type) { INamedTypeSymbol genericType = type.ConstructUnboundGenericType(); From 93f938d362bebb15bce5aff047d01bf4ea04838b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 19 Nov 2022 07:49:44 -0700 Subject: [PATCH 407/641] Fix null param check in `StaticCompositeResolver` Fixes #1523 --- .../Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs index ba0084c59..8d8037bc2 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs @@ -8,7 +8,7 @@ namespace MessagePack.Resolvers { /// - /// Singleton version of CompositeResolver, which be able to register a collection of formatters and resolvers to a single instance. + /// Singleton version of , which can register a collection of formatters and resolvers to a single instance. /// public class StaticCompositeResolver : IFormatterResolver { @@ -40,7 +40,7 @@ public void Register(params IMessagePackFormatter[] formatters) throw new InvalidOperationException("Register must call on startup(before use GetFormatter)."); } - if (this.formatters is null) + if (formatters is null) { throw new ArgumentNullException(nameof(formatters)); } From c972b170d1d8c50c269034d0778a2af4bdcb4cdc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 19 Nov 2022 08:15:47 -0700 Subject: [PATCH 408/641] Update to 17.4.0 to fix break --- sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj | 2 +- src/MessagePack/MessagePack.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj index 6d0c4cdec..6f68213f6 100644 --- a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj +++ b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj @@ -144,6 +144,6 @@ - + diff --git a/src/MessagePack/MessagePack.csproj b/src/MessagePack/MessagePack.csproj index 6dc057b89..762888bec 100644 --- a/src/MessagePack/MessagePack.csproj +++ b/src/MessagePack/MessagePack.csproj @@ -34,7 +34,7 @@ - + From 0c41ccb0a0ee52a4c9c02c38221d87172c077798 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 19 Nov 2022 08:36:30 -0700 Subject: [PATCH 409/641] Add incremental build support to MessagePack.MSBuild.Tasks Fixes #1526 --- .../MessagePackGenerator.cs | 7 +------ .../build/MessagePack.MSBuild.Tasks.targets | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs b/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs index a3766024a..0e9f3e727 100644 --- a/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs +++ b/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs @@ -28,7 +28,7 @@ public class MessagePackGenerator : Microsoft.Build.Utilities.Task, ICancelableT public ITaskItem[] Compile { get; set; } = null!; [Required] - public string IntermediateOutputPath { get; set; } = null!; + public string GeneratedOutputPath { get; set; } = null!; [Required] public ITaskItem[] ReferencePath { get; set; } = null!; @@ -44,9 +44,6 @@ public class MessagePackGenerator : Microsoft.Build.Utilities.Task, ICancelableT public string[]? ExternalIgnoreTypeNames { get; set; } - [Output] - public string? GeneratedOutputPath { get; set; } - internal CancellationToken CancellationToken => this.cts.Token; public void Cancel() => this.cts.Cancel(); @@ -59,8 +56,6 @@ public override bool Execute() return false; } - this.GeneratedOutputPath = Path.Combine(this.IntermediateOutputPath, GeneratedFileName); - try { var compilation = this.CreateCompilation(); diff --git a/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets b/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets index 554bc7f42..e95cf9e90 100644 --- a/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets +++ b/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets @@ -1,21 +1,28 @@  + + $(IntermediateOutputPath)mpc_generated.cs + + + + + + + DependsOnTargets="ResolveReferences" + Inputs="@(Compile)" + Outputs="$(GeneratedMessagePackFile)"> - - - + /> From d532384bee34649bfda4d98dd8f620c6c1789086 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 19 Nov 2022 13:09:02 -0700 Subject: [PATCH 410/641] Remove dead constant --- src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs b/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs index 0e9f3e727..69d8f23e5 100644 --- a/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs +++ b/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs @@ -20,8 +20,6 @@ namespace MessagePack.MSBuild.Tasks { public class MessagePackGenerator : Microsoft.Build.Utilities.Task, ICancelableTask { - private const string GeneratedFileName = "mpc_generated.cs"; - private readonly CancellationTokenSource cts = new CancellationTokenSource(); [Required] From 8ebf3f27b25adbe6d266bc07fbdd01bc94d82a48 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 21 Nov 2022 09:37:48 -0700 Subject: [PATCH 411/641] Use `MSBuildTreatWarningsAsErrors` in pipeline This is more comprehensive than `TreatWarningsAsErrors` because it changes the behavior of the MSBuild logging system itself instead of relying on individual tasks and targets to honor the property and elevate their own warnings. --- .github/workflows/build.yml | 2 +- azure-pipelines.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c4ba94c6..a56a6dda2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: pull_request: env: - TreatWarningsAsErrors: true + MSBuildTreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BUILDCONFIGURATION: Release # codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2cac17bd9..521d4ce6b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,7 +23,7 @@ parameters: default: true variables: - TreatWarningsAsErrors: true + MSBuildTreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BuildConfiguration: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ From 73ef446ccb46cf39b434ef004007681624bffc89 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 21 Nov 2022 09:40:20 -0700 Subject: [PATCH 412/641] Avoid static graph restore This until the fix for https://github.com/NuGet/Home/issues/12177 is broadly available. --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 301047d1e..e78128b9b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -17,7 +17,8 @@ true - true + + false $(MSBuildThisFileDirectory) From ae66da74a2e324d3fc73753c691cfeb882d18daf Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 8 Nov 2022 22:24:14 -0700 Subject: [PATCH 413/641] Update to the .NET 7 SDK --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 3ce46e096..e5187f36c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.402", + "version": "7.0.100", "rollForward": "patch", "allowPrerelease": false } From ca3ab7d086ec1559228a26e454f6dc71e920066e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 21 Nov 2022 20:06:18 -0700 Subject: [PATCH 414/641] Enable NuGet CPVM transitive pinning --- Directory.Packages.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index 924f4b4e0..5ce5b0f00 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,6 +2,7 @@ true + true From 6bcec4372bd8508a7513aa6653712b2388a94a9a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 22 Nov 2022 09:05:12 -0700 Subject: [PATCH 415/641] Fix build on machines with Visual Studio 2022 Update 3 This is a workaround for Azure Pipelines Hosted agents, which haven't upgraded to Dev17.4 yet. --- Directory.Packages.props | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 5ce5b0f00..e9475f7cb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -15,6 +15,7 @@ + @@ -25,6 +26,7 @@ + @@ -32,4 +34,4 @@ - \ No newline at end of file + From 6a34c4f283848ed96447f3ce5fde429309112fe0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 22 Nov 2022 09:23:41 -0700 Subject: [PATCH 416/641] Switch back to `GlobalPackageReference` --- Directory.Packages.props | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index e9475f7cb..5996640f0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,28 +10,15 @@ - - - - - - - + + + + + + - - - - - - - - - - - - + From fb2b395fce67a75e5be07443e204fc5b905b6983 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 24 Nov 2022 13:21:22 -0700 Subject: [PATCH 417/641] Drop the .NET compilers toolset pin This reverts "Fix build on machines with Visual Studio 2022 Update 3" since Azure Pipelines now has Update 4 installed. This reverts commit 6bcec4372bd8508a7513aa6653712b2388a94a9a. --- Directory.Packages.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 5996640f0..8e696a7e9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,7 +13,6 @@ - From eb28fe7968ed7df8c69ba54a0732c7552217ba24 Mon Sep 17 00:00:00 2001 From: Sergey Andreev Date: Fri, 25 Nov 2022 12:25:27 +0100 Subject: [PATCH 418/641] Fixed issue with generics formatters generation --- .../CodeAnalysis/TypeCollector.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs index da68130aa..50c68917d 100644 --- a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs @@ -483,7 +483,7 @@ private void CollectGeneric(INamedTypeSymbol type) INamedTypeSymbol genericType = type.ConstructUnboundGenericType(); var genericTypeString = genericType.ToDisplayString(); var fullName = type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - var isOpenGenericType = type.TypeArguments.Any(x => x is ITypeParameterSymbol); + var isOpenGenericType = IsOpenGenericTypeRecursively(type); // special case if (fullName == "global::System.ArraySegment" || fullName == "global::System.ArraySegment?") @@ -1045,5 +1045,10 @@ private bool IsAllowAccessibility(ITypeSymbol symbol) return true; } + + private bool IsOpenGenericTypeRecursively(INamedTypeSymbol type) + { + return type.IsGenericType && type.TypeArguments.Any(x => x is ITypeParameterSymbol || (x is INamedTypeSymbol symbol && IsOpenGenericTypeRecursively(symbol))); + } } } From a32f820b0f145106b6a7182079a59adf7e9554a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Dec 2022 10:45:54 -0700 Subject: [PATCH 419/641] Bump Microsoft.CodeCoverage (#182) Bumps [Microsoft.CodeCoverage](https://github.com/microsoft/vstest) from 17.5.0-preview-20221109-01 to 17.5.0-preview-20221201-01. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/commits) --- updated-dependencies: - dependency-name: Microsoft.CodeCoverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 8e696a7e9..056c53494 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From e7ed3b30668a893d23584ecf05294d7b14f6b445 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 1 Dec 2022 14:46:40 -0700 Subject: [PATCH 420/641] Bump Microsoft.CodeCoverage from 17.5.0-preview-20221201-01 to 17.5.0-preview-20221201-06 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 056c53494..f19a9842e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From f3d7e0e8bcec3cf5dfd725d9d08e3e4c8eaa7cb7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 2 Dec 2022 07:22:40 -0700 Subject: [PATCH 421/641] Fix unity build (#1537) * Build on Unity 2021.3 agent Co-authored-by: neuecc --- .github/workflows/unity.yml | 48 ++ azure-pipelines.yml | 12 - azure-pipelines/build_unity.yml | 34 - src/MessagePack.UnityClient/.vsconfig | 6 + .../Assets/Resources.meta | 8 + .../Assets/Resources/BillingMode.json | 1 + .../Assets/Resources/BillingMode.json.meta | 7 + .../Assets/RuntimeUnitTestToolkit/Editor.meta | 2 +- .../Editor/HierarchyTreeBuilder.cs.meta | 2 +- .../Editor/UnitTestBuilder.MenuItems.cs | 4 + .../Editor/UnitTestBuilder.MenuItems.cs.meta | 2 +- .../Editor/UnitTestBuilder.cs | 34 +- .../Editor/UnitTestBuilder.cs.meta | 5 +- .../RuntimeUnitTestToolkit.asmdef.meta | 2 +- .../RuntimeUnitTestToolkit/UnitTestData.cs | 391 ++++++++++ .../UnitTestData.cs.meta | 11 + .../RuntimeUnitTestToolkit/UnitTestRunner.cs | 340 ++------- .../UnitTestRunner.cs.meta | 5 +- .../RuntimeUnitTestToolkit/package.json | 4 +- .../RuntimeUnitTestToolkit/package.json.meta | 2 +- .../StringInterningFormatter.cs.meta | 11 + .../ShareTests/StringInterningTests.cs.meta | 11 + .../ProjectSettings/MemorySettings.asset | 35 + .../PackageManagerSettings.asset | 35 + .../ProjectSettings/ProjectVersion.txt | 4 +- .../VersionControlSettings.asset | 8 + .../ProjectSettings/boot.config | 0 .../UserSettings/EditorUserSettings.asset | Bin 0 -> 4156 bytes .../UserSettings/Layouts/default-2021.dwlt | 690 ++++++++++++++++++ src/MessagePack.UnityClient/build.bat | 2 +- src/MessagePack.UnityClient/build.sh | 3 +- 31 files changed, 1367 insertions(+), 352 deletions(-) create mode 100644 .github/workflows/unity.yml delete mode 100644 azure-pipelines/build_unity.yml create mode 100644 src/MessagePack.UnityClient/.vsconfig create mode 100644 src/MessagePack.UnityClient/Assets/Resources.meta create mode 100644 src/MessagePack.UnityClient/Assets/Resources/BillingMode.json create mode 100644 src/MessagePack.UnityClient/Assets/Resources/BillingMode.json.meta create mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs create mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs.meta create mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs.meta create mode 100644 src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/StringInterningTests.cs.meta create mode 100644 src/MessagePack.UnityClient/ProjectSettings/MemorySettings.asset create mode 100644 src/MessagePack.UnityClient/ProjectSettings/PackageManagerSettings.asset create mode 100644 src/MessagePack.UnityClient/ProjectSettings/VersionControlSettings.asset create mode 100644 src/MessagePack.UnityClient/ProjectSettings/boot.config create mode 100644 src/MessagePack.UnityClient/UserSettings/EditorUserSettings.asset create mode 100644 src/MessagePack.UnityClient/UserSettings/Layouts/default-2021.dwlt diff --git a/.github/workflows/unity.yml b/.github/workflows/unity.yml new file mode 100644 index 000000000..c3ee19439 --- /dev/null +++ b/.github/workflows/unity.yml @@ -0,0 +1,48 @@ +name: unity + +on: + workflow_dispatch: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +jobs: + unity: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + - uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: copy assets + run: src/MessagePack.UnityClient/copy_assets.sh + - uses: actions/cache@v3 + with: + path: src/MessagePack.UnityClient/Library + key: MessagePack-ubuntu + - name: build + uses: game-ci/unity-builder@v2 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE_2021 }} + with: + projectPath: src/MessagePack.UnityClient + unityVersion: 2021.3.11f1 + targetPlatform: StandaloneLinux64 + buildMethod: PackageExporter.Export + customParameters: /headless /ScriptBackend mono + versioning: None + - uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files + with: + directory: src/MessagePack.UnityClient + - uses: actions/upload-artifact@v3 + with: + name: MessagePack.unitypackage + path: bin/*.unitypackage diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d18997c3b..7944d2b00 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,18 +30,6 @@ stages: - template: azure-pipelines/build.yml - - job: Unity - pool: - name: CustomAgents - demands: - - UNITYHUB_EDITORS_FOLDER_LOCATION - - UNITYVERSION -equals 2019.1 - steps: - - checkout: self - clean: true - - template: azure-pipelines/install-dependencies.yml - - template: azure-pipelines/build_unity.yml - - job: Linux pool: vmImage: ubuntu-20.04 diff --git a/azure-pipelines/build_unity.yml b/azure-pipelines/build_unity.yml deleted file mode 100644 index 6338d449b..000000000 --- a/azure-pipelines/build_unity.yml +++ /dev/null @@ -1,34 +0,0 @@ -steps: -- powershell: Write-Host "##vso[task.setvariable variable=unity_package_version;]$((& (./azure-pipelines/Get-nbgv.ps1) get-version -f json | ConvertFrom-Json).NuGetPackageVersion)" - displayName: Get unity package version - -- script: dotnet publish src/MessagePack -c $(BuildConfiguration) -f netstandard2.0 - displayName: Build MessagePack - -- script: src/MessagePack.UnityClient/build.sh -l $(Build.ArtifactStagingDirectory)/build_logs/unitypackage.log - displayName: Build Unity package - -- task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: $(Build.ArtifactStagingDirectory)/build_logs - ArtifactName: build_logs - ArtifactType: Container - displayName: Publish build_logs artifacts - condition: succeededOrFailed() - -- task: CopyFiles@1 - inputs: - Contents: | - bin/*.unitypackage - TargetFolder: $(Build.ArtifactStagingDirectory)/unity - flattenFolders: true - displayName: Collecting deployables - condition: succeededOrFailed() - -- task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: $(Build.ArtifactStagingDirectory)/unity - ArtifactName: unity - ArtifactType: Container - displayName: Publish deployables artifacts - condition: succeededOrFailed() diff --git a/src/MessagePack.UnityClient/.vsconfig b/src/MessagePack.UnityClient/.vsconfig new file mode 100644 index 000000000..d70cd98b7 --- /dev/null +++ b/src/MessagePack.UnityClient/.vsconfig @@ -0,0 +1,6 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Workload.ManagedGame" + ] +} diff --git a/src/MessagePack.UnityClient/Assets/Resources.meta b/src/MessagePack.UnityClient/Assets/Resources.meta new file mode 100644 index 000000000..73088aba8 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b1de8635c42f5144f9c77b537e3a9616 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Resources/BillingMode.json b/src/MessagePack.UnityClient/Assets/Resources/BillingMode.json new file mode 100644 index 000000000..6f4bfb710 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Resources/BillingMode.json @@ -0,0 +1 @@ +{"androidStore":"GooglePlay"} \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Resources/BillingMode.json.meta b/src/MessagePack.UnityClient/Assets/Resources/BillingMode.json.meta new file mode 100644 index 000000000..7a0108031 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Resources/BillingMode.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ae6ce7e0a0dd7ca45b060f370d748bd3 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor.meta index 049ee1978..2e4c0c54e 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor.meta +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e64ff5fb973b7104f9c76c166c46f872 +guid: bc6ad6aaa548c204f9866a24b01d4507 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta index 102152e98..82c8e9bb4 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 50688156d1ed48e4d8e835a295e75699 +guid: 8760bbbab905a534eb6fb7b61b736926 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs index 9ec1c5453..94508b51c 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs @@ -169,6 +169,8 @@ static void BuildTargetStandaloneWindows64() SaveSettings(settings); } +#if !UNITY_2019_2_OR_NEWER + [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = true, priority = 3)] static bool ValidateBuildTargetStandaloneLinux() { @@ -185,6 +187,8 @@ static void BuildTargetStandaloneLinux() SaveSettings(settings); } +#endif + [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = true, priority = 4)] static bool ValidateBuildTargetStandaloneLinux64() { diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta index 5aef7c9ce..7c9917290 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8b7df7a947db56a4389c26cf3022840f +guid: 12bdad0556e999f4aa82da29415d361f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs index 46da861f4..9d7ddeb16 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs @@ -4,6 +4,7 @@ using RuntimeUnitTestToolkit.Editor; using System; using UnityEditor; +using UnityEditor.Build; using UnityEditor.Build.Reporting; using UnityEditor.SceneManagement; using UnityEngine; @@ -118,7 +119,7 @@ public static void BuildUnitTest() if (buildPath == null) { - buildPath = $"bin/UnitTest/{settings.BuildTarget}_{settings.ScriptBackend}/test" + (IsWindows(settings.BuildTarget) ? ".exe" : ""); + buildPath = $"bin/UnitTest/{settings.BuildTarget}_{settings.ScriptBackend}/test" + GetExtensionForBuildTarget(settings.BuildTarget); } var originalScene = SceneManager.GetActiveScene().path; @@ -397,7 +398,9 @@ static void Build(string sceneName, string buildPath, RuntimeUnitTestSettings se } if (settings.Headless) { +#pragma warning disable CS0618 options |= BuildOptions.EnableHeadlessMode; +#pragma warning restore CS0618 } var targetGroup = ToBuildTargetGroup(settings.BuildTarget); @@ -408,6 +411,9 @@ static void Build(string sceneName, string buildPath, RuntimeUnitTestSettings se PlayerSettings.SetScriptingBackend(targetGroup, settings.ScriptBackend); } + // MemoryPack changed: + EditorUserBuildSettings.il2CppCodeGeneration = Il2CppCodeGeneration.OptimizeSpeed; //runtime + var buildOptions = new BuildPlayerOptions { target = settings.BuildTarget, @@ -457,20 +463,42 @@ static bool IsWindows(BuildTarget buildTarget) } } + static string GetExtensionForBuildTarget(BuildTarget buildTarget) + { + switch (buildTarget) + { + case BuildTarget.StandaloneWindows: + case BuildTarget.StandaloneWindows64: + case BuildTarget.WSAPlayer: + return ".exe"; + case BuildTarget.StandaloneOSX: + return ".app"; + case BuildTarget.Android: + return ".apk"; + default: + return ""; + } + } + static BuildTargetGroup ToBuildTargetGroup(BuildTarget buildTarget) { #pragma warning disable CS0618 switch (buildTarget) { +#if UNITY_2017_3_OR_NEWER case BuildTarget.StandaloneOSX: - case (BuildTarget)3: +#else case BuildTarget.StandaloneOSXIntel: case BuildTarget.StandaloneOSXIntel64: + case BuildTarget.StandaloneOSXUniversal: +#endif // UNITY_2017_3_OR_NEWER case BuildTarget.StandaloneWindows: case BuildTarget.StandaloneWindows64: - case BuildTarget.StandaloneLinux: case BuildTarget.StandaloneLinux64: +#if !UNITY_2019_2_OR_NEWER + case BuildTarget.StandaloneLinux: case BuildTarget.StandaloneLinuxUniversal: +#endif // !UNITY_2019_2_OR_NEWER return BuildTargetGroup.Standalone; case (BuildTarget)6: case (BuildTarget)7: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs.meta index 7a1cd450b..bf66c58a9 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs.meta +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs.meta @@ -1,7 +1,8 @@ fileFormatVersion: 2 -guid: 4a1edf0e809243a4b95687c2fc05134c +guid: 3518da33b6245d341a0ef3670ee9268b +timeCreated: 1488689723 +licenseType: Pro MonoImporter: - externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta index d96593114..5ad198be0 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e1ad5407f3f9cec45a06a114f01e5d25 +guid: 14c4fea4b238088479114ba2ffe195f9 AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs new file mode 100644 index 000000000..2e31d3af6 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs @@ -0,0 +1,391 @@ +using NUnit.Framework; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEngine; +using UnityEngine.TestTools; + +namespace RuntimeUnitTestToolkit +{ + public class UnitTestData + { + // [SetupFixture][OneTimeSetup] + readonly List globalSetups = new List(); + // [SetupFixture][OneTimeTearDown] + readonly List globalTearDowns = new List(); + + // Key:Type.FullName + readonly Dictionary testGroups = new Dictionary(); + + public IEnumerable GlobalSetups => globalSetups; + public IEnumerable GlobalTearDowns => globalTearDowns; + public IEnumerable> TestGroups => testGroups; + + static IEnumerable GetTestTargetTypes() + { + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + var n = assembly.FullName; + if (n.StartsWith("UnityEngine")) continue; + if (n.StartsWith("mscorlib")) continue; + if (n.StartsWith("System")) continue; + + foreach (var item in assembly.GetTypes()) + { + SetUpFixtureAttribute setupFixture; + try + { + setupFixture = item.GetCustomAttribute(true); + } + catch (Exception ex) + { + Debug.Log("TestAttribute Load Fail, Assembly:" + assembly.FullName); + Debug.LogException(ex); + goto NEXT_ASSEMBLY; + } + if (setupFixture != null) + { + yield return item; + continue; + } + + foreach (var method in item.GetMethods()) + { + TestAttribute t1 = null; + try + { + t1 = method.GetCustomAttribute(true); + } + catch (Exception ex) + { + Debug.Log("TestAttribute Load Fail, Assembly:" + assembly.FullName); + Debug.LogException(ex); + goto NEXT_ASSEMBLY; + } + if (t1 != null) + { + yield return item; + break; + } + + UnityTestAttribute t2 = null; + try + { + t2 = method.GetCustomAttribute(true); + } + catch (Exception ex) + { + Debug.Log("UnityTestAttribute Load Fail, Assembly:" + assembly.FullName); + Debug.LogException(ex); + goto NEXT_ASSEMBLY; + } + if (t2 != null) + { + yield return item; + break; + } + } + } + + NEXT_ASSEMBLY: + continue; + } + } + + static void RegisterAttributeAction(MethodInfo info, object instance, List list) + where T : Attribute + { + var attr = info.GetCustomAttribute(true); + if (attr != null) + { + list.Add((Action)Delegate.CreateDelegate(typeof(Action), instance, info)); + } + } + + public static UnitTestData CreateFromAllAssemblies() + { + return new UnitTestData(); + } + + UnitTestData() + { + foreach (var testType in GetTestTargetTypes()) + { + var setupFixture = testType.GetCustomAttribute(true); + if (setupFixture != null) + { + var instance = Activator.CreateInstance(testType); + + var methods = testType.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); + foreach (var item in methods) + { + RegisterAttributeAction(item, instance, globalSetups); + RegisterAttributeAction(item, instance, globalTearDowns); + } + continue; + } + else + { + var group = new TestGroup(testType); + testGroups[testType.FullName] = group; + } + } + } + } + + public class TestGroup + { + // [Test] + List<(string name, Action test)> syncTests = new List<(string name, Action test)>(); + + // [UnityTest] + List<(string name, Func test)> asyncTests = new List<(string name, Func test)>(); + + // [SetUp] + List setups = new List(); + + // [OneTimeSetUp] + List onetimeSetups = new List(); + + // [TearDown] + List tearDowns = new List(); + + // [OneTimeTearDown] + List oneTimeTearDowns = new List(); + + // [UnitySetUp] + List> unitySetUps = new List>(); + + // [UnityTearDown] + List> unityTearDowns = new List>(); + + public string Name { get; private set; } + public IEnumerable<(string name, Action test)> SyncTests => syncTests; + public IEnumerable<(string name, Func test)> AsyncTests => asyncTests; + public IEnumerable Setups => setups; + public IEnumerable OnetimeSetups => onetimeSetups; + public IEnumerable TearDowns => tearDowns; + public IEnumerable OneTimeTearDowns => oneTimeTearDowns; + public IEnumerable> UnitySetUps => unitySetUps; + public IEnumerable> UnityTearDowns => unityTearDowns; + + public IEnumerable<(string name, object test)> Tests + { + get + { + foreach (var item in syncTests) yield return (item.name, item.test); + foreach (var item in asyncTests) yield return (item.name, item.test); + } + } + + static void RegisterAttributeAction(MethodInfo info, object instance, List list) + where T : Attribute + { + var attr = info.GetCustomAttribute(true); + if (attr != null) + { + list.Add((Action)Delegate.CreateDelegate(typeof(Action), instance, info)); + } + } + + static void RegisterAttributeAction(MethodInfo info, object instance, List> list) + where T : Attribute + { + var attr = info.GetCustomAttribute(true); + if (attr != null) + { + list.Add((Func)Delegate.CreateDelegate(typeof(Func), instance, info)); + } + } + + public TestGroup(Type testType) + { + this.Name = testType.Name; // not FullName + + var test = Activator.CreateInstance(testType); + var methods = testType.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); + + foreach (var item in methods) + { + try + { + RegisterAttributeAction(item, test, setups); + RegisterAttributeAction(item, test, tearDowns); + RegisterAttributeAction(item, test, onetimeSetups); + RegisterAttributeAction(item, test, oneTimeTearDowns); + RegisterAttributeAction(item, test, unitySetUps); + RegisterAttributeAction(item, test, unityTearDowns); + } + catch (Exception e) + { + UnityEngine.Debug.LogError(testType.Name + "." + item.Name + " failed to register setup/teardown method, exception: " + e.ToString()); + } + + try + { + var iteratorTest = item.GetCustomAttribute(true); + if (iteratorTest != null) + { + if (item.GetParameters().Length == 0 && item.ReturnType == typeof(IEnumerator)) + { + var factory = (Func)Delegate.CreateDelegate(typeof(Func), test, item); + asyncTests.Add((factory.Method.Name, factory)); + } + else + { + var testData = GetTestData(item); + if (testData.Count != 0) + { + foreach (var item2 in testData) + { + Func factory; + if (item.IsGenericMethod) + { + var method2 = InferGenericType(item, item2); + factory = () => (IEnumerator)method2.Invoke(test, item2); + } + else + { + factory = () => (IEnumerator)item.Invoke(test, item2); + } + var name = item.Name + "(" + string.Join(", ", item2.Select(x => x?.ToString() ?? "null")) + ")"; + name = name.Replace(Char.MinValue, ' ').Replace(Char.MaxValue, ' ').Replace("<", "[").Replace(">", "]"); + asyncTests.Add((name, factory)); + } + } + else + { + UnityEngine.Debug.Log(testType.Name + "." + item.Name + " currently does not supported in RuntumeUnitTestToolkit(multiple parameter without TestCase or return type is invalid)."); + } + } + } + + var standardTest = item.GetCustomAttribute(true); + if (standardTest != null) + { + if (item.GetParameters().Length == 0 && item.ReturnType == typeof(void)) + { + var invoke = (Action)Delegate.CreateDelegate(typeof(Action), test, item); + syncTests.Add((invoke.Method.Name, invoke)); + } + else + { + var testData = GetTestData(item); + if (testData.Count != 0) + { + foreach (var item2 in testData) + { + Action invoke = null; + if (item.IsGenericMethod) + { + var method2 = InferGenericType(item, item2); + invoke = () => method2.Invoke(test, item2); + } + else + { + invoke = () => item.Invoke(test, item2); + } + var name = item.Name + "(" + string.Join(", ", item2.Select(x => x?.ToString() ?? "null")) + ")"; + name = name.Replace(Char.MinValue, ' ').Replace(Char.MaxValue, ' ').Replace("<", "[").Replace(">", "]"); + syncTests.Add((name, invoke)); + } + } + else + { + UnityEngine.Debug.Log(testType.Name + "." + item.Name + " currently does not supported in RuntumeUnitTestToolkit(multiple parameter without TestCase or return type is invalid)."); + } + } + } + } + catch (Exception e) + { + UnityEngine.Debug.LogError(testType.Name + "." + item.Name + " failed to register method, exception: " + e.ToString()); + } + } + } + + List GetTestData(MethodInfo methodInfo) + { + List testCases = new List(); + + var inlineData = methodInfo.GetCustomAttributes(true); + foreach (var item in inlineData) + { + testCases.Add(item.Arguments); + } + + var sourceData = methodInfo.GetCustomAttributes(true); + foreach (var item in sourceData) + { + var enumerator = GetTestCaseSource(methodInfo, item.SourceType, item.SourceName, item.MethodParams); + foreach (var item2 in enumerator) + { + var item3 = item2 as IEnumerable; // object[][] + if (item3 != null) + { + var l = new List(); + foreach (var item4 in item3) + { + l.Add(item4); + } + testCases.Add(l.ToArray()); + } + } + } + + return testCases; + } + + IEnumerable GetTestCaseSource(MethodInfo method, Type sourceType, string sourceName, object[] methodParams) + { + Type type = sourceType ?? method.DeclaringType; + + MemberInfo[] member = type.GetMember(sourceName, BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); + if (member.Length == 1) + { + MemberInfo memberInfo = member[0]; + FieldInfo fieldInfo = memberInfo as FieldInfo; + if ((object)fieldInfo != null) + { + return (!fieldInfo.IsStatic) ? ReturnErrorAsParameter("The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method.") : ((methodParams == null) ? ((IEnumerable)fieldInfo.GetValue(null)) : ReturnErrorAsParameter("You have specified a data source field but also given a set of parameters. Fields cannot take parameters, please revise the 3rd parameter passed to the TestCaseSourceAttribute and either remove it or specify a method.")); + } + PropertyInfo propertyInfo = memberInfo as PropertyInfo; + if ((object)propertyInfo != null) + { + return (!propertyInfo.GetGetMethod(nonPublic: true).IsStatic) ? ReturnErrorAsParameter("The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method.") : ((methodParams == null) ? ((IEnumerable)propertyInfo.GetValue(null, null)) : ReturnErrorAsParameter("You have specified a data source property but also given a set of parameters. Properties cannot take parameters, please revise the 3rd parameter passed to the TestCaseSource attribute and either remove it or specify a method.")); + } + MethodInfo methodInfo = memberInfo as MethodInfo; + if ((object)methodInfo != null) + { + return (!methodInfo.IsStatic) ? ReturnErrorAsParameter("The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method.") : ((methodParams == null || methodInfo.GetParameters().Length == methodParams.Length) ? ((IEnumerable)methodInfo.Invoke(null, methodParams)) : ReturnErrorAsParameter("You have given the wrong number of arguments to the method in the TestCaseSourceAttribute, please check the number of parameters passed in the object is correct in the 3rd parameter for the TestCaseSourceAttribute and this matches the number of parameters in the target method and try again.")); + } + } + return null; + } + + MethodInfo InferGenericType(MethodInfo methodInfo, object[] parameters) + { + var set = new HashSet(); + List genericParameters = new List(); + foreach (var item in methodInfo.GetParameters() + .Select((x, i) => new { x.ParameterType, i }) + .Where(x => x.ParameterType.IsGenericParameter) + .OrderBy(x => x.ParameterType.GenericParameterPosition)) + { + if (set.Add(item.ParameterType)) // DistinctBy + { + genericParameters.Add(parameters[item.i].GetType()); + } + } + + return methodInfo.MakeGenericMethod(genericParameters.ToArray()); + } + + IEnumerable ReturnErrorAsParameter(string name) + { + throw new Exception(name); + } + } +} \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs.meta new file mode 100644 index 000000000..dc968a32b --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9658eff528f61734a84e348d7954e502 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs index 8637876cd..e05b45c0e 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs +++ b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs @@ -13,9 +13,7 @@ namespace RuntimeUnitTestToolkit { public class UnitTestRunner : MonoBehaviour { - // object is IEnumerator or Func - Dictionary> tests = new Dictionary>(); - + UnitTestData testData; List additionalActionsOnFirst = new List(); public Button clearButton; @@ -50,21 +48,18 @@ void Start() }; // register all test types - foreach (var item in GetTestTargetTypes()) - { - RegisterAllMethods(item); - } + testData = UnitTestData.CreateFromAllAssemblies(); var executeAll = new List>(); - foreach (var ___item in tests) + foreach (var ___item in testData.TestGroups) { var actionList = ___item; // be careful, capture in lambda - executeAll.Add(() => StartCoroutine(RunTestInCoroutine(actionList))); - Add(actionList.Key, () => StartCoroutine(RunTestInCoroutine(actionList))); + executeAll.Add(() => StartCoroutine(RunTestInCoroutine(actionList.Key, actionList.Value, true))); + Add(actionList.Key, actionList.Value.Name, () => StartCoroutine(RunTestInCoroutine(actionList.Key, actionList.Value, false))); } - var executeAllButton = Add("Run All Tests", () => StartCoroutine(ExecuteAllInCoroutine(executeAll))); + var executeAllButton = Add("$<>__AllTest", "Run All Tests", () => StartCoroutine(ExecuteAllInCoroutine(executeAll))); clearButton.gameObject.GetComponent().color = new Color(170 / 255f, 170 / 255f, 170 / 255f, 1); executeAllButton.gameObject.GetComponent().color = new Color(250 / 255f, 150 / 255f, 150 / 255f, 1); @@ -117,10 +112,10 @@ void Start() } } - Button Add(string title, UnityAction test) + Button Add(string key, string title, UnityAction test) { var newButton = GameObject.Instantiate(clearButton); - newButton.name = title; + newButton.name = key; newButton.onClick.RemoveAllListeners(); newButton.GetComponentInChildren().text = title; newButton.onClick.AddListener(test); @@ -178,249 +173,16 @@ static IEnumerable GetTestTargetTypes() } } -NEXT_ASSEMBLY: + NEXT_ASSEMBLY: continue; } } - public void AddTest(string group, string title, Action test, List setups, List teardowns) - { - List list; - if (!tests.TryGetValue(group, out list)) - { - list = new List(); - tests[group] = list; - } - - list.Add(new TestKeyValuePair(title, test, setups, teardowns)); - } - - public void AddAsyncTest(string group, string title, Func asyncTestCoroutine, List setups, List teardowns) - { - List list; - if (!tests.TryGetValue(group, out list)) - { - list = new List(); - tests[group] = list; - } - - list.Add(new TestKeyValuePair(title, asyncTestCoroutine, setups, teardowns)); - } - public void AddCutomAction(string name, UnityAction action) { additionalActionsOnFirst.Add(new Pair { Name = name, Action = action }); } - - public void RegisterAllMethods() - where T : new() - { - RegisterAllMethods(typeof(T)); - } - - public void RegisterAllMethods(Type testType) - { - try - { - var test = Activator.CreateInstance(testType); - - var methods = testType.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); - List setups = new List(); - List teardowns = new List(); - foreach (var item in methods) - { - try - { - var setup = item.GetCustomAttribute(true); - if (setup != null) - { - setups.Add((Action)Delegate.CreateDelegate(typeof(Action), test, item)); - } - var teardown = item.GetCustomAttribute(true); - if (teardown != null) - { - teardowns.Add((Action)Delegate.CreateDelegate(typeof(Action), test, item)); - } - } - catch (Exception e) - { - UnityEngine.Debug.LogError(testType.Name + "." + item.Name + " failed to register setup/teardown method, exception: " + e.ToString()); - } - } - - foreach (var item in methods) - { - try - { - var iteratorTest = item.GetCustomAttribute(true); - if (iteratorTest != null) - { - if (item.GetParameters().Length == 0 && item.ReturnType == typeof(IEnumerator)) - { - var factory = (Func)Delegate.CreateDelegate(typeof(Func), test, item); - AddAsyncTest(factory.Target.GetType().Name, factory.Method.Name, factory, setups, teardowns); - } - else - { - var testData = GetTestData(item); - if (testData.Count != 0) - { - foreach (var item2 in testData) - { - Func factory; - if (item.IsGenericMethod) - { - var method2 = InferGenericType(item, item2); - factory = () => (IEnumerator)method2.Invoke(test, item2); - } - else - { - factory = () => (IEnumerator)item.Invoke(test, item2); - } - var name = item.Name + "(" + string.Join(", ", item2.Select(x => x?.ToString() ?? "null")) + ")"; - name = name.Replace(Char.MinValue, ' ').Replace(Char.MaxValue, ' ').Replace("<", "[").Replace(">", "]"); - AddAsyncTest(test.GetType().Name, name, factory, setups, teardowns); - } - } - else - { - UnityEngine.Debug.Log(testType.Name + "." + item.Name + " currently does not supported in RuntumeUnitTestToolkit(multiple parameter without TestCase or return type is invalid)."); - } - } - } - - var standardTest = item.GetCustomAttribute(true); - if (standardTest != null) - { - if (item.GetParameters().Length == 0 && item.ReturnType == typeof(void)) - { - var invoke = (Action)Delegate.CreateDelegate(typeof(Action), test, item); - AddTest(invoke.Target.GetType().Name, invoke.Method.Name, invoke, setups, teardowns); - } - else - { - var testData = GetTestData(item); - if (testData.Count != 0) - { - foreach (var item2 in testData) - { - Action invoke = null; - if (item.IsGenericMethod) - { - var method2 = InferGenericType(item, item2); - invoke = () => method2.Invoke(test, item2); - } - else - { - invoke = () => item.Invoke(test, item2); - } - var name = item.Name + "(" + string.Join(", ", item2.Select(x => x?.ToString() ?? "null")) + ")"; - name = name.Replace(Char.MinValue, ' ').Replace(Char.MaxValue, ' ').Replace("<", "[").Replace(">", "]"); - AddTest(test.GetType().Name, name, invoke, setups, teardowns); - } - } - else - { - UnityEngine.Debug.Log(testType.Name + "." + item.Name + " currently does not supported in RuntumeUnitTestToolkit(multiple parameter without TestCase or return type is invalid)."); - } - } - } - } - catch (Exception e) - { - UnityEngine.Debug.LogError(testType.Name + "." + item.Name + " failed to register method, exception: " + e.ToString()); - } - } - } - catch (Exception ex) - { - Debug.LogException(ex); - } - } - - List GetTestData(MethodInfo methodInfo) - { - List testCases = new List(); - - var inlineData = methodInfo.GetCustomAttributes(true); - foreach (var item in inlineData) - { - testCases.Add(item.Arguments); - } - - var sourceData = methodInfo.GetCustomAttributes(true); - foreach (var item in sourceData) - { - var enumerator = GetTestCaseSource(methodInfo, item.SourceType, item.SourceName, item.MethodParams); - foreach (var item2 in enumerator) - { - var item3 = item2 as IEnumerable; // object[][] - if (item3 != null) - { - var l = new List(); - foreach (var item4 in item3) - { - l.Add(item4); - } - testCases.Add(l.ToArray()); - } - } - } - - return testCases; - } - - IEnumerable GetTestCaseSource(MethodInfo method, Type sourceType, string sourceName, object[] methodParams) - { - Type type = sourceType ?? method.DeclaringType; - - MemberInfo[] member = type.GetMember(sourceName, BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); - if (member.Length == 1) - { - MemberInfo memberInfo = member[0]; - FieldInfo fieldInfo = memberInfo as FieldInfo; - if ((object)fieldInfo != null) - { - return (!fieldInfo.IsStatic) ? ReturnErrorAsParameter("The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method.") : ((methodParams == null) ? ((IEnumerable)fieldInfo.GetValue(null)) : ReturnErrorAsParameter("You have specified a data source field but also given a set of parameters. Fields cannot take parameters, please revise the 3rd parameter passed to the TestCaseSourceAttribute and either remove it or specify a method.")); - } - PropertyInfo propertyInfo = memberInfo as PropertyInfo; - if ((object)propertyInfo != null) - { - return (!propertyInfo.GetGetMethod(nonPublic: true).IsStatic) ? ReturnErrorAsParameter("The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method.") : ((methodParams == null) ? ((IEnumerable)propertyInfo.GetValue(null, null)) : ReturnErrorAsParameter("You have specified a data source property but also given a set of parameters. Properties cannot take parameters, please revise the 3rd parameter passed to the TestCaseSource attribute and either remove it or specify a method.")); - } - MethodInfo methodInfo = memberInfo as MethodInfo; - if ((object)methodInfo != null) - { - return (!methodInfo.IsStatic) ? ReturnErrorAsParameter("The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method.") : ((methodParams == null || methodInfo.GetParameters().Length == methodParams.Length) ? ((IEnumerable)methodInfo.Invoke(null, methodParams)) : ReturnErrorAsParameter("You have given the wrong number of arguments to the method in the TestCaseSourceAttribute, please check the number of parameters passed in the object is correct in the 3rd parameter for the TestCaseSourceAttribute and this matches the number of parameters in the target method and try again.")); - } - } - return null; - } - - MethodInfo InferGenericType(MethodInfo methodInfo, object[] parameters) - { - var set = new HashSet(); - List genericParameters = new List(); - foreach (var item in methodInfo.GetParameters() - .Select((x, i) => new { x.ParameterType, i }) - .Where(x => x.ParameterType.IsGenericParameter) - .OrderBy(x => x.ParameterType.GenericParameterPosition)) - { - if (set.Add(item.ParameterType)) // DistinctBy - { - genericParameters.Add(parameters[item.i].GetType()); - } - } - - return methodInfo.MakeGenericMethod(genericParameters.ToArray()); - } - - IEnumerable ReturnErrorAsParameter(string name) - { - throw new Exception(name); - } - System.Collections.IEnumerator ScrollLogToEndNextFrame() { yield return null; @@ -428,13 +190,13 @@ System.Collections.IEnumerator ScrollLogToEndNextFrame() logScrollBar.value = 0; } - IEnumerator RunTestInCoroutine(KeyValuePair> actionList) + IEnumerator RunTestInCoroutine(string key, TestGroup testGroup, bool withoutGlobalSetup) { Button self = null; foreach (var btn in list.GetComponentsInChildren