Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.sonarqube/
*.swp
*.*~
project.lock.json
Expand Down Expand Up @@ -34,4 +35,4 @@ msbuild.wrn
# Rider
.idea/
.fake
.ionide
.ionide
53 changes: 49 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,58 @@ function Exec

if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }

exec { & dotnet restore }

$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)

exec { & dotnet build }
#
# install Sonar Scanner (from SonarQube)
#
exec { & dotnet tool install --global dotnet-sonarscanner }

exec { & dotnet restore }

$sonarProjectKey = "skarpdev_dotnet-version-cli"
$sonarHostUrl = "https://sonarcloud.io"
$openCoveragePaths = "$Env:APPVEYOR_BUILD_FOLDER/test/coverage.netcoreapp3.1.opencover.xml"
$trxCoveragePahts = "$Env:APPVEYOR_BUILD_FOLDER/test/TestResults/*.trx"

# initialize Sonar Scanner
# If the environment variable APPVEYOR_PULL_REQUEST_NUMBER is not present, then this is not a pull request
if(-not $env:APPVEYOR_PULL_REQUEST_NUMBER) {
exec {
& dotnet sonarscanner begin `
/k:$sonarProjectKey `
/o:skarp `
/v:$revision `
/d:sonar.host.url=$sonarHostUrl `
/d:sonar.cs.opencover.reportsPaths=$openCoveragePaths `
/d:sonar.cs.vstest.reportsPaths=$trxCoveragePahts `
/d:sonar.coverage.exclusions="**Test*.cs" `
/d:sonar.login="$Env:SONARCLOUD_TOKEN"
}
} else {
exec {
& dotnet sonarscanner begin `
/k:$sonarProjectKey `
/o:skarp `
/v:$revision `
/d:sonar.host.url=$sonarHostUrl `
/d:sonar.cs.opencover.reportsPaths=$openCoveragePaths `
/d:sonar.cs.vstest.reportsPaths=$trxCoveragePahts `
/d:sonar.coverage.exclusions="**Test*.cs" `
/d:sonar.login="$Env:SONARCLOUD_TOKEN" `
/d:sonar.pullrequest.branch=$Env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH `
/d:sonar.pullrequest.base=$Env:APPVEYOR_REPO_BRANCH `
/d:sonar.pullrequest.key=$Env:APPVEYOR_PULL_REQUEST_NUMBER
}
}

exec { & dotnet build -c Release }

exec { & dotnet test .\test\dotnet-version-test.csproj -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger trx }

exec { & dotnet test .\test\dotnet-version-test.csproj -c Release }
# trigger Sonar Scanner analysis
exec { & dotnet sonarscanner end /d:sonar.login="$Env:SONARCLOUD_TOKEN" }

# pack up everything
exec { & dotnet pack .\src\dotnet-version.csproj -c Release -o ..\artifacts --include-source }
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[![Build status](https://ci.appveyor.com/api/projects/status/r50rbldhoil6pqk6/branch/master?svg=true)](https://ci.appveyor.com/project/nover/dotnet-version-cli/branch/master)
[![nuget version][nuget-image]][nuget-url]
[![Sonar Quality][sonarqualitylogo]][sonarqubelink]
[![Code coverage][sonarcoveragelogo]][sonarqubelink]
[![Sonar vulnerabilities][sonarvulnerabilitieslogo]][sonarqubelink]
[![Sonar bugs][sonarbugslogo]][sonarqubelink]
[![Sonar code smells][sonarcodesmellslogo]][sonarqubelink]

# dotnet-version-cli

Expand Down Expand Up @@ -129,4 +134,10 @@ dotnet version "1.0.$revCount"
[1]: https://docs.npmjs.com/cli/version
[nuget-image]: https://img.shields.io/nuget/v/dotnet-version-cli.svg
[nuget-url]: https://www.nuget.org/packages/dotnet-version-cli
[semver2]: https://semver.org/spec/v2.0.0.html
[semver2]: https://semver.org/spec/v2.0.0.html
[sonarqubelink]: https://sonarcloud.io/dashboard?id=skarpdev_dotnet-version-cli
[sonarqualitylogo]: https://sonarcloud.io/api/project_badges/measure?project=skarpdev_dotnet-version-cli&metric=alert_status
[sonarcoveragelogo]: https://sonarcloud.io/api/project_badges/measure?project=skarpdev_dotnet-version-cli&metric=coverage
[sonarvulnerabilitieslogo]: https://sonarcloud.io/api/project_badges/measure?project=skarpdev_dotnet-version-cli&metric=vulnerabilities
[sonarbugslogo]: https://sonarcloud.io/api/project_badges/measure?project=skarpdev_dotnet-version-cli&metric=bugs
[sonarcodesmellslogo]: https://sonarcloud.io/api/project_badges/measure?project=skarpdev_dotnet-version-cli&metric=code_smells
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: '{build}'
image: Visual Studio 2019
environment:
SONARCLOUD_TOKEN:
secure: zP3yL8OgEY/gjfooti1esakQ0qHOwPl0GOoGugNS+61PxWOphHIndkOP/G3Glq96
pull_requests:
do_not_increment_build_number: true
branches:
Expand Down
1 change: 1 addition & 0 deletions src/dotnet-version.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<RepositoryUrl>https://github.com/skarpdev/dotnet-version-cli/</RepositoryUrl>
<PackageId>dotnet-version-cli</PackageId>
<Company>SKARP ApS</Company>
<ProjectGuid>1ae7aff7-e333-4205-aa1b-b8a8a79b4a87</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
Expand Down
9 changes: 9 additions & 0 deletions test/dotnet-version-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<RootNamespace>Skarp.Version.Cli.Test</RootNamespace>
<ProjectGuid>fb420acf-9e12-42b6-b724-1eee9cbf251e</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="1.2.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FakeItEasy" Version="4.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="xunit" Version="2.4.0" />
Expand Down