Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to .NET Core 3.1. #2

Merged
merged 6 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

# name: $(majorVersion).$(minorVersion).$(patchVersion)$(channelVersion)$(buildVersion)$(Rev:.r)

trigger:
branches:
include:
- master
tags:
include:
- v*

pool:
vmImage: "ubuntu-18.04"

variables:
buildConfiguration: "Release"
projectName: "Mocoding.AspNetCore.ODataApi"
solutionFile: "odata-api.sln"
oDataApi: $(projectName)
oDataApiEasyDocDb: $(projectName).EasyDocDb
oDataApiEntityFramework: $(projectName).EntityFramework
oDataApiMongoDb: $(projectName).MongoDb

stages:
- stage: Build
pool:
vmImage: "ubuntu-18.04"
jobs:
- job: Package
steps:
- task: UseGitVersion@5
displayName: "Git Version"
inputs:
versionSpec: "5.0.0"
useConfigFile: true
configFilePath: "GitVersion.yml"

- task: UseDotNet@2
displayName: 'Install .NET Core sdk'
inputs:
packageType: sdk
version: 2.0.0
installationPath: $(Agent.ToolsDirectory)/dotnet

- task: UseDotNet@2
displayName: 'Install .NET Core sdk'
inputs:
packageType: sdk
version: 3.1.300
installationPath: $(Agent.ToolsDirectory)/dotnet

- task: DotNetCoreCLI@2
displayName: "dotnet restore"
inputs:
command: restore
projects: $(solutionFile)

- task: SonarCloudPrepare@1
displayName: "Sonarcloud - Prepare"
inputs:
SonarCloud: 'sonarcloud'
organization: 'mocoding'
scannerMode: 'MSBuild'
projectKey: 'mocoding-software_odata-api'
extraProperties: 'sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/coverage.opencover.xml'

- task: DotNetCoreCLI@2
displayName: "dotnet build"
inputs:
command: build
projects: $(solutionFile)

- task: DotNetCoreCLI@2
displayName: "dotnet test"
inputs:
command: test
projects: 'test/**/*.Tests.csproj'
arguments: "--no-build /p:SkipCodeCoverageReport=true /p:Threshold=33 /p:CoverletOutput=$(Agent.TempDirectory)/"

- task: SonarCloudAnalyze@1
displayName: "Sonarcloud Analyze"

- task: SonarCloudPublish@1
displayName: "Sonarcloud Publish"
inputs:
pollingTimeoutSec: '300'

- task: PublishCodeCoverageResults@1
displayName: "Public Code Coverage"
inputs:
codeCoverageTool: "Cobertura"
summaryFileLocation: "$(Agent.TempDirectory)/coverage.cobertura.xml"
condition: succeededOrFailed()

- template: pack-template.yml
parameters:
project: $(oDataApi)

- template: pack-template.yml
parameters:
project: $(oDataApiEasyDocDb)

- template: pack-template.yml
parameters:
project: $(oDataApiEntityFramework)

- template: pack-template.yml
parameters:
project: $(oDataApiMongoDb)

- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: nupkg"
inputs:
PathtoPublish: "$(Build.StagingDirectory)"
ArtifactName: nupkg
- stage: Deploy
dependsOn: Build
condition: and(succeeded(), contains(variables['Build.Reason'], 'PullRequest'))
pool:
vmImage: "ubuntu-18.04"
jobs:
- deployment: DevBuild
environment: "dev-builds"
strategy:
runOnce:
deploy:
steps:
- task: NuGetCommand@2
displayName: "Publish to nuget (dev-builds)"
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg;'
nuGetFeedType: 'internal'
publishVstsFeed: 'da7703d4-fb22-4933-b869-83f4264b7b84/e1336e71-3540-4a0c-830c-639112685b07'
allowPackageConflicts: true
- stage: Release
dependsOn: Build
condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'tags/v'))
pool:
vmImage: "ubuntu-18.04"
jobs:
- deployment: Public
environment: "public"
strategy:
runOnce:
deploy:
steps:
- task: NuGetCommand@2
displayName: "Publish"
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg;'
nuGetFeedType: 'external'
publishFeedCredentials: 'public-nuget'
- task: GitHubRelease@1
displayName: 'Update GitHub release'
inputs:
gitHubConnection: 'mocoding-software'
repositoryName: 'mocoding-software/odata-api'
action: edit
tag: 'v$(Build.BuildNumber)'
assets: '$(Pipeline.Workspace)/**/*.nupkg'
assetUploadMode: replace
13 changes: 13 additions & 0 deletions .azure-pipelines/pack-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
- name: project
type: string
default: ""
steps:
- task: DotNetCoreCLI@2
displayName: "dotnet pack ${{ parameters.project }}"
inputs:
command: pack
packagesToPack: "src/${{ parameters.project }}/${{ parameters.project }}.csproj"
configuration: $(buildConfiguration)
packDirectory: "$(Build.StagingDirectory)/${{ parameters.project }}"
buildProperties: "Version=$(Build.BuildNumber)"
50 changes: 50 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "Existing Docker Compose (Extend)",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"docker-compose.yml"
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "devbox",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspace",

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
// This will ignore your local shell user setting for Linux since shells like zsh are typically
// not in base container images. You can also update this to an specific shell to ensure VS Code
// uses the right one for terminals and tasks. For example, /bin/bash (or /bin/ash for Alpine).
"terminal.integrated.shell.linux": null
},

