Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Added Xamarin Apple Target #675

Merged
merged 1 commit into from
Mar 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ namespace Rocket.Surgery.Nuke;
/// <summary>
/// <see cref="GitVersion" /> extensions.
/// </summary>
public static class GitVersionEx
public static class GitVersionFunctions
{
/// <summary>
/// Gets the full semantic version from <see cref="GitVersion" />.
21 changes: 21 additions & 0 deletions src/Nuke/Xamarin/apple/IHaveBundleIdentifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ReSharper disable once CheckNamespace

namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Has a bundle identifier.
/// </summary>
public interface IHaveBundleIdentifier : IHave
{
/// <summary>
/// Gets the path for the info plist.
/// </summary>
[Parameter("The application bundle identifier.")]
public string BundleIdentifier => "com.rocketbooster.nuke";

/// <summary>
/// Gets the suffix for the bundle identifier.
/// </summary>
[Parameter("The identifier suffix.")]
public string Suffix { get; set; }
}
16 changes: 16 additions & 0 deletions src/Nuke/Xamarin/apple/IHaveInfoPlist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Nuke.Common.IO;

// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Has an info.plist file.
/// </summary>
public interface IHaveInfoPlist : IHave
{
/// <summary>
/// Gets the path for the info plist.
/// </summary>
[Parameter("The path to the info.plist.")]
public AbsolutePath InfoPlist { get; }
}
39 changes: 39 additions & 0 deletions src/Nuke/Xamarin/apple/IXamarinAppleTarget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Serilog;

// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Represents an application with a apple head, and associated concerns.
/// </summary>
public interface IXamarinAppleTarget : IHaveBundleIdentifier, IHaveGitVersion, IHaveInfoPlist
{
/// <summary>
/// modify info.plist
/// </summary>
public Target ModifyInfoPlist => _ => _
.Executes(
() =>
{
Log.Verbose("Info.plist Path: {InfoPlist}", InfoPlist);
var plist = Plist.Deserialize(InfoPlist);

Log.Verbose("Deserialized Plist:\n {@Plist}\n", plist);

plist["CFBundleIdentifier"] = $"{BundleIdentifier}.{Suffix.ToLower()}".TrimEnd('.');
Log.Information("CFBundleIdentifier: {CFBundleIdentifier}", plist["CFBundleIdentifier"]);

plist["CFBundleShortVersionString"] = $"{GitVersion?.Major}.{GitVersion?.Minor}.{GitVersion?.Patch}";
Log.Information(
"CFBundleShortVersionString: {CFBundleShortVersionString}",
plist["CFBundleShortVersionString"]
);

plist["CFBundleVersion"] = $"{GitVersion?.FullSemanticVersion()}";
Log.Information("CFBundleVersion: {CFBundleVersion}", plist["CFBundleVersion"]);

Plist.Serialize(InfoPlist, plist);
Log.Verbose("Serialized Plist:\n {@Plist}\n", plist);
}
);
}
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
using Nuke.Common.IO;
using Serilog;

// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
Original file line number Diff line number Diff line change
@@ -31,11 +31,12 @@ public interface ICanArchiveiOS : IHavePackTarget,
.SetProperty("Platform", iOSTargetPlatform)
.SetProperty("BuildIpa", "true")
.SetProperty("ArchiveOnBuild", "true")
.SetProperty("IpaPackageDir", ArtifactsDirectory / "ios")
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "package.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.FullSemanticVersion())
.SetPackageVersion(GitVersion?.NuGetVersionV2)
.SetPackageVersion(GitVersion?.FullSemanticVersion())
)
);
}
37 changes: 37 additions & 0 deletions src/Nuke/Xamarin/apple/ios/ICanBuildXamariniOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Nuke.Common.Tools.MSBuild;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;

#pragma warning disable CA1304
// ReSharper disable InconsistentNaming
// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Xamarin iOS build
/// </summary>
public interface ICanBuildXamariniOS : IXamarinAppleTarget,
IHaveBuildTarget,
IHaveRestoreTarget,
IHaveSolution,
IHaveConfiguration,
IHaveOutputLogs,
IHaveiOSTargetPlatform,
ICan
{
/// <summary>
/// msbuild
/// </summary>
public Target BuildiPhone => _ => _
.DependsOn(Restore)
.Executes(
() => MSBuild(
settings => settings.SetSolutionFile(Solution)
.SetProperty("Platform", iOSTargetPlatform)
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "build.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.FullSemanticVersion())
.SetPackageVersion(GitVersion?.NuGetVersionV2)
)
);
}
File renamed without changes.
36 changes: 36 additions & 0 deletions src/Nuke/Xamarin/apple/mac/ICanBuildXamarinMac.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Nuke.Common.Tools.MSBuild;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;

#pragma warning disable CA1304
// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Xamarin mac build
/// </summary>
public interface ICanBuildXamarinMac : IXamarinAppleTarget,
IHaveBuildTarget,
IHaveRestoreTarget,
IHaveSolution,
IHaveConfiguration,
IHaveOutputLogs,
ICan
{
/// <summary>
/// msbuild
/// </summary>
public new Target Build => _ => _
.DependsOn(Restore)
.Executes(
() => MSBuild(
settings => settings
.SetSolutionFile(Solution)
.SetProperty("Platform", TargetPlatform.AnyCPU)
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "build.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.FullSemanticVersion())
.SetPackageVersion(GitVersion?.NuGetVersionV2)
)
);
}
File renamed without changes.
79 changes: 0 additions & 79 deletions src/Nuke/Xamarin/ios/ICanBuildXamariniOS.cs

This file was deleted.

74 changes: 0 additions & 74 deletions src/Nuke/Xamarin/mac/ICanBuildXamarinMac.cs

This file was deleted.