.NET Core local tools
( Video at https://youtu.be/iHLRBxi4S7c )
.NET Core has the concept of “local tools” – that means, tools for a solution / project. That is different from “global tools” by the fact that you can have it registered for the solution in a \.config\dotnet-tools.json file. You can read about those at https://docs.microsoft.com/en-us/dotnet/core/tools/local-tools-how-to-use
But I want to show you my local tools. First , the json:
{
“version”: 1,
“isRoot”: true,
“tools”: {
“dotnet-property”: {
“version”: “1.0.0.11”,
“commands”: [
“dotnet-property”
]
},
“powershell”: {
“version”: “7.0.0”,
“commands”: [
“pwsh”
]
},
“xunit-cli”: {
“version”: “0.1.3”,
“commands”: [
“xunit”
]
},
“coverlet.console”: {
“version”: “1.7.0”,
“commands”: [
“coverlet”
]
},
“dotnet-reportgenerator-globaltool”: {
“version”: “4.5.0”,
“commands”: [
“reportgenerator”
]
},
“dotnet-aop”: {
“version”: “2020.2.17.1904”,
“commands”: [
“dotnet-aop”
]
},
“loxsmoke.mddox”: {
“version”: “0.5.1”,
“commands”: [
“mddox”
]
},
“dotnet-project-licenses”: {
“version”: “1.1.1”,
“commands”: [
“dotnet-project-licenses”
]
},
“dotnetthx”: {
“version”: “0.2.0”,
“commands”: [
“dotnet-thx”
]
},
“dotnet-depends”: {
“version”: “0.4.0”,
“commands”: [
“dotnet-depends”
]
},
“dotnet-outdated”: {
“version”: “2.10.0”,
“commands”: [
“dotnet-outdated”
]
}
}
}
Now, how I use for code coverage:
dotnet tool restore –add-source https://myget.org/F/natemcmaster/api/v3/index.json
pwsh ./setVersion.ps1
dotnet coverlet bin\$(buildConfiguration)\netcoreapp3.1\CLITests.dll –target “dotnet” –targetargs “test –no-build –configuration $(buildConfiguration)” –exclude ‘[*Test*]*’ –format opencover –output $(Build.ArtifactStagingDirectory)\testResults\coverlet.xml
dotnet reportgenerator “-reports:$(Build.ArtifactStagingDirectory)\testResults\coverlet.xml” “-targetdir:$(Build.ArtifactStagingDirectory)\testResults” “-reporttypes:Cobertura;HtmlSummary;Badges;HtmlInline_AzurePipelines”
In this way I can have set version and running tests and see code coverage in Azure Devops: https://dev.azure.com/ignatandrei0674/WebAPI2CLI/_build?definitionId=7&_a=summary
( also, for code coverage, see video at https://youtu.be/JvahoA0WWms )
You can find also a list of tools here: https://github.com/natemcmaster/dotnet-tools
Leave a Reply