dotnet.star¶
.NET: bump NuGet packages, target frameworks and the SDK pinned in global.json.
Edits are line-based, so comments and formatting in project files stay as they were. Central package management (Directory.Packages.props) is covered alongside individual projects.
load("@fleet//dotnet.star", "projects", "set_package", "set_target_framework", "sdk_version", "set_sdk_version")
| Function | What it does |
|---|---|
projects |
Lists the project files and shared MSBuild props files. |
set_package |
Sets a NuGet package's version wherever a project already references it. |
set_target_framework |
Sets the target framework of every project, such as net8.0. |
sdk_version |
Reads the .NET SDK version pinned in global.json. |
set_sdk_version |
Sets the .NET SDK version in a global.json that already pins one. |
projects¶
Lists the project files and shared MSBuild props files.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The sorted paths of every .csproj, .fsproj and .vbproj, and every Directory.Packages.props and Directory.Build.props, outside bin and obj directories.
Example
set_package¶
Sets a NuGet package's version wherever a project already references it.
A newer version already there is kept, so a campaign never lowers one.
Covers <PackageReference> and central <PackageVersion> entries,
with the version as a Version="..." attribute or a <Version> child
element. Package names match case-insensitively, as NuGet does.
References without a version (under central package management) are
left alone.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
name |
The package ID, such as Newtonsoft.Json. |
version |
The new version. |
Returns: The list of paths that changed.
Example
src/Api/Api.csproj
Used in: dotnet-8
set_target_framework¶
Sets the target framework of every project, such as net8.0.
Changes <TargetFramework>. A multi-targeting <TargetFrameworks>
list changes only when from_framework is given, and then only that
entry is replaced, so net6.0;net48 becomes net8.0;net48.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
framework |
The new target framework moniker. |
from_framework |
The moniker to replace; when set, other targets are left alone. |
Returns: The list of paths that changed.
Example
set_target_framework(repo, "net8.0", from_framework = "net6.0")
# returns ["src/Api/Api.csproj", "src/Lib/Lib.csproj"]
Used in: dotnet-8
sdk_version¶
Reads the .NET SDK version pinned in global.json.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The version, or None when the repo has no global.json or it pins no SDK.
Example
set_sdk_version¶
Sets the .NET SDK version in a global.json that already pins one.
A newer version already there is kept, so a campaign never lowers one.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
version |
The SDK version, such as 8.0.400. |
Returns: True when the file changed.
Example
Used in: dotnet-8