Skip to content

Commit

Permalink
Adding ASP.NET Core 3.0 Support (#400)
Browse files Browse the repository at this point in the history
This set of changes drops view profiling for the moment in ASP.NET Core 3.x since the types we were wrapping as "pubternal" are no longer exposed in 3.0. On the framework side, dotnet/aspnetcore#11730 is in progress so we can use the diagnostics API to hopefully re-enable this for the 3.0 release.

Samples for ASP.NET Core 2.2 and 3.0 are broken into separate samples for clarity though they are mostly the same.

Overall changes:
- (For Linux): Fix Azure DevOps builds (note they're not successfully running all tests yet - some providers are skipped, but they're working!)
- (For Linux): Change SQL Formatters to always use `\n`
- (For Linux): Add `WindowsOnly` to `[Fact]` and `[Theory]` for skipping inapplicable tests on Linux
- (For Linux): Add `xunit.runner.json` to make things work on Linux/Mono (only copied to output and in effect there)
- (For Linux): Null ref fix for SQL CE errors (happens on Linux)
- (For .NET Core 3.0): Add a `netcoreapp3.0` build for `MiniProfiler.AspNet*` libs
- (For .NET Core 3.0): Exclude view profiling for now (this is what was breaking, ultimately)
- (For .NET Core 3.0): Split ASP.NET Core v2 and v3 samples into different projects, since some fundamentals have changed
- (For all): Bump version to `4.1.0-preview.*` to reflect the preview dependencies for `netcoreapp3.0` builds
- (For all): Dropped `netcoreapp1.1` from testing (note: `netstandard1.5` is still built, it's just not tested)
  • Loading branch information
NickCraver authored Nov 11, 2020
1 parent bb41fd3 commit 0cf2e39
Show file tree
Hide file tree
Showing 147 changed files with 20,985 additions and 429 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ src/MiniProfiler.Shared/ui/lib/MiniProfiler.js.map
src/MiniProfiler.Shared/ui/includes.js
src/MiniProfiler.Shared/ui/includes.min.js
tests/MiniProfiler.Tests/Test-*.xml
*.trx
17 changes: 12 additions & 5 deletions MiniProfiler.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.29021.104
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{CC40098D-04F2-4F43-B5CF-B74F74351761}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -35,7 +35,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.Providers.SqlS
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Mvc5", "samples\Samples.Mvc5\Samples.Mvc5.csproj", "{C179CF56-7AC2-4340-8D43-2A3DCDB2E448}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.AspNetCore", "samples\Samples.AspNetCore\Samples.AspNetCore.csproj", "{A3946CAB-4BF9-47C1-A517-104CD8D7F46C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.AspNetCore2", "samples\Samples.AspNetCore2\Samples.AspNetCore2.csproj", "{A3946CAB-4BF9-47C1-A517-104CD8D7F46C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.AspNetCore", "src\MiniProfiler.AspNetCore\MiniProfiler.AspNetCore.csproj", "{6A2B5B70-1C32-482F-B5C6-0597E2D4E376}"
EndProject
Expand Down Expand Up @@ -78,10 +78,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Mvc5.EFCore", "samp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.Providers.MongoDB", "src\MiniProfiler.Providers.MongoDB\MiniProfiler.Providers.MongoDB.csproj", "{001EFFB2-E56C-4A63-9954-79D7AEB052DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Misc", "samples\Misc\Misc.csproj", "{44075C61-13E9-4C78-B340-6045EA115433}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Misc", "samples\Misc\Misc.csproj", "{44075C61-13E9-4C78-B340-6045EA115433}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.Providers.PostgreSql", "src\MiniProfiler.Providers.PostgreSql\MiniProfiler.Providers.PostgreSql.csproj", "{61E02A52-EB05-4B48-9AAE-BC7C1741E557}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.AspNetCore3", "samples\Samples.AspNetCore3\Samples.AspNetCore3.csproj", "{D95A09CD-A291-42D0-AA41-8426090D0476}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -188,6 +190,10 @@ Global
{61E02A52-EB05-4B48-9AAE-BC7C1741E557}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61E02A52-EB05-4B48-9AAE-BC7C1741E557}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61E02A52-EB05-4B48-9AAE-BC7C1741E557}.Release|Any CPU.Build.0 = Release|Any CPU
{D95A09CD-A291-42D0-AA41-8426090D0476}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D95A09CD-A291-42D0-AA41-8426090D0476}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D95A09CD-A291-42D0-AA41-8426090D0476}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D95A09CD-A291-42D0-AA41-8426090D0476}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -218,10 +224,11 @@ Global
{001EFFB2-E56C-4A63-9954-79D7AEB052DB} = {6A510DBF-E85F-4D2C-B8F7-006DA31B3418}
{44075C61-13E9-4C78-B340-6045EA115433} = {E0DA4035-4D64-4BB8-8EA1-42197DE62519}
{61E02A52-EB05-4B48-9AAE-BC7C1741E557} = {6A510DBF-E85F-4D2C-B8F7-006DA31B3418}
{D95A09CD-A291-42D0-AA41-8426090D0476} = {E0DA4035-4D64-4BB8-8EA1-42197DE62519}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9373F37A-A996-4545-A251-1902C8886E3F}
LessCompiler = 6a2b5b70-1c32-482f-b5c6-0597e2d4e376
SolutionGuid = {9373F37A-A996-4545-A251-1902C8886E3F}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = StackExchange.Profiling.vsmdi
Expand Down
3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
image: Visual Studio 2017

