Skip to content

Commit c8c89ed

Browse files
committed
Update README
1 parent 2b9a89d commit c8c89ed

File tree

1 file changed

+30
-82
lines changed

1 file changed

+30
-82
lines changed

README.md

Lines changed: 30 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
# Codecov C# Example
1+
# [Codecov](https://codecov.io) C# Example
22

3-
| [https://codecov.io](https://codecov.io/) | [@codecov](https://twitter.com/codecov) | [hello@codecov.io](mailto:hello@codecov.io) |
4-
| ----------------------- | ------------- | --------------------- |
5-
6-
[![AppVeyor](https://img.shields.io/appveyor/ci/stevepeak/example-csharp.svg)](https://ci.appveyor.com/project/stevepeak/example-csharp/branch/master)
73
[![codecov](https://codecov.io/gh/codecov/example-csharp/branch/master/graph/badge.svg)](https://codecov.io/gh/codecov/example-csharp)
4+
[![AppVeyor](https://img.shields.io/appveyor/ci/stevepeak/example-csharp.svg)](https://ci.appveyor.com/project/stevepeak/example-csharp/branch/master)
85

9-
## Solution
6+
## Guide
7+
### AppVeyor Setup
8+
Add to your `appveyor.yml` file.
9+
```yml
10+
image: Visual Studio 2015
1011

11-
Start by restoring the nuget packages and building the solution.
12+
before_build:
13+
- nuget restore
14+
- choco install opencover.portable
15+
- choco install codecov
1216

13-
## Generate the Coverage File
17+
build:
18+
project: CodecovProject.sln
19+
verbosity: minimal
1420

21+
test_script:
22+
- OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:".\MyUnitTests\bin\Debug\MyUnitTests.dll -noshadow" -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml"
23+
- codecov -f "MyProject_coverage.xml
24+
```
25+
### Producing Coverage Reports
1526
Coverage is generated using [OpenCover](https://github.com/OpenCover/opencover). You can obtain it from [NuGet](https://www.nuget.org/packages/opencover) or [Chocolatey](https://chocolatey.org/packages/opencover.portable). If we run the following command in PowerShell to install OpenCover via Chocolatey,
1627
1728
```powershell
@@ -22,9 +33,9 @@ the OpenCover commandline will become available.
2233

2334
Generation of coverage report is slighly different depending on the .NET platform of your test projects.
2435

25-
### .NET Framework project
36+
#### .NET Framework project
2637

27-
#### xUnit
38+
##### xUnit
2839

2940
First install the xUnit console runner via [Nuget](https://www.nuget.org/packages/xunit.runner.console/2.3.0-beta1-build3642) or [Chocolatey](https://chocolatey.org/packages/XUnit). If we run the following in PowerShell to install xUnit via Chocolatey
3041

@@ -40,7 +51,7 @@ OpenCover.Console.exe -register:user -target:"xunit.console.x86.exe" -targetargs
4051

4152
Then a coverage report will be generated.
4253

43-
#### MSTest
54+
##### MSTest
4455

4556
Execute the following in your solution's root,
4657

@@ -51,7 +62,7 @@ OpenCover.Console.exe -register:user -target:"C:\Program Files (x86)\Microsoft V
5162
where you may need to change the `-target` flag to point to the correct version of MSTest.
5263

5364

54-
### .NET Core project
65+
#### .NET Core project
5566

5667
If you don't yet have .NET Core SDK installed, install it
5768

@@ -73,34 +84,7 @@ OpenCover.Console.exe -register:user -target:"C:/Program Files/dotnet/dotnet.exe
7384

7485
where `-oldstyle` switch is necessary, because .NET Core uses `System.Private.CoreLib` instead of `mscorlib` and thus `OpenCover` can't use `mscorlib` for code instrumentation. You may also need to change the location of `dotnet.exe` to depending on the installed location.
7586

76-
## Uploading Report
77-
78-
Many options exist for uploading reports to Codecov. Three commonly used uploaders for .NET are
79-
80-
1. [Codecov-exe](https://github.com/codecov/codecov-exe) (C# source code)
81-
2. [Bash](https://github.com/codecov/codecov-bash)
82-
3. [Python](https://github.com/codecov/codecov-python)
83-
84-
For OS X and Linux builds, the recommended uploader is bash. For windows builds, all three uploaders work, but Codecov-exe does not require any dependencies. For example, the bash uploader and python uploader would require bash or python to be installed. This may or may not be an option.
85-
86-
### Codecov-exe
87-
88-
First install Codecov-exe via [Nuget](https://www.nuget.org/packages/Codecov/) or [Chocolatey](https://chocolatey.org/packages/codecov). If we run the following in PowerShell to install it via Chocolatey
89-
90-
```powershell
91-
choco install codecov
92-
```
93-
94-
and then run the following in PowerShell
95-
96-
```
97-
.\codecov -f "MyProject_coverage.xml" -t <your upload token>
98-
```
99-
100-
the report will be uploaded.
101-
10287
### Bash
103-
10488
In bash run the following to upload the report
10589

10690
```bash
@@ -109,21 +93,6 @@ chmod +x codecov
10993
./codecov -f "MyProject_coverage.xml" -t <your upload token>
11094
```
11195

112-
### Python
113-
114-
First installed python (if you don't have it already). A simple way to install python is [Chocolatey](https://chocolatey.org/packages/python)
115-
116-
```powershell
117-
choco install python
118-
```
119-
120-
Next run the following in PowerShell
121-
122-
```
123-
pip install codecov
124-
.\codecov -f "MyProject_coverage.xml" -t <your upload token>
125-
```
126-
12796
### Continous Integration
12897

12998
The previous examples assumed local development. More commonly, you'll use a CI service like [AppVeyor](https://www.appveyor.com/) or [TeamCity](https://www.jetbrains.com/teamcity/). For TeamCity builds please see the [documentation](https://github.com/codecov/codecov-exe#teamcity). For AppVeyor builds using xUnit, your yaml file would look something like
@@ -166,32 +135,11 @@ test_script:
166135
- .\packages\<ADD PATH>\codecov.exe -f "MyProject_coverage.xml"
167136
```
168137
169-
#### Python
170-
171-
```yaml
172-
image: Visual Studio 2015
173-
174-
before_build:
175-
- nuget restore
176-
- choco install opencover.portable
177-
178-
build:
179-
project: CodecovProject.sln
180-
verbosity: minimal
181-
182-
test_script:
183-
- OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:".\MyUnitTests\bin\Debug\MyUnitTests.dll -noshadow" -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml"
184-
- "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%"
185-
- pip install codecov
186-
- codecov -f "MyProject_coverage.xml"
187-
```
188-
189-
## Cake.Codecov
190-
191-
If you use [Cake](http://cakebuild.net/) (C# Make) for your build automation, there is a [Cake.Codecov](http://cakebuild.net/dsl/codecov/) addin available. Cake also has built in support for [OpenCover](http://cakebuild.net/dsl/opencover/). It makes using OpenCover and Codecov-exe really easy!
192-
193-
## Sample Project
194-
195-
An example C# project using AppVeyor, xUnit, OpenCover, and Codecov-exe is [DotNetAnalyzers/StyleCopAnalyzers](https://github.com/DotNetAnalyzers/StyleCopAnalyzers).
138+
## Caveats
139+
### Private Repo
140+
Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI, GitHub Actions, or AppVeyor. Find your repository token at Codecov and provide via appending `-t <your upload token>` to you where you upload reports e.g. `.\codecov -f "MyProject_coverage.xml" -t <your upload token>`
196141

197-
We are happy to help if you have any questions. Please contact email our Support at [support@codecov.io](mailto:support@codecov.io)
142+
## Links
143+
- [Community Boards](https://community.codecov.io)
144+
- [Support](https://codecov.io/support)
145+
- [Documentation](https://docs.codecov.io)

0 commit comments

Comments
 (0)