Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit c069254

Browse files
authored
Make sure to fatten the packages (#213)
* Make sure to fatten the packages * Use a separate powershell script * Improve the fat packager
1 parent 6130c6c commit c069254

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ output/
77
docs/
88
.vs/
99
generated/
10+
tmp/
1011
**/scriptcs_packages/
1112

1213
*.xam

azure-pipelines.yml

+2-20
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,8 @@ jobs:
2626
- 'xamarin.androidbinderator.tool': '0.4.1'
2727
- 'xamarin.androidx.migration.tool': '1.0.0-preview05'
2828
postBuildSteps:
29-
- script: |
30-
# Make a temp folder to move the created nugets to before we fat package them
31-
mkdir -p $(Build.SourcesDirectory)/tmp/nuget
32-
mkdir -p $(Build.SourcesDirectory)/tmp/output
33-
# Move all of the nupkg files from output into the temp folder we just created
34-
mv $(Build.SourcesDirectory)/output/*.nupkg $(Build.SourcesDirectory)/tmp/nuget
35-
# Move the remaining output bits to a temp location so they don't get overwritten
36-
mv $(Build.SourcesDirectory)/output/* $(Build.SourcesDirectory)/tmp/output
37-
sh build.sh --script nuget.cake \
38-
--localSource=$(Build.SourcesDirectory)/tmp/nuget \
39-
--packagesPath=$(Build.SourcesDirectory)/tmp/pkgs \
40-
--workingPath=$(Build.SourcesDirectory)/tmp/working \
41-
--outputPath=$(Build.SourcesDirectory)/output \
42-
--incrementVersion=False \
43-
--packLatestOnly=True \
44-
--useExplicitVersion=True
45-
# Move the other output bits back to the original output folder
46-
mv $(Build.SourcesDirectory)/tmp/output/* $(Build.SourcesDirectory)/output
47-
displayName: 'NuGet FAT'
48-
enabled: false
29+
- pwsh: .\fatten.ps1
30+
displayName: 'Fatten the NuGet packages'
4931
# Run some internal auditing on Windows
5032
- ${{ if and(eq(variables['System.TeamProject'], 'devdiv'), eq(variables['System.JobName'], 'windows')) }}:
5133
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0

fatten.ps1

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Make a temp folder to move the created nugets to before we fat package them
2+
mkdir -p ./tmp/nuget
3+
mkdir -p ./tmp/output
4+
5+
# Move all of the nupkg files from output into the temp folder we just created
6+
mv ./output/*.nupkg ./tmp/nuget
7+
8+
# Move the remaining output bits to a temp location so they don't get overwritten
9+
mv ./output/* ./tmp/output
10+
11+
dotnet cake nuget.cake `
12+
--localSource=./tmp/nuget `
13+
--packagesPath=./tmp/pkgs `
14+
--workingPath=./tmp/working `
15+
--outputPath=./output `
16+
--incrementVersion=False `
17+
--packLatestOnly=True `
18+
--useExplicitVersion=True `
19+
--skipNuspecProcessing=True
20+
21+
# Move the other output bits back to the original output folder
22+
mv ./tmp/output/* ./output

nuget.cake

+11-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
//
4949
///////////////////////////////////////////////////////////////////////////////
5050

51-
#addin nuget:?package=Cake.FileHelpers&version=3.0.0
51+
#addin nuget:?package=Cake.FileHelpers&version=3.2.1
5252
#addin nuget:?package=NuGet.Packaging&version=4.7.0&loaddependencies=true
5353
#addin nuget:?package=NuGet.Protocol&version=4.7.0&loaddependencies=true
5454

@@ -100,6 +100,8 @@ var minimumVersion = new Dictionary<string, NuGetVersion> {
100100

101101
var blacklistIdPrefix = new List<string> {
102102
"xamarin.build.download",
103+
"xamarin.android.support.constraint.layout",
104+
"xamarin.google.guava",
103105
};
104106

105107
var seedPackages = new [] {
@@ -203,16 +205,18 @@ VersionRange GetSupportVersionRange(FilePath nuspec)
203205
// search this nuget for a support version
204206
version = xmd
205207
.Descendants(ns + "dependency")
206-
.FirstOrDefault(e => e.Attribute("id").Value.ToLower().StartsWith("xamarin.android.support"))
208+
.LastOrDefault(e => e.Attribute("id").Value.ToLower().StartsWith("xamarin.android.support"))
207209
?.Attribute("version")
208210
?.Value;
209211

210212
// if none was found, look in the dependencies
211213
if (string.IsNullOrEmpty(version)) {
212-
foreach (var xdep in xmd.Descendants(ns + "dependency")) {
214+
foreach (var xdep in xmd.Descendants(ns + "dependency").Reverse()) {
213215
var id = xdep.Attribute("id").Value.ToLower();
214216
var range = VersionRange.Parse(xdep.Attribute("version").Value);
215217
var depNuspec = $"{packagesPath}/{id}/{range.MinVersion ?? range.MaxVersion}/{id}.nuspec";
218+
if (!FileExists(depNuspec))
219+
continue;
216220
// if a support version was found, use it, otherwise continue looking
217221
var suppRange = GetSupportVersionRange(depNuspec);
218222
if (suppRange != null)
@@ -244,7 +248,7 @@ VersionRange GetArchVersionRange(FilePath nuspec)
244248
if (xid.Value.ToLower().StartsWith("xamarin.android.support")) {
245249
version = xmd
246250
.Descendants(ns + "dependency")
247-
.First(e => e.Attribute("id").Value.ToLower().StartsWith("xamarin.android.arch"))
251+
.Last(e => e.Attribute("id").Value.ToLower().StartsWith("xamarin.android.arch"))
248252
.Attribute("version")
249253
.Value;
250254
} else {
@@ -509,8 +513,9 @@ Task("PrepareWorkingDirectory")
509513

510514
// move the old dependencies into the new groups if they contain a support version
511515
// if not, then just use the version of the nuspec
512-
var xgroups = xdeps.Elements(ns + "group");
513-
foreach (var xoldGroup in xgroups) {
516+
// only select the last group as the rest will be re-created
517+
var xoldGroup = xdeps.Elements(ns + "group").LastOrDefault();
518+
if (xoldGroup != null) {
514519
var xgroupDeps = xoldGroup.Elements(ns + "dependency");
515520
var firstSupportVersion = xgroupDeps
516521
.Where(x => x.Attribute("id").Value.ToLower().StartsWith("xamarin.android.support"))

0 commit comments

Comments
 (0)