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

Repack netstandard facade in ckan.exe #4013

Merged
merged 1 commit into from
Feb 2, 2024
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
39 changes: 18 additions & 21 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#addin "nuget:?package=semver&version=2.3.0"
#addin "nuget:?package=Cake.Docker&version=0.11.1"
#addin nuget:?package=Cake.Git&version=3.0.0
#tool "nuget:?package=ILRepack&version=2.0.18"
#tool "nuget:?package=ILRepack&version=2.0.27"
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.16.3"

using System.Text.RegularExpressions;
Expand Down Expand Up @@ -296,6 +296,8 @@ Task("Repack-Ckan")
.Combine(configuration)
.Combine("bin")
.Combine(buildNetFramework))));
// Need netstandard.dll facade to instantiate types from ValveKeyValue on Mono
assemblyPaths.Add(FacadesDirectory().CombineWithFilePath("netstandard.dll"));
var ckanLogFile = repackDirectory.Combine(configuration)
.CombineWithFilePath($"ckan.log");
ReportRepacking(ckanFile, ckanLogFile);
Expand All @@ -305,8 +307,7 @@ Task("Repack-Ckan")
assemblyPaths,
new ILRepackSettings
{
Libs = new List<DirectoryPath> { cmdLineBinDirectory,
netstandardRefDirectory() },
Libs = new List<DirectoryPath> { cmdLineBinDirectory },
TargetPlatform = TargetPlatformVersion.v4,
Parallel = true,
Verbose = false,
Expand Down Expand Up @@ -361,8 +362,7 @@ Task("Repack-Netkan")
assemblyPaths,
new ILRepackSettings
{
Libs = new List<DirectoryPath> { netkanBinDirectory,
netstandardRefDirectory() },
Libs = new List<DirectoryPath> { netkanBinDirectory },
TargetPlatform = TargetPlatformVersion.v4,
Parallel = true,
Verbose = false,
Expand Down Expand Up @@ -522,22 +522,19 @@ Teardown(context =>

RunTarget(target);

private DirectoryPath netstandardRefDirectory()
{
// We need to tell ILRepack where to find netstandard.dll (on Linux),
// which doesn't get copied to the output folder
var netstandardDirectory = nugetDirectory.Combine("netstandard.library");
var netstandardVersion = System.IO.Directory
.EnumerateDirectories(netstandardDirectory.ToString())
.Select(p => System.IO.Path.GetFileName(p))
.OrderBy(p => ParseSemVer(p))
.Last();
return netstandardDirectory.Combine(netstandardVersion)
.Combine("build")
.Combine("netstandard2.0")
.Combine("ref");
}

private DirectoryPath FacadesDirectory()
=> IsRunningOnWindows()
? Context.Environment.GetSpecialPath(SpecialPath.ProgramFilesX86)
.Combine("Reference Assemblies")
.Combine("Microsoft")
.Combine("Framework")
.Combine(".NETFramework")
.Combine("v4.8")
.Combine("Facades")
: new DirectoryPath("/usr").Combine("lib")
.Combine("mono")
.Combine("4.8-api")
.Combine("Facades");

private Semver.SemVersion GetVersion()
{
Expand Down
Loading