mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Update SourceLink package/info and target .NET Core 3.1 with hactoolnet (#106)
Make hactoolnet target the LTS .NET Core version. LibHac still targets .NET Core 3.0.
This commit is contained in:
parent
5e4ea459cb
commit
e8bef8af6a
6 changed files with 75 additions and 37 deletions
|
@ -1 +1 @@
|
|||
3.0.100
|
||||
3.1.100
|
|
@ -35,15 +35,13 @@ namespace LibHacBuild
|
|||
public readonly bool Untrimmed;
|
||||
|
||||
[Solution("LibHac.sln")] readonly Solution _solution;
|
||||
[GitRepository] readonly GitRepository _gitRepository;
|
||||
[GitVersion] readonly GitVersion _gitVersion;
|
||||
|
||||
AbsolutePath SourceDirectory => RootDirectory / "src";
|
||||
AbsolutePath TestsDirectory => RootDirectory / "tests";
|
||||
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
|
||||
AbsolutePath SignedArtifactsDirectory => ArtifactsDirectory / "signed";
|
||||
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
||||
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp3.0";
|
||||
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp3.1";
|
||||
AbsolutePath CliNativeDir => TempDirectory / $"hactoolnet_{HostOsName}";
|
||||
AbsolutePath CliNativeExe => CliNativeDir / $"hactoolnet_native{NativeProgramExtension}";
|
||||
AbsolutePath CliCoreZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-netcore.zip";
|
||||
|
@ -54,6 +52,8 @@ namespace LibHacBuild
|
|||
Project LibHacTestProject => _solution.GetProject("LibHac.Tests").NotNull();
|
||||
Project HactoolnetProject => _solution.GetProject("hactoolnet").NotNull();
|
||||
|
||||
private bool HasGitDir { get; set; }
|
||||
|
||||
private string NativeRuntime { get; set; }
|
||||
private string HostOsName { get; set; }
|
||||
private string NativeProgramExtension { get; set; }
|
||||
|
@ -86,42 +86,76 @@ namespace LibHacBuild
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsMasterBranch => _gitVersion?.BranchName.Equals("master") ?? false;
|
||||
|
||||
Target SetVersion => _ => _
|
||||
.OnlyWhenStatic(() => _gitRepository != null)
|
||||
.Executes(() =>
|
||||
{
|
||||
VersionString = $"{_gitVersion.MajorMinorPatch}";
|
||||
if (!string.IsNullOrWhiteSpace(_gitVersion.PreReleaseTag))
|
||||
GitRepository gitRepository = null;
|
||||
GitVersion gitVersion = null;
|
||||
|
||||
try
|
||||
{
|
||||
VersionString += $"-{_gitVersion.PreReleaseTag}+{_gitVersion.Sha.Substring(0, 8)}";
|
||||
gitRepository = (GitRepository)new GitRepositoryAttribute().GetValue(null, null);
|
||||
|
||||
gitVersion = GitVersionTasks.GitVersion(s => s
|
||||
.SetFramework("netcoreapp3.1")
|
||||
.DisableLogOutput())
|
||||
.Result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e);
|
||||
}
|
||||
|
||||
string suffix = _gitVersion.PreReleaseTag;
|
||||
if (gitRepository == null || gitVersion == null)
|
||||
{
|
||||
Logger.Normal("Unable to read Git version.");
|
||||
return;
|
||||
}
|
||||
|
||||
HasGitDir = true;
|
||||
|
||||
VersionString = $"{gitVersion.MajorMinorPatch}";
|
||||
if (!string.IsNullOrWhiteSpace(gitVersion.PreReleaseTag))
|
||||
{
|
||||
VersionString += $"-{gitVersion.PreReleaseTag}+{gitVersion.Sha.Substring(0, 8)}";
|
||||
}
|
||||
|
||||
string suffix = gitVersion.PreReleaseTag;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(suffix))
|
||||
{
|
||||
if (!_gitRepository.IsOnMasterBranch())
|
||||
if (!gitRepository.IsOnMasterBranch())
|
||||
{
|
||||
suffix = $"-{suffix}";
|
||||
}
|
||||
|
||||
suffix += $"+{_gitVersion.Sha.Substring(0, 8)}";
|
||||
suffix += $"+{gitVersion.Sha.Substring(0, 8)}";
|
||||
}
|
||||
|
||||
if (Host == HostType.AppVeyor)
|
||||
{
|
||||
// Workaround GitVersion issue by getting PR info manually https://github.com/GitTools/GitVersion/issues/1927
|
||||
string prNumber = Environment.GetEnvironmentVariable("APPVEYOR_PULL_REQUEST_NUMBER");
|
||||
string branchName = Environment.GetEnvironmentVariable("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH");
|
||||
|
||||
if (int.TryParse(prNumber, out int prInt) && branchName != null)
|
||||
{
|
||||
string prString = $"PullRequest{prInt:D4}";
|
||||
|
||||
VersionString = VersionString.Replace(branchName, prString);
|
||||
suffix = suffix.Replace(branchName, prString);
|
||||
}
|
||||
|
||||
SetAppVeyorVersion(VersionString);
|
||||
}
|
||||
|
||||
VersionProps = new Dictionary<string, object>
|
||||
{
|
||||
["VersionPrefix"] = _gitVersion.AssemblySemVer,
|
||||
["VersionPrefix"] = gitVersion.AssemblySemVer,
|
||||
["VersionSuffix"] = suffix
|
||||
};
|
||||
|
||||
Logger.Normal($"Building version {VersionString}");
|
||||
|
||||
if (Host == HostType.AppVeyor)
|
||||
{
|
||||
SetAppVeyorVersion(VersionString);
|
||||
}
|
||||
});
|
||||
|
||||
Target Clean => _ => _
|
||||
|
@ -159,7 +193,8 @@ namespace LibHacBuild
|
|||
.EnableNoRestore()
|
||||
.SetConfiguration(Configuration)
|
||||
.SetProperties(VersionProps)
|
||||
.SetProperty("BuildType", "Release");
|
||||
.SetProperty("BuildType", "Release")
|
||||
.SetProperty("HasGitDir", HasGitDir);
|
||||
|
||||
DotNetBuild(s => buildSettings);
|
||||
|
||||
|
@ -169,7 +204,7 @@ namespace LibHacBuild
|
|||
|
||||
DotNetPublish(s => publishSettings
|
||||
.SetProject(HactoolnetProject)
|
||||
.SetFramework("netcoreapp3.0")
|
||||
.SetFramework("netcoreapp3.1")
|
||||
.SetOutput(CliCoreDir)
|
||||
.SetNoBuild(true)
|
||||
.SetProperties(VersionProps));
|
||||
|
@ -221,7 +256,7 @@ namespace LibHacBuild
|
|||
.EnableNoBuild()
|
||||
.SetConfiguration(Configuration);
|
||||
|
||||
if (EnvironmentInfo.IsUnix) settings = settings.SetProperty("TargetFramework", "netcoreapp3.0");
|
||||
if (EnvironmentInfo.IsUnix) settings = settings.SetProperty("TargetFramework", "netcoreapp3.1");
|
||||
|
||||
DotNetTest(s => settings);
|
||||
});
|
||||
|
@ -335,7 +370,7 @@ namespace LibHacBuild
|
|||
DotNetPublishSettings publishSettings = new DotNetPublishSettings()
|
||||
.SetConfiguration(Configuration)
|
||||
.SetProject(nativeProject)
|
||||
.SetFramework("netcoreapp3.0")
|
||||
.SetFramework("netcoreapp3.1")
|
||||
.SetRuntime(NativeRuntime)
|
||||
.SetOutput(CliNativeDir)
|
||||
.SetProperties(VersionProps);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<RootNamespace>LibHacBuild</RootNamespace>
|
||||
<IsPackable>False</IsPackable>
|
||||
|
@ -10,8 +10,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageDownload Include="GitVersion.Tool" Version="[5.0.1]" />
|
||||
<PackageReference Include="NuGet.CommandLine" Version="5.3.1" />
|
||||
<PackageDownload Include="GitVersion.Tool" Version="[5.1.3]" />
|
||||
<PackageReference Include="NuGet.CommandLine" Version="5.4.0" />
|
||||
<PackageReference Include="Nuke.Common" Version="0.23.4" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.2.0" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<VersionPrefix>0.8.0</VersionPrefix>
|
||||
<TargetFrameworks>netcoreapp3.0;netstandard2.1</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -13,17 +15,18 @@
|
|||
<PackageTags>Nintendo;Switch;nca;xci;savefile</PackageTags>
|
||||
<PackageProjectUrl>https://github.com/Thealexbarney/LibHac</PackageProjectUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/Thealexbarney/LibHac</RepositoryUrl>
|
||||
|
||||
<VersionPrefix>0.7.0</VersionPrefix>
|
||||
<PathMap Condition=" '$(BuildType)' == 'Release' ">$(MSBuildProjectDirectory)=C:/LibHac/</PathMap>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<IncludeSource>true</IncludeSource>
|
||||
<NoWarn>$(NoWarn);1591;NU5105</NoWarn>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
<!-- When doing a release build with a Git directory, SourceLink will set the SourceRoot needed for DeterministicSourcePaths -->
|
||||
<!-- Otherwise use a manually specified path -->
|
||||
<PathMap Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'false' ">$(MSBuildProjectDirectory)=C:/LibHac/</PathMap>
|
||||
<DeterministicSourcePaths Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'true' ">true</DeterministicSourcePaths>
|
||||
|
||||
<NoWarn>$(NoWarn);1591;NU5105</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
|
||||
|
@ -35,7 +38,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19554-01" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>0.7.0</VersionPrefix>
|
||||
<VersionPrefix>0.8.0</VersionPrefix>
|
||||
<PathMap Condition=" '$(BuildType)' == 'Release' ">$(MSBuildProjectDirectory)=C:/hactoolnet/</PathMap>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
|
Loading…
Reference in a new issue