init:
- git config --global core.autocrlf input
- SET PATH=%POSTGRES_PATH%\bin;%MYSQL_PATH%\bin;%PATH%

install:
- choco install dotnetcore-sdk --version 3.0.100-preview6-012264
- nuget install redis-64 -excludeversion
- redis-64\tools\redis-server.exe --service-install
- redis-64\tools\redis-server.exe --service-start
Expand Down Expand Up @@ -48,7 +48,6 @@ build_script:
- createdb test
# MySQL
- mysql -e "create database test;" --user=root
- ps: .\build\dotnet-install.ps1 -Version 2.1.300
- ps: .\build.ps1 -PullRequestNumber "$env:APPVEYOR_PULL_REQUEST_NUMBER" -CreatePackages $true

test: off
Expand Down
40 changes: 16 additions & 24 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ resources:
image: mongo
ports:
- 27017:27017
- container: mysql
image: mysql
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
- container: postgres
image: postgres
ports:
Expand All @@ -23,19 +16,13 @@ resources:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test

services:
redis: redis
mongo: mongo
mysql: mysql
postgres: postgres

pool:
name: Hosted Windows Container
vmImage: win1803
vmImage: 'ubuntu-16.04'

# Build Variables
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
MYSQL_DATABASE: test
RedisConnectionString: localhost:6379
MongoDbConnectionString: mongodb://localhost:27017/test
MySQLConnectionString: server=localhost;uid=root;pwd=root;database=test;Allow User Variables=true
Expand Down Expand Up @@ -65,23 +52,28 @@ pr:
- '**/*.md'

steps:
- task: DotNetCoreInstaller@0
displayName: 'Install DotNet Core 2.1.3'
- task: UseDotNet@2
inputs:
packageType: 'runtime'
version: '2.2.5'

- task: UseDotNet@2
inputs:
version: 2.1.300
packageType: 'sdk'
version: '3.0.100-preview6-012264'

- task: PowerShell@2
displayName: 'Build / Test / Create Packages'
inputs:
targetType: filePath
filePath: build.AzureDevops.ps1
targetType: inline
script: .\build.ps1 -CreatePackages $true -PullRequestNumber $env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER

- task: PublishTestResults@2
displayName: 'Publish Test Results **/Test-*.xml'
displayName: 'Publish Test Results **/*.trx'
condition: succeededOrFailed()
inputs:
testResultsFormat: XUnit
testResultsFiles: '**/Test-*.xml'
mergeTestResults: true
testRunner: VSTest
testResultsFiles: '**/*.trx'

# PR doesn't create nuget packages. So publish artifact step disabled for PR's
- task: PublishBuildArtifacts@1
Expand Down
2 changes: 0 additions & 2 deletions build.azureDevops.ps1

This file was deleted.

5 changes: 3 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ $projectsToBuild =

$testsToRun =
'MiniProfiler.Tests',
'MiniProfiler.Tests.AspNet'
'MiniProfiler.Tests.AspNet',
'MiniProfiler.Tests.AspNetCore'

if ($PullRequestNumber) {
Write-Host "Building for a pull request (#$PullRequestNumber), skipping packaging." -ForegroundColor Yellow
Expand All @@ -46,7 +47,7 @@ if ($RunTests) {
Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta"
Push-Location ".\tests\$project"

dotnet test -c Release --no-build
dotnet test -c Release --no-build --logger trx
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Pop-Location
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.300"
"version": "3.0.100-preview6-012264"
}
}
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions samples/Samples.AspNetCore2/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ASP.NET Core 2.2
--------
This is a sample project demonstrating how MiniProfiler can be used in ASP.NET Core 2.2.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@
<ProjectReference Include="..\..\src\MiniProfiler.Providers.SqlServer\MiniProfiler.Providers.SqlServer.csproj" />
<ProjectReference Include="..\..\src\MiniProfiler.Providers.Sqlite\MiniProfiler.Providers.Sqlite.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</ItemGroup>
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions samples/Samples.AspNetCore3/Controllers/AreaController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;

namespace Samples.AspNetCore.Controllers
{
[Area("MySpace")]
public class AreaController : Controller
{
public IActionResult Simple() => Content("Simple");

public IActionResult Index() => View();
}
}
26 changes: 26 additions & 0 deletions samples/Samples.AspNetCore3/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
using StackExchange.Profiling;

namespace Samples.AspNetCore.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
using (MiniProfiler.Current.Step("Example Step"))
{
using (MiniProfiler.Current.Step("Sub timing"))
{
// Not trying to delay the page load here, only serve as an example
}
using (MiniProfiler.Current.Step("Sub timing 2"))
{
// Not trying to delay the page load here, only serve as an example
}
}
return View();
}

public IActionResult Error() => View();
}
}
Loading

0 comments on commit 0cf2e39

Please sign in to comment.