Skip to content

Commit 625de53

Browse files
committed
feat: 2025.11.3
1 parent 9dc5c54 commit 625de53

4 files changed

Lines changed: 105 additions & 41 deletions

File tree

Nickvision.FlatpakGenerator/FlatpakSourcesGenerator.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,22 @@ public static async Task<bool> CheckRuntimeAsync(string runtime, bool runAsUser)
6868
return false;
6969
}
7070

71-
public static async Task<List<NugetSource>> GenerateSourcesAsync(string input, int dotnetVersion, string? temp, bool selfContained, bool runAsUser)
71+
public static async Task<List<NugetSource>> GenerateSourcesAsync(string input, int dotnetVersion, string? freedesktopVersion, string? temp, bool selfContained, bool runAsUser)
7272
{
7373
input = input.Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
74+
freedesktopVersion = freedesktopVersion ?? "25.08";
7475
temp = Path.Combine(temp?.Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) ?? Directory.GetCurrentDirectory(), "nuget-temp");
7576
Directory.CreateDirectory(temp);
7677
if (string.IsNullOrEmpty(input) || !File.Exists(input) || Path.GetExtension(input) != ".csproj")
7778
{
7879
Console.Error.WriteLine("[Error] Invalid input csproj file path");
7980
return [];
8081
}
81-
if (!await CheckRuntimeAsync($"org.freedesktop.Sdk//24.08", runAsUser))
82+
if (!await CheckRuntimeAsync($"org.freedesktop.Sdk//{freedesktopVersion}", runAsUser))
8283
{
8384
return [];
8485
}
85-
if (!await CheckRuntimeAsync($"org.freedesktop.Sdk.Extension.dotnet{dotnetVersion}//24.08", runAsUser))
86+
if (!await CheckRuntimeAsync($"org.freedesktop.Sdk.Extension.dotnet{dotnetVersion}//{freedesktopVersion}", runAsUser))
8687
{
8788
return [];
8889
}
@@ -97,10 +98,10 @@ public static async Task<List<NugetSource>> GenerateSourcesAsync(string input, i
9798
"--env=DOTNET_CLI_TELEMETRY_OPTOUT=true",
9899
"--env=DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true",
99100
"--command=sh",
100-
"--runtime=org.freedesktop.Sdk//24.08",
101+
$"--runtime=org.freedesktop.Sdk//{freedesktopVersion}",
101102
"--share=network",
102103
"--filesystem=host",
103-
$"org.freedesktop.Sdk.Extension.dotnet{dotnetVersion}//24.08",
104+
$"org.freedesktop.Sdk.Extension.dotnet{dotnetVersion}//{freedesktopVersion}",
104105
"-c",
105106
$"PATH=\"${{PATH}}:/usr/lib/sdk/dotnet{dotnetVersion}/bin\" LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/usr/lib/sdk/dotnet{dotnetVersion}/lib\" exec dotnet restore \"$@\"",
106107
"--",
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
6-
<ImplicitUsings>disable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
<PackageId>Nickvision.FlatpakGenerator</PackageId>
9-
<Version>2025.11.2</Version>
10-
<Company>Nickvision</Company>
11-
<Authors>Nickvision</Authors>
12-
<Description>A tool to generate Flatpak sources file for .NET projects</Description>
13-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
14-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
15-
<PackAsTool>true</PackAsTool>
16-
<Copyright>(c) Nickvision 2021-2025</Copyright>
17-
<PackageProjectUrl>https://nickvision.org</PackageProjectUrl>
18-
<RepositoryType>git</RepositoryType>
19-
<RepositoryUrl>https://github.com/NickvisionApps/FlatpakGenerator</RepositoryUrl>
20-
<Title>Nickvision.FlatpakGenerator</Title>
21-
<PackageIcon>logo.png</PackageIcon>
22-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
6+
<ImplicitUsings>disable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<PackageId>Nickvision.FlatpakGenerator</PackageId>
9+
<Version>2025.11.3</Version>
10+
<Company>Nickvision</Company>
11+
<Authors>Nickvision</Authors>
12+
<Description>A tool to generate Flatpak sources file for .NET projects</Description>
13+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
14+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
15+
<PackAsTool>true</PackAsTool>
16+
<Copyright>(c) Nickvision 2021-2025</Copyright>
17+
<PackageProjectUrl>https://nickvision.org</PackageProjectUrl>
18+
<RepositoryType>git</RepositoryType>
19+
<RepositoryUrl>https://github.com/NickvisionApps/FlatpakGenerator</RepositoryUrl>
20+
<Title>Nickvision.FlatpakGenerator</Title>
21+
<PackageIcon>logo.png</PackageIcon>
22+
</PropertyGroup>
2323

24-
<ItemGroup>
25-
<PackageReference Include="System.CommandLine" Version="2.0.0" />
26-
</ItemGroup>
24+
<ItemGroup>
25+
<PackageReference Include="System.CommandLine" Version="2.0.0" />
26+
</ItemGroup>
2727

28-
<ItemGroup>
29-
<None Include="..\resources\logo.png">
30-
<Pack>True</Pack>
31-
<PackagePath />
32-
<Link>logo.png</Link>
33-
</None>
34-
</ItemGroup>
35-
28+
<ItemGroup>
29+
<None Include="..\resources\logo.png">
30+
<Pack>True</Pack>
31+
<PackagePath />
32+
<Link>logo.png</Link>
33+
</None>
34+
</ItemGroup>
35+
3636
</Project>

Nickvision.FlatpakGenerator/Program.cs

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.CommandLine;
3+
using System.Reflection.Metadata.Ecma335;
34
using System.Threading.Tasks;
45

56
namespace Nickvision.FlatpakGenerator;
@@ -24,7 +25,17 @@ public static async Task<int> Main(string[] args)
2425
{
2526
"-d"
2627
},
27-
DefaultValueFactory = r => 8
28+
DefaultValueFactory = r => 10
29+
},
30+
new Option<string>("--freedesktop")
31+
{
32+
Description = "The FreeDesktop SDK version to target",
33+
Required = true,
34+
Aliases =
35+
{
36+
"-f"
37+
},
38+
DefaultValueFactory = r => "25.08"
2839
},
2940
new Option<bool>("--run-as-user")
3041
{
@@ -55,7 +66,17 @@ public static async Task<int> Main(string[] args)
5566
{
5667
"-d"
5768
},
58-
DefaultValueFactory = r => 8
69+
DefaultValueFactory = r => 10
70+
},
71+
new Option<string>("--freedesktop")
72+
{
73+
Description = "The FreeDesktop SDK version to target",
74+
Required = true,
75+
Aliases =
76+
{
77+
"-f"
78+
},
79+
DefaultValueFactory = r => "25.08"
5980
},
6081
new Option<string>("--output")
6182
{
@@ -96,16 +117,51 @@ public static async Task<int> Main(string[] args)
96117
};
97118
checkCommand.SetAction(async x =>
98119
{
99-
await FlatpakSourcesGenerator.CheckRuntimeAsync("org.freedesktop.Sdk//24.08", x.GetValue<bool>("--run-as-user"));
100-
await FlatpakSourcesGenerator.CheckRuntimeAsync($"org.freedesktop.Sdk.Extension.dotnet{x.GetRequiredValue<int>("--dotnet")}//24.08", x.GetValue<bool>("--run-as-user"));
120+
if(!IsDotnetVersionValid(x.GetValue<int>("--dotnet")))
121+
{
122+
Console.Error.WriteLine("[Error] Invalid .NET version. Supported versions are 8, 9, and 10.");
123+
return;
124+
}
125+
if(!IsFreedesktopVersionValid(x.GetValue<string>("--freedesktop"), x.GetValue<int>("--dotnet")))
126+
{
127+
Console.Error.WriteLine("[Error] Invalid FreeDesktop version for the specified .NET version.");
128+
return;
129+
}
130+
await FlatpakSourcesGenerator.CheckRuntimeAsync($"org.freedesktop.Sdk//{x.GetValue<string>("--freedesktop")}", x.GetValue<bool>("--run-as-user"));
131+
await FlatpakSourcesGenerator.CheckRuntimeAsync($"org.freedesktop.Sdk.Extension.dotnet{x.GetRequiredValue<int>("--dotnet")}//{x.GetValue<string>("--freedesktop")}", x.GetValue<bool>("--run-as-user"));
101132
});
102133
generateCommand.SetAction(async x =>
103134
{
104-
var sources = await FlatpakSourcesGenerator.GenerateSourcesAsync(x.GetRequiredValue<string>("--input"), x.GetRequiredValue<int>("--dotnet"), x.GetValue<string>("--temp"), x.GetValue<bool>("--self-contained"), x.GetValue<bool>("--run-as-user"));
135+
if (!IsDotnetVersionValid(x.GetValue<int>("--dotnet")))
136+
{
137+
Console.Error.WriteLine("[Error] Invalid .NET version. Supported versions are 8, 9, and 10.");
138+
return;
139+
}
140+
if (!IsFreedesktopVersionValid(x.GetValue<string>("--freedesktop"), x.GetValue<int>("--dotnet")))
141+
{
142+
Console.Error.WriteLine("[Error] Invalid FreeDesktop version for the specified .NET version.");
143+
return;
144+
}
145+
var sources = await FlatpakSourcesGenerator.GenerateSourcesAsync(x.GetRequiredValue<string>("--input"), x.GetRequiredValue<int>("--dotnet"), x.GetRequiredValue<string>("--freedesktop"), x.GetValue<string>("--temp"), x.GetValue<bool>("--self-contained"), x.GetValue<bool>("--run-as-user"));
105146
await FlatpakSourcesGenerator.WriteSourcesFileAsync(sources, x.GetValue<string>("--output"));
106147
});
107148
rootCommand.Subcommands.Add(checkCommand);
108149
rootCommand.Subcommands.Add(generateCommand);
109150
return await rootCommand.Parse(args).InvokeAsync();
110151
}
152+
153+
private static bool IsDotnetVersionValid(int dotnetVersion) => dotnetVersion >= 8 && dotnetVersion <= 10;
154+
155+
private static bool IsFreedesktopVersionValid(string? freedesktopVersion, int dotnetVersion)
156+
{
157+
if(freedesktopVersion == "24.08")
158+
{
159+
return dotnetVersion != 8;
160+
}
161+
else if(freedesktopVersion == "25.08")
162+
{
163+
return true;
164+
}
165+
return false;
166+
}
111167
}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ This tool is a replacement for the [flatpak-dotnet-generator](https://github.com
1010
1. Written in C# (obviously)
1111
2. Support for adding runtime packages that are required to build self-contained programs (enabled with `--self-contained`/`-s` flag)
1212
3. Support for running `flatpak` commands in user mode (enabled with `--user`/`-u` flag)
13+
4. Support for specifying dotnet versions (specified with `--dotnet`) and freedesktop versions (specified with `--freedesktop`) to use
14+
15+
| .NET SDK | FreeDesktop 24.08 | FreeDesktop 25.08 |
16+
|----------|-------------------|-------------------|
17+
| 8 |||
18+
| 9 |||
19+
| 10 |||
1320

1421
## Dependencies
1522
- .NET 8/9/10

0 commit comments

Comments
 (0)