|
| 1 | +# .NET |
| 2 | + |
| 3 | +Endless Lifecycle Support (ELS) for .NET from TuxCare delivers security fixes for .NET library, framework, and tool packages, distributed through NuGet packages. This allows you to continue running your .NET applications without vulnerability concerns, even after official support has ended. |
| 4 | + |
| 5 | +NuGet is the standard package manager for .NET, used to deliver the reusable components applications depend on. ELS applies fixes at the package level, so your applications receive security updates without requiring changes to your own code. |
| 6 | + |
| 7 | +## Supported Versions |
| 8 | + |
| 9 | +**Supported .NET versions**: 6, 8, 10 |
| 10 | + |
| 11 | +Other versions upon request. |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +* .NET SDK installed. A TuxCare-supported .NET SDK build is also [available](/els-for-runtimes/dotnet/). |
| 16 | +* Access to the TuxCare .NET NuGet repository (credentials required). |
| 17 | +You need a username and password to use the TuxCare ELS for .NET repository. Anonymous access is disabled. To receive the credentials, please contact [sales@tuxcare.com](mailto:sales@tuxcare.com). |
| 18 | + |
| 19 | +## Adding the Repository |
| 20 | + |
| 21 | +This section describes how to add the TuxCare ELS for .NET repository as a package source. |
| 22 | + |
| 23 | +### Adding the NuGet Source via CLI |
| 24 | + |
| 25 | +Add the TuxCare NuGet repository as a package source using the `dotnet` CLI: |
| 26 | + |
| 27 | +<CodeWithCopy> |
| 28 | + |
| 29 | +```text |
| 30 | +dotnet nuget add source "https://nexus.repo.tuxcare.com/repository/els_dotnet/index.json" ` |
| 31 | + --name TuxCare ` |
| 32 | + --username <USERNAME> ` |
| 33 | + --password <PASSWORD> |
| 34 | +``` |
| 35 | + |
| 36 | +</CodeWithCopy> |
| 37 | + |
| 38 | +**Replace `<USERNAME>` and `<PASSWORD>` with the credentials provided by sales.** |
| 39 | + |
| 40 | +### Adding the NuGet Source via nuget.config |
| 41 | + |
| 42 | +As an alternative to the CLI, you can configure NuGet package sources using a `nuget.config` file. This approach is useful for sharing configuration across a team or for version-controlled source settings. |
| 43 | + |
| 44 | +#### Understanding NuGet Configuration Hierarchy |
| 45 | + |
| 46 | +NuGet configuration follows a hierarchy (from highest to lowest priority): |
| 47 | + |
| 48 | +1. **Project-level**: `nuget.config` in your project folder |
| 49 | +2. **Solution-level**: `nuget.config` in the solution folder (parent directory) |
| 50 | +3. **User-level**: `~/.nuget/NuGet/NuGet.Config` |
| 51 | +4. **Machine-level**: `/etc/nuget/NuGet/NuGet.Config` |
| 52 | + |
| 53 | +Settings in higher-priority files override those in lower-priority files. |
| 54 | + |
| 55 | +#### Creating a nuget.config File |
| 56 | + |
| 57 | +Create a `nuget.config` file in your project or solution directory: |
| 58 | + |
| 59 | +<CodeWithCopy> |
| 60 | + |
| 61 | +``` |
| 62 | +<?xml version="1.0" encoding="utf-8"?> |
| 63 | +<configuration> |
| 64 | + <packageSources> |
| 65 | + <!--To inherit the global NuGet package sources remove the <clear/> line below --> |
| 66 | + <clear /> |
| 67 | + <add key="nuget" value="https://api.nuget.org/v3/index.json" /> |
| 68 | + <add key="TuxCare" value="https://nexus.repo.tuxcare.com/repository/els_dotnet/index.json" /> |
| 69 | + </packageSources> |
| 70 | +</configuration> |
| 71 | +``` |
| 72 | + |
| 73 | +</CodeWithCopy> |
| 74 | + |
| 75 | +In this configuration: |
| 76 | + |
| 77 | +* The `<clear />` element removes inherited package sources, giving you full control. |
| 78 | +* The `nuget` source points to the official NuGet.org repository. |
| 79 | +* The `TuxCare` source points to the TuxCare ELS repository. |
| 80 | + |
| 81 | +#### Adding Credentials for nuget.config |
| 82 | + |
| 83 | +If your `nuget.config` requires authentication, you can add credentials using the CLI or by adding a `<packageSourceCredentials>` section to your `nuget.config`: |
| 84 | + |
| 85 | +<CodeTabs :tabs="[ |
| 86 | + { title: 'CLI', content: 'dotnet nuget update source TuxCare --username <USERNAME> --password <PASSWORD>' }, |
| 87 | + { title: 'nuget.config', content: credsConfig } |
| 88 | +]" /> |
| 89 | + |
| 90 | +:::warning |
| 91 | +Avoid committing credentials to version control. Consider using environment variables or a separate local configuration file for sensitive information. |
| 92 | +::: |
| 93 | + |
| 94 | +### Verifying the Source |
| 95 | + |
| 96 | +To verify that the source was added successfully, list all configured NuGet sources: |
| 97 | + |
| 98 | +<CodeWithCopy> |
| 99 | + |
| 100 | +```text |
| 101 | +dotnet nuget list source |
| 102 | +``` |
| 103 | + |
| 104 | +</CodeWithCopy> |
| 105 | + |
| 106 | +Example output: |
| 107 | + |
| 108 | +```text |
| 109 | +Registered Sources: |
| 110 | + 1. nuget.org [Enabled] |
| 111 | + https://api.nuget.org/v3/index.json |
| 112 | + 2. TuxCare [Enabled] |
| 113 | + https://nexus.repo.tuxcare.com/repository/els_dotnet/index.json |
| 114 | +``` |
| 115 | + |
| 116 | +## Working with Packages |
| 117 | + |
| 118 | +This section explains how to install and use packages from the TuxCare repository. |
| 119 | + |
| 120 | +### Navigating to Your Project |
| 121 | + |
| 122 | +Ensure you are in a directory containing a valid .NET project. The folder must contain a `.csproj` file. |
| 123 | + |
| 124 | +<CodeWithCopy> |
| 125 | + |
| 126 | +```text |
| 127 | +dir *.csproj |
| 128 | +``` |
| 129 | + |
| 130 | +</CodeWithCopy> |
| 131 | + |
| 132 | +If a `.csproj` file is found, you can proceed with package installation. If not, create a new project: |
| 133 | + |
| 134 | +<CodeWithCopy> |
| 135 | + |
| 136 | +```text |
| 137 | +dotnet new console -o MyProject |
| 138 | +cd MyProject |
| 139 | +``` |
| 140 | + |
| 141 | +</CodeWithCopy> |
| 142 | + |
| 143 | +### Installing Packages |
| 144 | + |
| 145 | +Install a package from the TuxCare repository using the `dotnet add package` command: |
| 146 | + |
| 147 | +<CodeWithCopy> |
| 148 | + |
| 149 | +```text |
| 150 | +dotnet add package <PACKAGE_NAME> |
| 151 | +``` |
| 152 | + |
| 153 | +</CodeWithCopy> |
| 154 | + |
| 155 | +To install a specific version: |
| 156 | + |
| 157 | +<CodeWithCopy> |
| 158 | + |
| 159 | +```text |
| 160 | +dotnet add package <PACKAGE_NAME> --version <VERSION> |
| 161 | +``` |
| 162 | + |
| 163 | +</CodeWithCopy> |
| 164 | + |
| 165 | +For example: |
| 166 | + |
| 167 | +<CodeWithCopy> |
| 168 | + |
| 169 | +```text |
| 170 | +dotnet add package Newtonsoft.Json --version 12.0.4-tuxcare-els |
| 171 | +``` |
| 172 | + |
| 173 | +</CodeWithCopy> |
| 174 | + |
| 175 | +**You can find available package versions in your TuxCare account on [Nexus](https://nexus.repo.tuxcare.com/repository/els_dotnet/) (anonymous access is restricted).** |
| 176 | + |
| 177 | +### Using Package Source Mapping |
| 178 | + |
| 179 | +If you use a `nuget.config` file, you can add package source mapping to route specific packages to the TuxCare feed. This ensures certain packages are always fetched from TuxCare while others come from NuGet.org. |
| 180 | + |
| 181 | +Add a `<packageSourceMapping>` section to your `nuget.config`, for example, Newtonsoft.Json: |
| 182 | + |
| 183 | +<CodeWithCopy> |
| 184 | + |
| 185 | +``` |
| 186 | +<packageSourceMapping> |
| 187 | + <!-- Allow nuget.org to serve any package --> |
| 188 | + <packageSource key="nuget"> |
| 189 | + <package pattern="*" /> |
| 190 | + </packageSource> |
| 191 | +
|
| 192 | + <!-- Route specific packages to TuxCare feed --> |
| 193 | + <packageSource key="TuxCare"> |
| 194 | + <package pattern="Newtonsoft.*" /> |
| 195 | + </packageSource> |
| 196 | +</packageSourceMapping> |
| 197 | +``` |
| 198 | + |
| 199 | +</CodeWithCopy> |
| 200 | + |
| 201 | +**You can find available package versions in your TuxCare account on [Nexus](https://nexus.repo.tuxcare.com/repository/els_dotnet/) (anonymous access is restricted).** |
| 202 | + |
| 203 | +### Building the Project |
| 204 | + |
| 205 | +After installing packages, verify that everything works correctly by building the project: |
| 206 | + |
| 207 | +<CodeWithCopy> |
| 208 | + |
| 209 | +```text |
| 210 | +dotnet build |
| 211 | +``` |
| 212 | + |
| 213 | +</CodeWithCopy> |
| 214 | + |
| 215 | +If the build completes successfully, the TuxCare package is successfully integrated into your project. Check the output folder to confirm that the package DLL (e.g., `Newtonsoft.Json.dll`) was downloaded from the TuxCare repository. |
| 216 | + |
| 217 | +### Upgrading Packages |
| 218 | + |
| 219 | +To upgrade to a newer TuxCare release, update the package in your project: |
| 220 | + |
| 221 | +<CodeWithCopy> |
| 222 | + |
| 223 | +```text |
| 224 | +dotnet add package <PACKAGE_NAME> --version <NEW_VERSION> |
| 225 | +``` |
| 226 | + |
| 227 | +</CodeWithCopy> |
| 228 | + |
| 229 | +Then rebuild the project to verify the upgrade: |
| 230 | + |
| 231 | +<CodeWithCopy> |
| 232 | + |
| 233 | +```text |
| 234 | +dotnet build |
| 235 | +``` |
| 236 | + |
| 237 | +</CodeWithCopy> |
| 238 | + |
| 239 | +## Managing NuGet Sources |
| 240 | + |
| 241 | +This section covers common tasks for managing the TuxCare NuGet source. |
| 242 | + |
| 243 | +### Removing a Source |
| 244 | + |
| 245 | +If you need to remove the TuxCare source: |
| 246 | + |
| 247 | +<CodeWithCopy> |
| 248 | + |
| 249 | +```text |
| 250 | +dotnet nuget remove source TuxCare |
| 251 | +``` |
| 252 | + |
| 253 | +</CodeWithCopy> |
| 254 | + |
| 255 | +### Updating Source Credentials |
| 256 | + |
| 257 | +To update the credentials for an existing source, remove and re-add the source: |
| 258 | + |
| 259 | +<CodeWithCopy> |
| 260 | + |
| 261 | +```text |
| 262 | +dotnet nuget remove source TuxCare |
| 263 | +dotnet nuget add source "https://nexus.repo.tuxcare.com/repository/els_dotnet/index.json" ` |
| 264 | + --name TuxCare ` |
| 265 | + --username <NEW_USERNAME> ` |
| 266 | + --password <NEW_PASSWORD> |
| 267 | +``` |
| 268 | + |
| 269 | +</CodeWithCopy> |
| 270 | + |
| 271 | +<script setup> |
| 272 | + |
| 273 | +const credsConfig = |
| 274 | +`<packageSourceCredentials> |
| 275 | + <TuxCareProd> |
| 276 | + <add key="Username" value="username" /> |
| 277 | + <add key="Password" value="passwordHash" /> |
| 278 | + </TuxCareProd> |
| 279 | +</packageSourceCredentials>` |
| 280 | +</script> |
0 commit comments