// Uncomment the next line to have VS Code connect as an existing non-root user in the container. See
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
// "remoteUser": "vscode",

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created - for example installing git.
"postCreateCommand": "apt-get update && apt-get install -y git",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"ms-vscode.csharp",
"fudge.auto-using",
"formulahendry.dotnet-test-explorer",
"tintoy.msbuild-project-tools",
"eamodio.gitlens",
"christian-kohler.path-intellisense"
]
}
44 changes: 44 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

version: '2.4'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
devbox:
image: mcr.microsoft.com/dotnet/core/sdk:3.1.300
# You may want to add a non-root user to your Dockerfile and uncomment the line below
# to cause all processes to run as this user. Once present, you can also simply
# use the "remoteUser" property in devcontainer.json if you just want VS Code and
# its sub-processes (terminals, tasks, debugging) to execute as the user. On Linux,
# you may need to ensure the UID and GID of the container user you create matches your
# local user. See https://aka.ms/vscode-remote/containers/non-root for details.
# user: vscode

# Uncomment if you want to add a different Dockerfile in the .devcontainer folder
# build:
# context: .
# dockerfile: Dockerfile

# Uncomment if you want to expose any additional ports. The snippet below exposes port 3000.
ports:
- 5001:5001
- 5002:5002

volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/workspace

# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker-compose for details.
# - /var/run/docker.sock:/var/run/docker.sock

# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
# cap_add:
# - SYS_PTRACE
# security_opt:
# - seccomp:unconfined

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"

25 changes: 4 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates
*.lock.json
.vs

src/Portal/dist
src/Portal/.tmp
src/Portal/bin
src/Portal/obj
src/Portal.VsoPlugin/bin
src/Portal.VsoPlugin/obj
node_modules
src/Portal/wwwroot/lib
Debug
Views
data
test_data
*.user
bin
obj
.vs
.codecov
coverage.*.xml
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<PropertyGroup>
<SkipCodeCoverageReport Condition="$(SkipCodeCoverageReport) == ''">false</SkipCodeCoverageReport>
<CoverletOutputFormat>cobertura,opencover</CoverletOutputFormat>
<Include>[*.ODataApi]*,[*.ODataApi.*]*</Include> <!-- [Assembly-Filter]Type-Filter -->
<CollectCoverage>true</CollectCoverage>
<ThresholdType>line</ThresholdType>
<ThresholdStat>total</ThresholdStat>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<PackageReference Include="ReportGenerator" Version="4.6.1" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Target Name="GenerateCoverageReport" AfterTargets="GenerateCoverageResult" Condition="!$(SkipCodeCoverageReport)">
<ItemGroup>
<CoverageFiles Include="coverage.cobertura.xml" />
</ItemGroup>
<ReportGenerator ReportFiles="@(CoverageFiles)" TargetDirectory="../../.codecov" ReportTypes="Html" />
</Target>
</Project>
30 changes: 30 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
assembly-versioning-scheme: Major
mode: ContinuousDeployment
next-version: 3.0.0
increment: Patch
legacy-semver-padding: 1
build-metadata-padding: 1
commits-since-version-source-padding: 1
continuous-delivery-fallback-tag: 'ci'
branches:
master:
regex: master
mode: ContinuousDeployment
tag: ''
increment: inherit
prevent-increment-of-merged-branch-version: true
tag-number-pattern: '[/-](?<number>\d+)[-/]'
pull-request:
regex: (pull|pull\-requests|pr)[/-]
mode: ContinuousDeployment
tag: "dev"
increment: Patch
tag-number-pattern: '[/-](?<number>\d+)[-/]'
develop:
regex: (!master)?
mode: ContinuousDeployment
tag: useBranchName
increment: Patch
ignore:
sha: []
merge-message-formats: {}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Mocoding Stack - OData API

[![Nuget](https://img.shields.io/nuget/vpre/Mocoding.AspNetCore.ODataApi)](https://www.nuget.org/packages/Mocoding.AspNetCore.ODataApi)
[![Build Status][azure-pipelines]][azure-pipelines-url]
[![Coverage][sonar-coverage]][sonar-url]
![Nuget Downloads](https://img.shields.io/nuget/dt/Mocoding.AspNetCore.ODataApi)


[azure-pipelines]: https://dev.azure.com/mocoding/GitHub/_apis/build/status/mocoding-software.odata-api?branchName=master
[azure-pipelines-url]: https://dev.azure.com/mocoding/GitHub/_build/latest?definitionId=115&branchName=master

[sonar-url]: https://sonarcloud.io/dashboard?id=mocoding-software_odata-api

[sonar-coverage]: https://sonarcloud.io/api/project_badges/measure?project=mocoding-software_odata-api&metric=coverage
2 changes: 1 addition & 1 deletion _stylecop/StyleCop.ruleset → StyleCop.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1649" Action="None" />
<Rule Id="SA1652" Action="None" />
<Rule Id="SA1652" Action="None" />
<Rule Id="IDE1006" Action="None" />
</Rules>
</RuleSet>
1 change: 1 addition & 0 deletions examples/WebApp.EF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static void Main(string[] args)

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://localhost:5002")
.UseStartup<Startup>();
}
}
Loading