1. Create an issue describing the bug or enhancement you want to propose (select the right issue template).
2. Make sure the issue has been reviewed and agreed.
3. Create a Merge Request, from your **own** fork (see [forking workflow](https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html) documentation).
3. Create a Merge Request, from your **own** fork (see [forking workflow](https://docs.gitlab.com/user/project/repository/forking_workflow/) documentation).
Don't hesitate to mark your MR as `Draft` as long as you think it's not ready to be reviewed.
| `image` / `DOTNET_IMAGE` | The Docker image used to run the .NET SDK<br/>:warning: **set the version required by your project** | `mcr.microsoft.com/dotnet/sdk:latest` |
| `image` / `DOTNET_IMAGE` | The Docker image used to run the .NET SDK<br/>:warning: **set the version required by your project** | `mcr.microsoft.com/dotnet/sdk:latest`<br/>[](https://to-be-continuous.gitlab.io/doc/secu/trivy-DOTNET_IMAGE) |
| `project-dir` / `DOTNET_PROJECT_DIR` | The folder where solution (*.sln) or project (*.csproj) file is located | `.` _(root project dir)_ |
| `nuget-sources` / `DOTNET_NUGET_SOURCES` | Space separated list of .Net NuGet package [sources](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-add-source)(formatted as `somename:https://some.nuget.registry/some/repo/index.json anothername:https://another.nuget.registry/another/repo/index.json`) | _none_ |
## Jobs
@@ -56,81 +58,65 @@ It uses the following variable:
| Input / Variable | Description | Default value |
| `build-args` / `DOTNET_BUILD_ARGS` | Arguments used by the build job | `build --with-default-args` |
| `build-args` / `DOTNET_BUILD_ARGS` | Arguments used by the [build](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build) job | _none_ |
| `build-dir` / `DOTNET_BUILD_DIR` | The relative path to the folder where the built files are located | `bin/Debug` |
| `test-project-dir` / `DOTNET_TEST_PROJECT_DIR` | The folder where Unit tests (*.cproj) file is located | `.` _(root project dir)_ |
| `test-extra-args` / `DOTNET_TEST_EXTRA_ARGS` | Extra arguments used by the [test](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test?tabs=dotnet-test-with-vstest) job | _none_ |
| `test-enabled` / `DOTNET_TEST_ENABLED` | Set to `false` to disable tests execution | `true` |
### SonarQube analysis
#### Unit Tests and Code Coverage reports
If you're using the SonarQube template to analyse your DOTNET code, here are 2 sample `sonar-project.properties` files.
In order to implement the best GitLab and SonarQube integration, the .NET template requires your project to use some specific tools and plugins:
# set your source directories here (relative to the sonar-project.properties file)
sonar.sources=.
# exclude unwanted directories and files from being analysed
sonar.exclusions=output/**,**/*_test.dotnet
- Unit Tests report for [GitLab integration](https://docs.gitlab.com/ci/yaml/artifacts_reports/#artifactsreportsjunit) is generated with [JUnit Test Logger](https://github.com/spekt/junit.testlogger)
# set your tests directories here (relative to the sonar-project.properties file)
sonar.tests=.
sonar.test.inclusions=**/*_test.dotnet
:information_source: the `JunitXml.TestLogger` package shall be added to your test projects ([see nuget](https://www.nuget.org/packages/JUnitXml.TestLogger))
- Unit Tests report for [SonarQube integration](https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/test-coverage/test-execution-parameters/#sonarcsxunitreportspaths) is generated with [Xunit Test Logger](https://github.com/spekt/xunit.testlogger)
:information_source: the `XunitXml.TestLogger` package shall be added to your test projects ([see nuget](https://www.nuget.org/packages/XunitXml.TestLogger))
More info:
:warning: only required if you enabled [SonarQube analysis](#dotnet-sonar-job)
- Code Coverage is computed with [Coverlet](https://github.com/coverlet-coverage/coverlet):
*[dotnet language support](https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/test-coverage/dotnet-test-coverage/)
:information_source: the `coverlet.msbuild` package shall be added to your test projects ([see nuget](https://www.nuget.org/packages/coverlet.msbuild))
### `dotnet-lint` job
With those packages properly configured, the following reports are generated:
This job performs a [lint](link-to-the-tool) analysis of your code, mapped to the `build` stage.
| :lock: `SONAR_TOKEN` | SonarQube authentication [token](https://docs.sonarsource.com/sonarqube-server/latest/user-guide/managing-tokens/#using-a-token)(depends on your authentication method) | _none_ |
| `sonar-extra-args` / `DOTNET_SONAR_EXTRA_ARGS` | Extra arguments used by the [SonarScanner](https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/analysis-parameters/) | _none_ |
It uses the following variables:
More info:
| Input / Variable | Description | Default value |
"description":"The folder where solution (*.sln) or project (*.csproj) file is located",
"default":".",
"advanced":true
},
{
"name":"DOTNET_LINT_IMAGE",
"description":"The Docker image used to run the lint tool",
"default":"docker.io/dotnet-lint:latest"
"name":"DOTNET_BUILD_DIR",
"description":"The relative path to the folder where the built files are located",
"default":"bin/Debug",
"advanced":true
},
{
"name":"DOTNET_LINT_ARGS",
"description":"Lint [options and arguments](link-to-the-cli-options)",
"default":"--serevity=medium",
"name":"DOTNET_NUGET_SOURCES",
"description":"Space separated list of .Net NuGet package [sources](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-add-source) (formatted as `somename:https://some.nuget.registry/some/repo/index.json anothername:https://another.nuget.registry/another/repo/index.json`)",
"description":"Arguments used by the publish job",
"default":"publish --with-default-args",
"name":"SONAR_HOST_URL",
"description":"SonarQube server url",
"mandatory":true,
"advanced":true
},
{
"name":"DOTNET_PUBLISH_LOGIN",
"description":"Login to use to publish",
"secret":true
"name":"SONAR_PROJECT_KEY",
"description":"SonarQube Project Key",
"advanced":true
},
{
"name":"DOTNET_PUBLISH_PASSWORD",
"description":"Password to use to publish",
"name":"SONAR_TOKEN",
"description":"SonarQube authentication token (see https://docs.sonarsource.com/sonarqube-server/latest/user-guide/managing-tokens/) - depends on your authentication method",
"secret":true
},
{
"name":"DOTNET_SONAR_EXTRA_ARGS",
"description":"Extra arguments used by the [SonarScanner](https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/analysis-parameters/)",