Skip to content

Commit 54c010c

Browse files
first-stormhfiguiere
authored andcommitted
dotnet: Add support for additional arguments in flatpak-dotnet-generator.py
1 parent 87c64a0 commit 54c010c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

dotnet/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,17 @@ If you want to change the directory name, run `flatpak-dotnet-generator.py` with
3232
- `--runtime` or `-r` The target [runtime](https://learn.microsoft.com/en-us/dotnet/core/rid-catalog#linux-rids) to restore packages for.
3333
- `--dotnet` or `-d` The target version of dotnet to use. (Defaults to latest LTS version)
3434
- `--freedesktop` or `-f` The target version of the freedesktop sdk to use. (Defaults to latest version)
35-
- `--destdir` The directory the generated sources file will save sources to `nuget-sources` by default.
35+
- `--destdir` The directory the generated sources file will save sources to `nuget-sources` by default.
36+
- `--dotnet-args` or `-a` Pass additional arguments to the `dotnet` command.
37+
38+
## Example
39+
40+
To pass multiple arguments to the `dotnet` command, use the `--dotnet-args` option:
41+
42+
```bash
43+
python3 flatpak-dotnet-generator.py my-output-sources.json my.input.Desktop.csproj --runtime linux-x64 --dotnet-args --no-cache --verbosity detailed
44+
```
45+
46+
In this example:
47+
- `--no-cache` and `--verbosity detailed` are additional arguments passed to the `dotnet` command.
48+
- You can add as many arguments as needed after `--dotnet-args`.

dotnet/flatpak-dotnet-generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ def main():
2929
parser.add_argument('--destdir',
3030
help='The directory the generated sources file will save sources to',
3131
default='nuget-sources')
32+
parser.add_argument('--dotnet-args', '-a', nargs=argparse.REMAINDER,
33+
help='Additional arguments to pass to the dotnet command')
3234
args = parser.parse_args()
3335

3436
sources = []
35-
3637
with tempfile.TemporaryDirectory(dir=Path()) as tmp:
3738
def restore_project(project, runtime):
3839
subprocess.run([
@@ -42,7 +43,7 @@ def restore_project(project, runtime):
4243
'--command=sh', f'--runtime=org.freedesktop.Sdk//{args.freedesktop}', '--share=network',
4344
'--filesystem=host', f'org.freedesktop.Sdk.Extension.dotnet{args.dotnet}//{args.freedesktop}', '-c',
4445
f'PATH="${{PATH}}:/usr/lib/sdk/dotnet{args.dotnet}/bin" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/sdk/dotnet{args.dotnet}/lib" exec dotnet restore "$@"',
45-
'--', '--packages', tmp, project] + (['-r', runtime] if runtime else []))
46+
'--', '--packages', tmp, project] + (['-r', runtime] if runtime else []) + (args.dotnet_args or []))
4647

4748
with concurrent.futures.ThreadPoolExecutor() as executor:
4849
futures = []

0 commit comments

Comments
 (0)