From 3be626ba580693930e2e272f89dffd6a3c56a395 Mon Sep 17 00:00:00 2001 From: Jo Shields Date: Fri, 11 Aug 2017 09:23:24 -0400 Subject: [PATCH] Fix for msbuild not finding nuget references --- fix-project-builds-linux.patch | 94 ++++++++++++++++++++++++++++++++++ mono-core.spec | 2 + 2 files changed, 96 insertions(+) create mode 100644 fix-project-builds-linux.patch diff --git a/fix-project-builds-linux.patch b/fix-project-builds-linux.patch new file mode 100644 index 0000000000..7786a3e46a --- /dev/null +++ b/fix-project-builds-linux.patch @@ -0,0 +1,94 @@ +diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/NuGetPackageObject.cs b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/NuGetPackageObject.cs +index 26f04c1..703a648 100644 +--- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/NuGetPackageObject.cs ++++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/NuGetPackageObject.cs +@@ -34,6 +34,7 @@ public NuGetPackageObject(string id, string version, Func fullPackagePat + + public string Id { get; } + public string Version { get; } ++ public string RelativePackagePath => (string)LibraryObject["path"]; + + /// + /// The JSON object from the "targets" section in the project.lock.json for this package. +diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs +index 8acffe3..a074997 100644 +--- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs ++++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs +@@ -369,7 +369,7 @@ private void GetAnalyzers(JObject lockFile) + if (Path.GetExtension(file).Equals(".dll", StringComparison.OrdinalIgnoreCase)) + { + string path; +- if (TryGetFile(package.Id, package.Version, file, out path)) ++ if (TryGetFile(package.Id, package.Version, package.RelativePackagePath, file, out path)) + { + var analyzer = new TaskItem(path); + +@@ -441,16 +441,16 @@ private void SetWinMDMetadata(IEnumerable runtimeWinMDs, ICollection< + } + } + +- private bool TryGetFile(string packageName, string packageVersion, string file, out string path) ++ private bool TryGetFile(string packageName, string packageVersion, string packageRelativePath, string file, out string path) + { + if (IsFileValid(file, "C#", "VB")) + { +- path = GetPath(packageName, packageVersion, file); ++ path = GetPath(packageName, packageVersion, packageRelativePath, file); + return true; + } + else if (IsFileValid(file, "VB", "C#")) + { +- path = GetPath(packageName, packageVersion, file); ++ path = GetPath(packageName, packageVersion, packageRelativePath, file); + return true; + } + +@@ -469,9 +469,9 @@ private bool IsFileValid(string file, string expectedLanguage, string unExpected + !file.Split('/').Any(x => x.Equals(unExpectedLanguage, StringComparison.OrdinalIgnoreCase))); + } + +- private string GetPath(string packageName, string packageVersion, string file) ++ private string GetPath(string packageId, string packageVersion, string packageRelativePath, string file) + { +- return Path.Combine(GetNuGetPackagePath(packageName, packageVersion), file.Replace('/', Path.DirectorySeparatorChar)); ++ return Path.Combine(GetNuGetPackagePath(packageId, packageVersion, packageRelativePath), file.Replace('/', Path.DirectorySeparatorChar)); + } + + /// +@@ -932,17 +932,23 @@ private void AddReferencedPackages(JArray packageDependencies, SortedSet + } + } + +- private string GetNuGetPackagePath(string packageId, string packageVersion) ++ private string GetNuGetPackagePath(string packageId, string packageVersion, string packageRelativePath) + { ++ string relativePathToUse = String.IsNullOrEmpty(packageRelativePath) ++ ? Path.Combine(packageId, packageVersion) ++ : packageRelativePath.Replace('/', Path.DirectorySeparatorChar); ++ ++ string hashFileName = $"{packageId.ToLowerInvariant()}.{packageVersion.ToLowerInvariant()}.nupkg.sha512"; ++ + foreach (var packagesFolder in _packageFolders) + { +- string packagePath = Path.Combine(packagesFolder, packageId, packageVersion); ++ string packageFullPath = Path.Combine(packagesFolder, relativePathToUse); + + // The proper way to check if a package is available is to look for the hash file, since that's the last + // file written as a part of the restore process. If it's not there, it means something failed part way through. +- if (_fileExists(Path.Combine(packagePath, $"{packageId}.{packageVersion}.nupkg.sha512"))) ++ if (_fileExists(Path.Combine(packageFullPath, hashFileName))) + { +- return packagePath; ++ return packageFullPath; + } + } + +@@ -972,7 +978,7 @@ private IEnumerable GetPackagesFromTarget(JObject lockFile, + } + else + { +- fullPackagePathGenerator = () => GetNuGetPackagePath(id, version); ++ fullPackagePathGenerator = () => GetNuGetPackagePath(id, version, (string)libraryObject["path"]); + } + + yield return new NuGetPackageObject(id, version, fullPackagePathGenerator, (JObject)package.Value, libraryObject); diff --git a/mono-core.spec b/mono-core.spec index db237cf0ab..5faad01e1f 100644 --- a/mono-core.spec +++ b/mono-core.spec @@ -38,6 +38,7 @@ Url: http://www.mono-project.com Source0: http://download.mono-project.com/sources/mono/mono-%{version}.tar.bz2 Patch0: provides-facades.patch Patch1: 0001-btls-Disable-BUILD_SHARED_LIBS-while-building-boring.patch +Patch2: fix-project-builds-linux.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: bison @@ -135,6 +136,7 @@ technologies that have been submitted to the ECMA for standardization. %setup -q -n mono-%{version} %patch0 -p1 %patch1 -p1 +%patch2 -p1 %build ./autogen.sh