|
6 | 6 |
|
7 | 7 | ## Usage
|
8 | 8 |
|
9 |
| -Add the following import to your `csproj` or `Directory.Build.props`: |
10 |
| - |
11 |
| -```xml |
12 |
| -<?xml version="1.0" encoding="utf-8"?> |
13 |
| -<Project> |
14 |
| - <ItemGroup> |
15 |
| - <PackageReference Include="Messerli.CodeStyle" Version="1.2.0" PrivateAssets="all" /> |
16 |
| - </ItemGroup> |
17 |
| -</Project> |
| 9 | +### Without the CentralPackageVersions SDK |
| 10 | + |
| 11 | +Add the following package reference to your project or to your `Directory.Build.props`: |
| 12 | + |
| 13 | +```diff |
| 14 | + <?xml version="1.0" encoding="utf-8"?> |
| 15 | + <Project> |
| 16 | + <ItemGroup> |
| 17 | ++ <PackageReference Include="Messerli.CodeStyle" Version="1.2.1" PrivateAssets="all" /> |
| 18 | + </ItemGroup> |
| 19 | + </Project> |
| 20 | +``` |
| 21 | + |
| 22 | +### With the CentralPackageVersions SDK |
| 23 | + |
| 24 | +Add `Messerli.CodeStyle` to your `Packages.props`: |
| 25 | +```diff |
| 26 | + <?xml version="1.0" encoding="utf-8"?> |
| 27 | + <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 28 | + <ItemGroup Label="Build dependencies"> |
| 29 | ++ <PackageReference Update="Messerli.CodeStyle" Version="1.2.1" /> |
| 30 | + </ItemGroup> |
| 31 | + </Project> |
| 32 | +``` |
| 33 | + |
| 34 | +Add the following package reference to your project or to your `Directory.Build.props`: |
| 35 | +```diff |
| 36 | + <?xml version="1.0" encoding="utf-8"?> |
| 37 | + <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 38 | ++ <ItemGroup> |
| 39 | ++ <PackageReference Include="Messerli.CodeStyle" PrivateAssets="all" /> |
| 40 | ++ </ItemGroup> |
| 41 | + </Project> |
18 | 42 | ```
|
19 | 43 |
|
| 44 | +## Warnings as Errors |
20 | 45 |
|
| 46 | +Some analyzer rules, such as rules involving single line comments, are configured as warnings to facilitate development. |
| 47 | +To enforce these rules, enable `TreatWarningsAsErrors` for CI builds. |
| 48 | + |
| 49 | +```diff |
| 50 | +- dotnet build --no-restore |
| 51 | ++ dotnet build --no-restore /p:TreatWarningsAsErrors=true |
| 52 | +``` |
| 53 | + |
| 54 | +### Github Actions |
| 55 | +```diff |
| 56 | + jobs: |
| 57 | + build: |
| 58 | + steps: |
| 59 | + # ... |
| 60 | + - name: Build |
| 61 | +- run: dotnet build --no-restore |
| 62 | ++ run: dotnet build --no-restore /p:TreatWarningsAsErrors=true |
| 63 | + # ... |
| 64 | +``` |
| 65 | + |
| 66 | +### Azure Devops |
| 67 | +```diff |
| 68 | + steps: |
| 69 | + # ... |
| 70 | + - task: DotNetCoreCLI@2 |
| 71 | + displayName: Build |
| 72 | + inputs: |
| 73 | +- arguments: '--no-restore' |
| 74 | ++ arguments: '--no-restore /p:TreatWarningsAsErrors=true' |
| 75 | + # ... |
| 76 | +``` |
0 commit comments