Skip to content
Open
39 changes: 20 additions & 19 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3814,25 +3814,26 @@ This way Renovate can use GitHub's [Commit signing support for bots and other Gi

Table with options:

| Name | Description |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bundlerConservative` | Enable conservative mode for `bundler` (Ruby dependencies). This will only update the immediate dependency in the lockfile instead of all subdependencies. |
| `composerWithAll` | Run `composer update` with `--with-all-dependencies` flag instead of the default `--with-dependencies`. |
| `dotnetWorkloadRestore` | Run `dotnet workload restore` before `dotnet restore` commands. |
| `gomodMassage` | Enable massaging `replace` directives before calling `go` commands. |
| `gomodTidy` | Run `go mod tidy` after Go module updates. This is implicitly enabled for major module updates when `gomodUpdateImportPaths` is enabled. |
| `gomodTidy1.17` | Run `go mod tidy -compat=1.17` after Go module updates. |
| `gomodTidyE` | Run `go mod tidy -e` after Go module updates. |
| `gomodUpdateImportPaths` | Update source import paths on major module updates, using [mod](https://github.com/marwan-at-work/mod). |
| `gomodSkipVendor` | Never run `go mod vendor` after Go module updates. |
| `gomodVendor` | Always run `go mod vendor` after Go module updates even if vendor files aren't detected. |
| `helmUpdateSubChartArchives` | Update subchart archives in the `/charts` folder. |
| `kustomizeInflateHelmCharts` | Inflate updated helm charts referenced in the kustomization. |
| `npmDedupe` | Run `npm install` with `--prefer-dedupe` for npm >= 7 or `npm dedupe` after `package-lock.json` update for npm <= 6. |
| `npmInstallTwice` | Run `npm install` commands _twice_ to work around bugs where `npm` generates invalid lock files if run only once |
| `pnpmDedupe` | Run `pnpm dedupe --ignore-scripts` after `pnpm-lock.yaml` updates. |
| `yarnDedupeFewer` | Run `yarn-deduplicate --strategy fewer` after `yarn.lock` updates. |
| `yarnDedupeHighest` | Run `yarn-deduplicate --strategy highest` (`yarn dedupe --strategy highest` for Yarn >=2.2.0) after `yarn.lock` updates. |
| Name | Description |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bundlerConservative` | Enable conservative mode for `bundler` (Ruby dependencies). This will only update the immediate dependency in the lockfile instead of all subdependencies. |
| `composerWithAll` | Run `composer update` with `--with-all-dependencies` flag instead of the default `--with-dependencies`. |
| `dotnetEnableWindowsTargeting` | Run `dotnet restore` commands with `-p:EnableWindowsTargeting=true` set. |
| `dotnetWorkloadRestore` | Run `dotnet workload restore` before `dotnet restore` commands. |
| `gomodMassage` | Enable massaging `replace` directives before calling `go` commands. |
| `gomodTidy` | Run `go mod tidy` after Go module updates. This is implicitly enabled for major module updates when `gomodUpdateImportPaths` is enabled. |
| `gomodTidy1.17` | Run `go mod tidy -compat=1.17` after Go module updates. |
| `gomodTidyE` | Run `go mod tidy -e` after Go module updates. |
| `gomodUpdateImportPaths` | Update source import paths on major module updates, using [mod](https://github.com/marwan-at-work/mod). |
| `gomodSkipVendor` | Never run `go mod vendor` after Go module updates. |
| `gomodVendor` | Always run `go mod vendor` after Go module updates even if vendor files aren't detected. |
| `helmUpdateSubChartArchives` | Update subchart archives in the `/charts` folder. |
| `kustomizeInflateHelmCharts` | Inflate updated helm charts referenced in the kustomization. |
| `npmDedupe` | Run `npm install` with `--prefer-dedupe` for npm >= 7 or `npm dedupe` after `package-lock.json` update for npm <= 6. |
| `npmInstallTwice` | Run `npm install` commands _twice_ to work around bugs where `npm` generates invalid lock files if run only once |
| `pnpmDedupe` | Run `pnpm dedupe --ignore-scripts` after `pnpm-lock.yaml` updates. |
| `yarnDedupeFewer` | Run `yarn-deduplicate --strategy fewer` after `yarn.lock` updates. |
| `yarnDedupeHighest` | Run `yarn-deduplicate --strategy highest` (`yarn dedupe --strategy highest` for Yarn >=2.2.0) after `yarn.lock` updates. |

## postUpgradeTasks

Expand Down
1 change: 1 addition & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,7 @@ const options: RenovateOptions[] = [
allowedValues: [
'bundlerConservative',
'composerWithAll',
'dotnetEnableWindowsTargeting',
'dotnetWorkloadRestore',
'gomodMassage',
'gomodTidy',
Expand Down
43 changes: 43 additions & 0 deletions lib/modules/manager/nuget/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,49 @@ describe('modules/manager/nuget/artifacts', () => {
]);
});

it('properly appends additional commands options when requested', async () => {
const execSnapshots = mockExecAll();
fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json');
git.getFiles.mockResolvedValueOnce({
'packages.lock.json': 'Current packages.lock.json',
});
fs.getLocalFiles.mockResolvedValueOnce({
'packages.lock.json': 'New packages.lock.json',
});
expect(
await nuget.updateArtifacts({
packageFileName: 'project.csproj',
updatedDeps: [{ depName: 'dep' }],
newPackageFileContent: '{}',
config: {
...config,
postUpdateOptions: ['dotnetEnableWindowsTargeting'],
},
}),
).toEqual([
{
file: {
contents: 'New packages.lock.json',
path: 'packages.lock.json',
type: 'addition',
},
},
]);
expect(execSnapshots).toMatchObject([
{
cmd: 'dotnet restore project.csproj --force-evaluate --configfile /tmp/renovate/cache/__renovate-private-cache/nuget/nuget.config -p:EnableWindowsTargeting=true',
options: {
cwd: '/tmp/github/some/repo',
env: {
NUGET_PACKAGES:
'/tmp/renovate/cache/__renovate-private-cache/nuget/packages',
MSBUILDDISABLENODEREUSE: '1',
},
},
},
]);
});

it('runs workload restore and updates lock file', async () => {
const execSnapshots = mockExecAll();
fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json');
Expand Down
10 changes: 9 additions & 1 deletion lib/modules/manager/nuget/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ async function runDotnetRestore(
toolConstraints: [{ toolName: 'dotnet', constraint: dotnetVersion }],
};

// the first empty item results in adding a leading space once joined with other arguments from the array
const dotnetRestoreOpts = [''];
if (config.postUpdateOptions?.includes('dotnetEnableWindowsTargeting')) {
dotnetRestoreOpts.push('-p:EnableWindowsTargeting=true');
}

const cmds = [
...dependentPackageFileNames.map(
(fileName) =>
// it is essential that dotnetRestoreOpts are added directly after the previous arguments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it was added with an additional space, the only "problem" we'd see are that our tests would need to update as there'd be an additional space, right?

There's nothing the dotnet CLI will have issues with?

// as the leading space will be added dynamically
`dotnet restore ${quote(
fileName,
)} --force-evaluate --configfile ${quote(nugetConfigFile)}`,
)} --force-evaluate --configfile ${quote(nugetConfigFile)}${dotnetRestoreOpts.join(' ')}`,
),
];

Expand Down
13 changes: 13 additions & 0 deletions lib/modules/manager/nuget/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,16 @@ You can enable this behavior by adding `dotnetWorkloadRestore` to the `postUpdat
"postUpdateOptions": ["dotnetWorkloadRestore"]
}
```

### Windows targeting

In case you need to allow Windows targeting during package restore, e.g. adding the `-p:EnableWindowsTargeting=true` CLI argument to the
Sometimes package restore needs Windows targeting enabled.
Normally, you do this by adding `-p:EnableWindowsTargeting=true` to the `dotnet restore` command.
In Renovate, the same effect is achieved by adding `dotnetEnableWindowsTargeting` to `postUpdateOptions`.

```json
{
"postUpdateOptions": ["dotnetEnableWindowsTargeting"]
}
```