mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Add SetVersion command
This commit is contained in:
parent
8c3ebbe375
commit
9edd3715f9
@ -5,7 +5,6 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>NAPS2</RootNamespace>
|
||||
<AssemblyName>naps2</AssemblyName>
|
||||
<Version>7.0.1</Version>
|
||||
<ApplicationIcon>../NAPS2.Lib/Icons/favicon.ico</ApplicationIcon>
|
||||
|
||||
<SelfContained>true</SelfContained>
|
||||
|
@ -5,7 +5,6 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>NAPS2</RootNamespace>
|
||||
<AssemblyName>NAPS2</AssemblyName>
|
||||
<Version>7.0.1</Version>
|
||||
<ApplicationIcon>../NAPS2.Lib/Icons/favicon.ico</ApplicationIcon>
|
||||
|
||||
<RuntimeIdentifiers>osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
|
@ -8,7 +8,6 @@
|
||||
<LargeAddressAware>true</LargeAddressAware>
|
||||
<RootNamespace>NAPS2</RootNamespace>
|
||||
<AssemblyName>NAPS2</AssemblyName>
|
||||
<Version>7.0.1</Version>
|
||||
<ApplicationIcon>../NAPS2.Lib/Icons/favicon.ico</ApplicationIcon>
|
||||
|
||||
<!-- <PublishSingleFile>true</PublishSingleFile>-->
|
||||
|
@ -3,6 +3,7 @@ using NAPS2.Tools.Localization;
|
||||
using NAPS2.Tools.Project;
|
||||
using NAPS2.Tools.Project.Installation;
|
||||
using NAPS2.Tools.Project.Packaging;
|
||||
using NAPS2.Tools.Project.Release;
|
||||
using NAPS2.Tools.Project.Verification;
|
||||
using NAPS2.Tools.Project.Workflows;
|
||||
|
||||
@ -35,6 +36,7 @@ public static class Program
|
||||
.Add<ResxOptions, ResxCommand>()
|
||||
.Add<PushTemplatesOptions, PushTemplatesCommand>()
|
||||
.Add<PullTranslationsOptions, PullTranslationsCommand>()
|
||||
.Add<SetVersionOptions, SetVersionCommand>()
|
||||
.Add<SaneOptsOptions, SaneOptsCommand>();
|
||||
|
||||
var result = Parser.Default.ParseArguments(args, commands.OptionTypes);
|
||||
|
@ -6,7 +6,7 @@ public class InstallCommand : ICommand<InstallOptions>
|
||||
{
|
||||
public int Run(InstallOptions opts)
|
||||
{
|
||||
var version = ProjectHelper.GetDefaultProjectVersion();
|
||||
var version = ProjectHelper.GetCurrentVersionName();
|
||||
|
||||
var constraints = new TargetConstraints
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ public static class FlatpakPackager
|
||||
|
||||
// Update metainfo file with the current version/date
|
||||
var metaInfo = File.ReadAllText(Path.Combine(Paths.SetupLinux, "com.naps2.Naps2.metainfo.xml"));
|
||||
var version = ProjectHelper.GetDefaultProjectVersion();
|
||||
var version = ProjectHelper.GetCurrentVersionName();
|
||||
var date = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
metaInfo = Regex.Replace(metaInfo,
|
||||
@"<release [^>]+/>",
|
||||
|
@ -46,7 +46,7 @@ public class PackageCommand : ICommand<PackageOptions>
|
||||
|
||||
private static PackageInfo GetPackageInfo(Platform platform, string preferredConfig)
|
||||
{
|
||||
var pkgInfo = new PackageInfo(platform, ProjectHelper.GetProjectVersion("NAPS2.App.WinForms"));
|
||||
var pkgInfo = new PackageInfo(platform, ProjectHelper.GetCurrentVersionName());
|
||||
|
||||
if (!platform.IsWindows())
|
||||
{
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using NAPS2.Tools.Project.Targets;
|
||||
|
||||
@ -6,30 +5,33 @@ namespace NAPS2.Tools.Project;
|
||||
|
||||
public static class ProjectHelper
|
||||
{
|
||||
public static string GetProjectVersion(string projectName)
|
||||
public static string GetCurrentVersion()
|
||||
{
|
||||
var projectPath = Path.Combine(Paths.SolutionRoot, projectName, $"{projectName}.csproj");
|
||||
var projectFile = XDocument.Load(projectPath);
|
||||
var version = projectFile.Descendants().SingleOrDefault(x => x.Name == "Version")?.Value;
|
||||
var versionTargetsPath = Path.Combine(Paths.Setup, "targets", "VersionTargets.targets");
|
||||
var versionTargetsFile = XDocument.Load(versionTargetsPath);
|
||||
var version = versionTargetsFile.Descendants().SingleOrDefault(x => x.Name == "Version")?.Value;
|
||||
if (version == null)
|
||||
{
|
||||
throw new Exception($"Could not read version from project: {projectPath}");
|
||||
}
|
||||
if (!Regex.IsMatch(version, @"[0-9]+(\.[0-9]+){2}"))
|
||||
{
|
||||
throw new Exception($"Invalid project version: {version}");
|
||||
throw new Exception($"Could not read version from project: {versionTargetsPath}");
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public static string GetDefaultProjectVersion()
|
||||
public static string GetCurrentVersionName()
|
||||
{
|
||||
return GetProjectVersion("NAPS2.App.WinForms");
|
||||
var versionTargetsPath = Path.Combine(Paths.Setup, "targets", "VersionTargets.targets");
|
||||
var versionTargetsFile = XDocument.Load(versionTargetsPath);
|
||||
var version = versionTargetsFile.Descendants().SingleOrDefault(x => x.Name == "VersionName")?.Value;
|
||||
if (version == null)
|
||||
{
|
||||
throw new Exception($"Could not read version from project: {versionTargetsPath}");
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public static string GetPackagePath(string ext, Platform platform, string? version = null)
|
||||
{
|
||||
version ??= GetProjectVersion("NAPS2.App.WinForms");
|
||||
version ??= GetCurrentVersion();
|
||||
var path = Path.Combine(Paths.Publish, version, $"naps2-{version}-{platform.PackageName()}.{ext}");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
||||
return path;
|
||||
|
@ -7,7 +7,7 @@ public class ShareCommand : ICommand<ShareOptions>
|
||||
bool doIn = opts.ShareType is "both" or "in";
|
||||
bool doOut = opts.ShareType is "both" or "out";
|
||||
|
||||
var version = ProjectHelper.GetDefaultProjectVersion();
|
||||
var version = ProjectHelper.GetCurrentVersionName();
|
||||
|
||||
var syncBaseFolder = N2Config.ShareDir;
|
||||
if (!Directory.Exists(syncBaseFolder))
|
||||
|
@ -6,7 +6,7 @@ public class VerifyCommand : ICommand<VerifyOptions>
|
||||
{
|
||||
public int Run(VerifyOptions opts)
|
||||
{
|
||||
var version = ProjectHelper.GetDefaultProjectVersion();
|
||||
var version = ProjectHelper.GetCurrentVersionName();
|
||||
|
||||
using var appDriverRunner = AppDriverRunner.Start();
|
||||
|
||||
|
@ -9,7 +9,7 @@ public class VirusScanCommand : ICommand<VirusScanOptions>
|
||||
public int Run(VirusScanOptions opts)
|
||||
{
|
||||
Output.Info("Checking for antivirus false positives");
|
||||
var version = ProjectHelper.GetDefaultProjectVersion();
|
||||
var version = ProjectHelper.GetCurrentVersionName();
|
||||
|
||||
var constraints = new TargetConstraints
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user