├── Cake.Boots
├── .gitignore
├── tools
│ └── packages.config
├── BootsSettings.cs
├── Cake.Boots.csproj
├── build.cake
└── BootsAddin.cs
├── .github
├── FUNDING.yml
├── dependabot.yml
└── workflows
│ └── actions.yml
├── icon.png
├── .vscode
├── settings.json
├── launch.json
└── tasks.json
├── global.json
├── .gitattributes
├── Boots.Core
├── FileType.cs
├── Product.cs
├── Boots.Core.csproj
├── Helpers.cs
├── UrlResolver.cs
├── ReleaseChannel.cs
├── PkgInstaller.cs
├── Installer.cs
├── MsiInstaller.cs
├── Downloader.cs
├── MacUrlResolver.cs
├── HttpClientWithPolicy.cs
├── Bootstrapper.cs
├── AsyncProcess.cs
├── WindowsUrlResolver.cs
└── VsixInstaller.cs
├── docs
├── AppCenter.png
├── GetMonoVersion.png
├── GetMacIosVersion.png
├── GetAndroidVersion.png
└── HowToFindBuilds.md
├── samples
├── HelloForms
│ ├── AssemblyInfo.cs
│ ├── HelloForms.csproj
│ ├── App.xaml
│ ├── MainPage.xaml.cs
│ ├── App.xaml.cs
│ └── MainPage.xaml
├── HelloForms.iOS
│ ├── Resources
│ │ ├── Default.png
│ │ ├── Default@2x.png
│ │ ├── Default-568h@2x.png
│ │ ├── Default-Portrait.png
│ │ ├── Default-Portrait@2x.png
│ │ └── LaunchScreen.storyboard
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── Icon20.png
│ │ │ ├── Icon29.png
│ │ │ ├── Icon40.png
│ │ │ ├── Icon58.png
│ │ │ ├── Icon60.png
│ │ │ ├── Icon76.png
│ │ │ ├── Icon80.png
│ │ │ ├── Icon87.png
│ │ │ ├── Icon1024.png
│ │ │ ├── Icon120.png
│ │ │ ├── Icon152.png
│ │ │ ├── Icon167.png
│ │ │ ├── Icon180.png
│ │ │ └── Contents.json
│ ├── Entitlements.plist
│ ├── Main.cs
│ ├── AppDelegate.cs
│ ├── Info.plist
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── HelloForms.iOS.csproj
├── HelloForms.Android
│ ├── Resources
│ │ ├── mipmap-hdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-mdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── icon.xml
│ │ │ └── icon_round.xml
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ └── AboutResources.txt
│ ├── appcenter-pre-build.sh
│ ├── Properties
│ │ ├── AndroidManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── Assets
│ │ └── AboutAssets.txt
│ ├── MainActivity.cs
│ └── HelloForms.Android.csproj
└── HelloForms.sln
├── nuget.config
├── appveyor.yml
├── scripts
├── xa-version.targets
└── build-and-test.yaml
├── Boots
├── Boots.csproj
└── Program.cs
├── Boots.Tests
├── Boots.Tests.csproj
├── Utils.cs
├── InstallerTests.cs
├── DownloaderTests.cs
├── MainTests.cs
├── AsyncProcessTests.cs
├── BootstrapperTests.cs
├── UrlResolverTests.cs
└── HttpClientWithPolicyTests.cs
├── azure-pipelines.yml
├── LICENSE
├── bitrise.yml
├── Directory.Build.targets
├── Directory.Build.props
├── boots.sln
├── .gitignore
├── .editorconfig
└── README.md
/Cake.Boots/.gitignore:
--------------------------------------------------------------------------------
1 | tools
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [jonathanpeppers]
2 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/icon.png
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "dotnet.defaultSolution": "boots.sln"
3 | }
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "rollForward": "major"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/Boots.Core/FileType.cs:
--------------------------------------------------------------------------------
1 | public enum FileType
2 | {
3 | vsix,
4 | pkg,
5 | msi
6 | }
7 |
--------------------------------------------------------------------------------
/docs/AppCenter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/docs/AppCenter.png
--------------------------------------------------------------------------------
/docs/GetMonoVersion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/docs/GetMonoVersion.png
--------------------------------------------------------------------------------
/docs/GetMacIosVersion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/docs/GetMacIosVersion.png
--------------------------------------------------------------------------------
/docs/GetAndroidVersion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/docs/GetAndroidVersion.png
--------------------------------------------------------------------------------
/Boots.Core/Product.cs:
--------------------------------------------------------------------------------
1 | public enum Product
2 | {
3 | Mono,
4 | XamarinAndroid,
5 | XamariniOS,
6 | XamarinMac,
7 | }
8 |
--------------------------------------------------------------------------------
/samples/HelloForms/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms.Xaml;
2 |
3 | [assembly: XamlCompilation (XamlCompilationOptions.Compile)]
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Resources/Default.png
--------------------------------------------------------------------------------
/Cake.Boots/tools/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Resources/Default@2x.png
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "nuget"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Resources/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Resources/Default-Portrait.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-hdpi/icon.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-mdpi/icon.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-xhdpi/icon.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Resources/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Resources/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-xxhdpi/icon.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-hdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-hdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-mdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-mdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-xhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-xhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-xxhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-xxhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jonathanpeppers/boots/HEAD/samples/HelloForms.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-anydpi-v26/icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/mipmap-anydpi-v26/icon_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 | #3F51B5
5 | #303F9F
6 | #FF4081
7 |
8 |
--------------------------------------------------------------------------------
/Boots.Core/Boots.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/appcenter-pre-build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # App Center custom build scripts: https://aka.ms/docs/build/custom/scripts
3 |
4 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
5 |
6 | dotnet tool install --global boots --version 1.0.2.421
7 | boots --preview Mono
8 | boots --preview XamarinAndroid
9 | boots --preview XamariniOS
10 |
--------------------------------------------------------------------------------
/samples/HelloForms/HelloForms.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Boots.Core/Helpers.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace Boots.Core
4 | {
5 | static class Helpers
6 | {
7 | public static bool IsWindows => RuntimeInformation.IsOSPlatform (OSPlatform.Windows);
8 |
9 | public static bool IsMac => RuntimeInformation.IsOSPlatform (OSPlatform.OSX);
10 |
11 | public static bool IsLinux => RuntimeInformation.IsOSPlatform (OSPlatform.Linux);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Cake.Boots/BootsSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | public class BootsSettings
4 | {
5 | public TimeSpan? Timeout { get; set; }
6 |
7 | public TimeSpan? ReadWriteTimeout { get; set; }
8 |
9 | public int? NetworkRetries { get; set; }
10 |
11 | public ReleaseChannel? Channel { get; set; }
12 |
13 | public Product? Product { get; set; }
14 |
15 | public FileType? FileType { get; set; }
16 |
17 | public string? Url { get; set; }
18 | }
19 |
--------------------------------------------------------------------------------
/Boots.Core/UrlResolver.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace Boots.Core
5 | {
6 | abstract class UrlResolver
7 | {
8 | protected readonly Bootstrapper Boots;
9 |
10 | public UrlResolver (Bootstrapper boots)
11 | {
12 | Boots = boots;
13 | }
14 |
15 | public abstract Task Resolve (ReleaseChannel channel, Product product, CancellationToken token = new CancellationToken ());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: '{build}'
2 | branches:
3 | only:
4 | - main
5 | - /.+appveyor.+/
6 | image: macOS
7 | test: false
8 | environment:
9 | Configuration: Release
10 | Verbosity: Diagnostic
11 | build_script:
12 | - sh: >-
13 | export PATH="$PATH:~/.dotnet/tools" &&
14 | dotnet tool update --global Cake.Tool &&
15 | dotnet build Cake.Boots/Cake.Boots.csproj &&
16 | cd Cake.Boots &&
17 | dotnet cake --target=Mono --verbosity=$Verbosity &&
18 | dotnet cake --verbosity=$Verbosity
19 |
--------------------------------------------------------------------------------
/samples/HelloForms/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Boots.Core/ReleaseChannel.cs:
--------------------------------------------------------------------------------
1 | public enum ReleaseChannel
2 | {
3 | ///
4 | /// The "stable" channel, or https://aka.ms/vs/17/release/channel on Windows, and "Stable" on Mac.
5 | ///
6 | Stable,
7 | ///
8 | /// The "preview" channel, or https://aka.ms/vs/17/pre/channel on Windows, and "Beta" on Mac.
9 | ///
10 | Preview,
11 | ///
12 | /// This channel is only valid for Visual Studio for Mac, it resolves to Preview on Windows.
13 | ///
14 | Alpha,
15 | }
16 |
--------------------------------------------------------------------------------
/samples/HelloForms/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Xamarin.Forms;
8 |
9 | namespace HelloForms
10 | {
11 | // Learn more about making custom code visible in the Xamarin.Forms previewer
12 | // by visiting https://aka.ms/xamarinforms-previewer
13 | [DesignTimeVisible (false)]
14 | public partial class MainPage : ContentPage
15 | {
16 | public MainPage ()
17 | {
18 | InitializeComponent ();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace HelloForms.iOS
9 | {
10 | public class Application
11 | {
12 | // This is the main entry point of the application.
13 | static void Main(string[] args)
14 | {
15 | // if you want to use a different Application Delegate class from "AppDelegate"
16 | // you can specify it here.
17 | UIApplication.Main(args, null, "AppDelegate");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/samples/HelloForms/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 | using Xamarin.Forms.Xaml;
4 |
5 | namespace HelloForms
6 | {
7 | public partial class App : Application
8 | {
9 | public App ()
10 | {
11 | InitializeComponent ();
12 |
13 | MainPage = new MainPage ();
14 | }
15 |
16 | protected override void OnStart ()
17 | {
18 | // Handle when your app starts
19 | }
20 |
21 | protected override void OnSleep ()
22 | {
23 | // Handle when your app sleeps
24 | }
25 |
26 | protected override void OnResume ()
27 | {
28 | // Handle when your app resumes
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/scripts/xa-version.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/HelloForms/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Boots/Boots.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 | Major
7 | true
8 | boots
9 | boots
10 | false
11 | true
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with you package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/Boots.Tests/Boots.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | false
6 | disable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Boots.Tests/Utils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 | using Xunit.Abstractions;
5 |
6 | namespace Boots.Tests
7 | {
8 | public class TestWriter : TextWriter
9 | {
10 | readonly ITestOutputHelper output;
11 |
12 | public TestWriter (ITestOutputHelper output)
13 | {
14 | this.output = output;
15 | }
16 |
17 | public override Encoding Encoding => Encoding.Default;
18 |
19 | public override void WriteLine (string value)
20 | {
21 | if (value != null) {
22 | output.WriteLine (value);
23 | Console.WriteLine (value);
24 | }
25 | }
26 |
27 | public override void WriteLine (string format, params object [] args)
28 | {
29 | output.WriteLine (format, args);
30 | Console.WriteLine (format, args);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | "program": "${workspaceFolder}/Boots/bin/Debug/netcoreapp3.1/Boots.dll",
13 | "args": [],
14 | "cwd": "${workspaceFolder}/Boots",
15 | "console": "internalConsole",
16 | "stopAtEntry": false
17 | },
18 | {
19 | "name": ".NET Core Attach",
20 | "type": "coreclr",
21 | "request": "attach"
22 | }
23 | ]
24 | }
--------------------------------------------------------------------------------
/Boots.Core/PkgInstaller.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | namespace Boots.Core
7 | {
8 | class PkgInstaller : Installer
9 | {
10 | public PkgInstaller (Bootstrapper boots) : base (boots) { }
11 |
12 | public override string Extension => ".pkg";
13 |
14 | public async override Task Install (string file, CancellationToken token = default)
15 | {
16 | if (string.IsNullOrEmpty (file))
17 | throw new ArgumentException (nameof (file));
18 | if (!File.Exists (file))
19 | throw new FileNotFoundException ($"{Extension} file did not exist: {file}", file);
20 |
21 | using var proc = new AsyncProcess (Boots) {
22 | Command = "/usr/sbin/installer",
23 | Arguments = $"-verbose -dumplog -pkg \"{file}\" -target /",
24 | Elevate = true,
25 | };
26 | await proc.RunAsync (token);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Boots.Core/Installer.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 |
5 | namespace Boots.Core
6 | {
7 | abstract class Installer
8 | {
9 | protected readonly Bootstrapper Boots;
10 |
11 | public Installer (Bootstrapper boots)
12 | {
13 | Boots = boots;
14 | }
15 |
16 | public abstract string Extension { get; }
17 |
18 | public abstract Task Install (string file, CancellationToken token = new CancellationToken ());
19 |
20 | protected async Task PrintLogFileAndDelete (string log, CancellationToken token)
21 | {
22 | if (File.Exists (log)) {
23 | using (var reader = File.OpenText (log)) {
24 | while (!reader.EndOfStream && !token.IsCancellationRequested) {
25 | Boots.Logger.WriteLine (await reader.ReadLineAsync ());
26 | }
27 | }
28 | File.Delete (log);
29 | } else {
30 | Boots.Logger.WriteLine ($"Log file did not exist: {log}");
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Boots.Tests/InstallerTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using Boots.Core;
5 | using Xunit;
6 |
7 | namespace Boots.Tests
8 | {
9 | public class InstallerTests
10 | {
11 | [Theory]
12 | [InlineData (typeof (VsixInstaller))]
13 | [InlineData (typeof (PkgInstaller))]
14 | [InlineData (typeof (MsiInstaller))]
15 | public async Task NoFilePath (Type type)
16 | {
17 | var installer = (Installer) Activator.CreateInstance (type, new Bootstrapper ());
18 | await Assert.ThrowsAsync (() => installer.Install (null));
19 | }
20 |
21 | [Theory]
22 | [InlineData (typeof (VsixInstaller))]
23 | [InlineData (typeof (PkgInstaller))]
24 | [InlineData (typeof (MsiInstaller))]
25 | public async Task FileDoesNotExist (Type type)
26 | {
27 | var installer = (Installer) Activator.CreateInstance (type, new Bootstrapper ());
28 | await Assert.ThrowsAsync (() => installer.Install ("asdf"));
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Boots.Core/MsiInstaller.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | namespace Boots.Core
7 | {
8 | class MsiInstaller : Installer
9 | {
10 | public MsiInstaller (Bootstrapper boots) : base (boots) { }
11 |
12 | public override string Extension => ".msi";
13 |
14 | public async override Task Install (string file, CancellationToken token = default)
15 | {
16 | if (string.IsNullOrEmpty (file))
17 | throw new ArgumentException (nameof (file));
18 | if (!File.Exists (file))
19 | throw new FileNotFoundException ($"{Extension} file did not exist: {file}", file);
20 |
21 | var log = Path.GetTempFileName ();
22 | try {
23 | using var proc = new AsyncProcess (Boots) {
24 | Command = "msiexec",
25 | Arguments = $"/i \"{file}\" /qn /L*V \"{log}\"",
26 | Elevate = true,
27 | };
28 | await proc.RunAsync (token);
29 | } finally {
30 | await PrintLogFileAndDelete (log, token);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Boots.Core/Downloader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net.Http;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | namespace Boots.Core
8 | {
9 | public class Downloader : IDisposable
10 | {
11 | readonly Bootstrapper boots;
12 | readonly Uri uri;
13 |
14 | public Downloader (Bootstrapper boots, string extension = "")
15 | {
16 | this.boots = boots;
17 | uri = new Uri (boots.Url);
18 |
19 | TempFile = Path.Combine (Path.GetTempPath (), Path.GetRandomFileName () + extension);
20 | }
21 |
22 | public string TempFile { get; private set; }
23 |
24 | public async Task Download (CancellationToken token = new CancellationToken ())
25 | {
26 | boots.Logger.WriteLine ($"Downloading {uri}");
27 | using var client = new HttpClientWithPolicy (boots);
28 | await client.DownloadAsync (uri, TempFile, token);
29 | }
30 |
31 | public void Dispose ()
32 | {
33 | if (File.Exists (TempFile)) {
34 | boots.Logger.WriteLine ($"Deleting {TempFile}");
35 | File.Delete (TempFile);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 |
2 | # https://aka.ms/yaml
3 |
4 | name: $(BuildID)
5 |
6 | trigger:
7 | - main
8 |
9 | variables:
10 | Configuration: Release
11 | BootsVersion: 1.1.0
12 | BootsSuffix: ''
13 | PackageVersion: $(BootsVersion).$(Build.BuildNumber)$(BootsSuffix)
14 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
15 | DOTNET_CLI_TELEMETRY_OPTOUT: true
16 |
17 | jobs:
18 |
19 | - job: windows
20 | pool:
21 | vmImage: windows-2022
22 | demands: msbuild
23 | steps:
24 |
25 | - template: scripts/build-and-test.yaml
26 | parameters:
27 | name: windows
28 |
29 | - powershell: dotnet cake
30 | displayName: Cake test
31 | workingDirectory: Cake.Boots
32 |
33 | - job: mac
34 | pool:
35 | vmImage: macOS-latest
36 | demands: msbuild
37 | steps:
38 |
39 | - script: echo '##vso[task.setvariable variable=JI_JAVA_HOME]$(JAVA_HOME_11_X64)'
40 | displayName: set JI_JAVA_HOME
41 |
42 | - template: scripts/build-and-test.yaml
43 | parameters:
44 | name: mac
45 |
46 | - bash: dotnet cake --target=Mono && dotnet cake
47 | workingDirectory: Cake.Boots
48 | displayName: Cake test
49 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Jonathan Peppers
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace HelloForms.iOS
9 | {
10 | // The UIApplicationDelegate for the application. This class is responsible for launching the
11 | // User Interface of the application, as well as listening (and optionally responding) to
12 | // application events from iOS.
13 | [Register("AppDelegate")]
14 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
15 | {
16 | //
17 | // This method is invoked when the application has loaded and is ready to run. In this
18 | // method you should instantiate the window, load the UI into it and then make the window
19 | // visible.
20 | //
21 | // You have 17 seconds to return from this method, or iOS will terminate your application.
22 | //
23 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
24 | {
25 | global::Xamarin.Forms.Forms.Init();
26 | LoadApplication(new App());
27 |
28 | return base.FinishedLaunching(app, options);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/boots.sln",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/boots.sln",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "--project",
36 | "${workspaceFolder}/boots.sln"
37 | ],
38 | "problemMatcher": "$msCompile"
39 | }
40 | ]
41 | }
--------------------------------------------------------------------------------
/samples/HelloForms.Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Android.App;
4 | using Android.Content.PM;
5 | using Android.Runtime;
6 | using Android.Views;
7 | using Android.Widget;
8 | using Android.OS;
9 |
10 | namespace HelloForms.Droid
11 | {
12 | [Activity(Label = "HelloForms", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
13 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
14 | {
15 | protected override void OnCreate(Bundle savedInstanceState)
16 | {
17 | base.OnCreate(savedInstanceState);
18 |
19 | Xamarin.Essentials.Platform.Init(this, savedInstanceState);
20 | global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
21 | LoadApplication(new App());
22 | }
23 |
24 | public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
25 | {
26 | Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
27 |
28 | base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.github/workflows/actions.yml:
--------------------------------------------------------------------------------
1 | name: GitHub Actions
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 | branches:
9 | - main
10 | paths:
11 | - '.github/**'
12 |
13 | jobs:
14 | macOS:
15 | runs-on: macOS-latest
16 | env:
17 | DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
18 | steps:
19 | - uses: actions/checkout@v1
20 | - uses: actions/setup-dotnet@v1
21 | with:
22 | dotnet-version: '3.0.x'
23 | - name: build
24 | shell: bash
25 | run: |
26 | export PATH="$PATH:~/.dotnet/tools"
27 | dotnet tool install --global boots
28 | boots --preview Mono
29 | boots --preview XamarinAndroid
30 | export JI_JAVA_HOME="$JAVA_HOME_11_X64"
31 | msbuild ./samples/HelloForms.Android/HelloForms.Android.csproj /restore /t:SignAndroidPackage
32 |
33 | windows:
34 | runs-on: windows-latest
35 | env:
36 | DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
37 | steps:
38 | - uses: actions/checkout@v1
39 | - uses: microsoft/setup-msbuild@v1.0.2
40 | - name: build
41 | shell: pwsh
42 | run: |
43 | dotnet tool install --global boots
44 | boots --preview XamarinAndroid
45 | msbuild ./samples/HelloForms.Android/HelloForms.Android.csproj /restore /t:SignAndroidPackage
46 |
--------------------------------------------------------------------------------
/bitrise.yml:
--------------------------------------------------------------------------------
1 | ---
2 | format_version: '8'
3 | default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
4 | project_type: xamarin
5 | trigger_map:
6 | - push_branch: main
7 | workflow: primary
8 | workflows:
9 | primary:
10 | steps:
11 | - activate-ssh-key@4.0.5:
12 | run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
13 | - git-clone@4.0.25: {}
14 | - set-java-version@1:
15 | inputs:
16 | - set_java_version: '8'
17 | - android-sdk-update@1:
18 | inputs:
19 | - sdk_version: '30'
20 | - script@1.1.6:
21 | title: Do anything with Script step
22 | inputs:
23 | - content: |-
24 | #!/usr/bin/env bash
25 | set -e
26 | set -x
27 | dotnet tool install --global boots
28 | boots --stable Mono
29 | boots --preview Xamarin.Android
30 | msbuild ./samples/HelloForms.Android/HelloForms.Android.csproj -restore -t:SignAndroidPackage
31 | - deploy-to-bitrise-io@1.12.0: {}
32 | app:
33 | envs:
34 | - opts:
35 | is_expand: false
36 | BITRISE_PROJECT_PATH: samples/HelloForms.sln
37 | - opts:
38 | is_expand: false
39 | BITRISE_XAMARIN_CONFIGURATION: Release
40 | - opts:
41 | is_expand: false
42 | BITRISE_XAMARIN_PLATFORM: Any CPU
43 |
--------------------------------------------------------------------------------
/Boots.Tests/DownloaderTests.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Threading.Tasks;
3 | using Boots.Core;
4 | using Xunit;
5 |
6 | namespace Boots.Tests
7 | {
8 | public class DownloaderTests
9 | {
10 | [Fact]
11 | public async Task Get ()
12 | {
13 | string tempFile;
14 | using (var downloader = new Downloader (new Bootstrapper {
15 | Url = "http://httpbin.org/json",
16 | })) {
17 | tempFile = downloader.TempFile;
18 | Assert.False (File.Exists (tempFile), $"{tempFile} should *not* exist!");
19 | await downloader.Download ();
20 | Assert.True (File.Exists (tempFile), $"{tempFile} should exist!");
21 | }
22 | Assert.False (File.Exists (tempFile), $"{tempFile} should *not* exist!");
23 | }
24 |
25 | [Fact]
26 | public void VsixFilePath ()
27 | {
28 | var downloader = new Downloader (new Bootstrapper {
29 | Url = "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/VisualStudioProductTeam/vsextensions/ProjectSystemTools/1.0.1.1927902/vspackage"
30 | }, ".vsix");
31 | Assert.Equal (".vsix", Path.GetExtension (downloader.TempFile));
32 | }
33 |
34 | [Fact]
35 | public void PkgFilePath ()
36 | {
37 | var downloader = new Downloader (new Bootstrapper {
38 | Url = "https://aka.ms/objective-sharpie"
39 | }, ".pkg");
40 | Assert.Equal (".pkg", Path.GetExtension (downloader.TempFile));
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using Android.App;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("HelloForms.Android")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("HelloForms.Android")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ComVisible(false)]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
32 | // Add some common permissions, these can be removed if not needed
33 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
34 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
35 |
--------------------------------------------------------------------------------
/Boots.Tests/MainTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Threading.Tasks;
5 | using Xunit;
6 |
7 | namespace Boots.Tests
8 | {
9 | public class MainTests : IDisposable
10 | {
11 | const string DefaultErrorMessage = "At least one of --url, --stable, --preview, or --alpha must be used";
12 | readonly TextWriter consoleError;
13 | readonly StringWriter stderr;
14 | readonly MethodInfo main;
15 |
16 | public MainTests ()
17 | {
18 | consoleError = Console.Error;
19 | Console.SetError (stderr = new StringWriter ());
20 |
21 | var program = Type.GetType ("Boots.Program, Boots", throwOnError: true);
22 | main = program.GetMethod ("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
23 | Assert.NotNull (main);
24 | }
25 |
26 | public void Dispose ()
27 | {
28 | Console.SetError (consoleError);
29 | }
30 |
31 | [Fact]
32 | public async Task Empty ()
33 | {
34 | var args = Array.Empty ();
35 | var task = (Task) main.Invoke (null, new object [] { args });
36 | await task;
37 | Assert.Contains (DefaultErrorMessage, stderr.ToString ());
38 | }
39 |
40 | [Fact]
41 | public async Task Stable ()
42 | {
43 | var args = new [] { "--stable", "Xamarin.Android" };
44 | var task = (Task) main.Invoke (null, new object [] { args });
45 | await task;
46 | Assert.DoesNotContain (DefaultErrorMessage, stderr.ToString ());
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(PackageId)
5 | true
6 | $(MSBuildThisFileDirectory)bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | all
20 | runtime; build; native; contentfiles; analyzers; buildtransitive
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Boots.Tests/AsyncProcessTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 | using Boots.Core;
6 | using Xunit;
7 | using Xunit.Abstractions;
8 |
9 | namespace Boots.Tests
10 | {
11 | public class AsyncProcessTests
12 | {
13 | readonly Bootstrapper boots = new Bootstrapper ();
14 |
15 | public AsyncProcessTests (ITestOutputHelper output)
16 | {
17 | boots.Logger = new TestWriter (output);
18 | }
19 |
20 | [SkippableFact]
21 | public async Task EchoShouldNotThrow ()
22 | {
23 | using (var proc = new AsyncProcess (boots) {
24 | Command = Helpers.IsWindows ? "cmd" : "echo",
25 | Arguments = Helpers.IsWindows ? "/C echo test" : "test"
26 | }) {
27 | await proc.RunAsync (new CancellationToken ());
28 | }
29 | }
30 |
31 | [Fact]
32 | public async Task NonExistingCommandShouldThrow ()
33 | {
34 | using (var proc = new AsyncProcess (boots) {
35 | Command = Guid.NewGuid ().ToString ()
36 | }) {
37 | await Assert.ThrowsAsync (() => proc.RunAsync (new CancellationToken ()));
38 | }
39 | }
40 |
41 | [Fact]
42 | public async Task RunWithOutput ()
43 | {
44 | using (var proc = new AsyncProcess (boots) {
45 | Command = Helpers.IsWindows ? "cmd" : "echo",
46 | Arguments = Helpers.IsWindows ? "/C echo test" : "test"
47 | }) {
48 | var text = await proc.RunWithOutputAsync (new CancellationToken ());
49 | Assert.Equal ("test", text.Trim ());
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1.1.0
4 |
5 |
6 | $(BUILD_BUILDNUMBER)
7 | 1
8 | $(BootsVersion).$(BuildNumber)
9 | $(BootsVersion).$(BuildNumber)
10 | $(BootsVersion).$(BuildNumber)$(BootsSuffix)
11 | Jonathan Peppers, Peter Collins
12 | $([System.DateTime]::Now.Year) $(Authors)
13 | icon.png
14 | LICENSE
15 | https://github.com/jonathanpeppers/boots
16 | Bootstrap CI Xamarin Cake Azure DevOps
17 | boots is a dotnet global tool for "bootstrapping" vsix & pkg files.
18 | latest
19 | enable
20 | true
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UISupportedInterfaceOrientations
11 |
12 | UIInterfaceOrientationPortrait
13 | UIInterfaceOrientationLandscapeLeft
14 | UIInterfaceOrientationLandscapeRight
15 |
16 | UISupportedInterfaceOrientations~ipad
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationPortraitUpsideDown
20 | UIInterfaceOrientationLandscapeLeft
21 | UIInterfaceOrientationLandscapeRight
22 |
23 | MinimumOSVersion
24 | 8.0
25 | CFBundleDisplayName
26 | HelloForms
27 | CFBundleIdentifier
28 | com.companyname.HelloForms
29 | CFBundleVersion
30 | 1.0
31 | UILaunchStoryboardName
32 | LaunchScreen
33 | CFBundleName
34 | HelloForms
35 | XSAppIconAssets
36 | Assets.xcassets/AppIcon.appiconset
37 |
38 |
39 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
26 |
27 |
30 |
31 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("HelloForms.iOS")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("HelloForms.iOS")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/scripts/build-and-test.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | name: ''
3 | xaversion: 13.2
4 | steps:
5 |
6 | - task: UseDotNet@2
7 | displayName: install .NET 6
8 | inputs:
9 | version: 6.0.x
10 |
11 | - script: dotnet tool update --global Cake.Tool
12 | displayName: install Cake
13 |
14 | - script: dotnet build boots.sln -bl:$(System.DefaultWorkingDirectory)/bin/build.binlog
15 | displayName: dotnet build
16 |
17 | - script: dotnet test Boots.Tests/bin/$(Configuration)/net6.0/Boots.Tests.dll --logger:"trx;verbosity=normal" --logger:"console;verbosity=normal"
18 | displayName: dotnet test
19 |
20 | - task: PublishTestResults@2
21 | displayName: publish test results
22 | inputs:
23 | testResultsFormat: VSTest
24 | testResultsFiles: TestResults/*.trx
25 | testRunTitle: ${{ parameters.name }}
26 | failTaskOnFailedTests: true
27 | condition: succeededOrFailed()
28 |
29 | - script: dotnet Boots/bin/$(Configuration)/netcoreapp3.1/Boots.dll --alpha Xamarin.Android
30 | displayName: install xamarin-android
31 |
32 | - task: MSBuild@1
33 | displayName: verify
34 | inputs:
35 | solution: scripts/xa-version.targets
36 | msbuildArguments: '/v:minimal /nologo /t:Check /p:Expected=${{ parameters.xaversion }} /bl:$(System.DefaultWorkingDirectory)/bin/verify.binlog'
37 |
38 | - task: MSBuild@1
39 | displayName: build sample
40 | inputs:
41 | solution: samples/HelloForms.Android/HelloForms.Android.csproj
42 | msbuildArguments: '/restore /t:SignAndroidPackage /p:AndroidPackageFormat=aab /bl:$(System.DefaultWorkingDirectory)/bin/sample.binlog'
43 |
44 | - task: PublishPipelineArtifact@0
45 | displayName: artifacts
46 | inputs:
47 | artifactName: ${{ parameters.name }}
48 | targetPath: bin
49 | condition: succeededOrFailed()
50 |
--------------------------------------------------------------------------------
/samples/HelloForms.Android/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.xml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable-hdpi/
12 | icon.png
13 |
14 | drawable-ldpi/
15 | icon.png
16 |
17 | drawable-mdpi/
18 | icon.png
19 |
20 | layout/
21 | main.xml
22 |
23 | values/
24 | strings.xml
25 |
26 | In order to get the build system to recognize Android resources, set the build action to
27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
28 | instead operate on resource IDs. When you compile an Android application that uses resources,
29 | the build system will package the resources for distribution and generate a class called
30 | "Resource" that contains the tokens for each one of the resources included. For example,
31 | for the above Resources layout, this is what the Resource class would expose:
32 |
33 | public class Resource {
34 | public class drawable {
35 | public const int icon = 0x123;
36 | }
37 |
38 | public class layout {
39 | public const int main = 0x456;
40 | }
41 |
42 | public class strings {
43 | public const int first_string = 0xabc;
44 | public const int second_string = 0xbcd;
45 | }
46 | }
47 |
48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50 | string in the dictionary file values/strings.xml.
51 |
--------------------------------------------------------------------------------
/Cake.Boots/Cake.Boots.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | Cake.Boots
6 | true
7 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
8 | <_NuGetPackagePath>lib\$(TargetFramework)
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Cake.Boots/build.cake:
--------------------------------------------------------------------------------
1 | var target = Argument("target", "Default");
2 |
3 | // NOTE: only Release builds work
4 | #r "bin/Release/netstandard2.0/Cake.Boots.dll"
5 |
6 | // NOTE: always update Mono in a separate process, run Cake twice.
7 | Task("Mono")
8 | .Does(async () =>
9 | {
10 | await Boots (Product.Mono, ReleaseChannel.Preview);
11 | });
12 |
13 | Task("Boots")
14 | .Does(async () =>
15 | {
16 | string vs = Environment.GetEnvironmentVariable("AGENT_JOBNAME") == "vs2019" ? "2019" : "2022";
17 | var url = IsRunningOnWindows() ?
18 | $"https://github.com/codecadwallader/codemaid/releases/download/v12.0/CodeMaid.VS{vs}.v12.0.300.vsix" :
19 | "https://aka.ms/objective-sharpie";
20 |
21 | await Boots (url);
22 |
23 | if (IsRunningOnWindows()) {
24 | // Install a Firefox .msi twice
25 | var firefox = "https://download-installer.cdn.mozilla.net/pub/firefox/releases/82.0/win64/en-US/Firefox%20Setup%2082.0.msi";
26 | await Boots (firefox);
27 | await Boots (firefox, fileType: FileType.msi);
28 | } else {
29 | // Let's really run through the gauntlet and install 6 .pkg files
30 | await Boots (Product.XamariniOS, ReleaseChannel.Stable);
31 | await Boots (Product.XamarinMac, ReleaseChannel.Stable);
32 | await Boots (Product.XamariniOS, ReleaseChannel.Preview);
33 | await Boots (Product.XamarinMac, ReleaseChannel.Preview);
34 | await Boots (Product.XamariniOS, ReleaseChannel.Alpha);
35 | await Boots (Product.XamarinMac, ReleaseChannel.Alpha);
36 |
37 | var settings = new BootsSettings {
38 | Channel = ReleaseChannel.Stable,
39 | Product = Product.XamarinAndroid,
40 | Timeout = TimeSpan.FromSeconds (200),
41 | ReadWriteTimeout = TimeSpan.FromMinutes (10),
42 | NetworkRetries = 1,
43 | };
44 | await Boots (settings);
45 | settings.Channel = ReleaseChannel.Preview;
46 | await Boots (settings);
47 | settings.Channel = ReleaseChannel.Alpha;
48 | await Boots (settings);
49 | }
50 | });
51 |
52 | Task("Default")
53 | .IsDependentOn("Boots");
54 |
55 | RunTarget(target);
56 |
--------------------------------------------------------------------------------
/Boots.Tests/BootstrapperTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Boots.Core;
4 | using Xunit;
5 | using Xunit.Abstractions;
6 |
7 | namespace Boots.Tests
8 | {
9 | public class BootstrapperTests
10 | {
11 | readonly Bootstrapper boots = new Bootstrapper ();
12 |
13 | public BootstrapperTests (ITestOutputHelper output)
14 | {
15 | boots.Logger = new TestWriter (output);
16 | }
17 |
18 | string GetCodeMaidUrl()
19 | {
20 | string vs = Environment.GetEnvironmentVariable("AGENT_JOBNAME") == "vs2019" ? "2019" : "2022";
21 | return $"https://github.com/codecadwallader/codemaid/releases/download/v12.0/CodeMaid.VS{vs}.v12.0.300.vsix";
22 | }
23 |
24 | [SkippableFact]
25 | public async Task SimpleInstall ()
26 | {
27 | if (Helpers.IsWindows) {
28 | boots.Url = GetCodeMaidUrl();
29 | } else if (Helpers.IsMac) {
30 | boots.Url = "https://aka.ms/objective-sharpie";
31 | } else {
32 | Skip.If (true, "Not supported on Linux yet");
33 | }
34 | await boots.Install ();
35 | // Two installs back-to-back should be fine
36 | await boots.Install ();
37 | }
38 |
39 | [SkippableFact]
40 | public async Task DowngradeFirst ()
41 | {
42 | Skip.If (!Helpers.IsWindows, "DowngradeFirst is only applicable on Windows");
43 | boots.Url = GetCodeMaidUrl();
44 | await boots.Install ();
45 | // NOTE: this only does something for .vsix files on Windows
46 | boots.DowngradeFirst = true;
47 | await boots.Install ();
48 | }
49 |
50 | [SkippableFact]
51 | public async Task InstallMsi ()
52 | {
53 | Skip.If (!Helpers.IsWindows, ".msis are only supported on Windows");
54 | boots.FileType = FileType.msi;
55 | boots.Url = "https://download-installer.cdn.mozilla.net/pub/firefox/releases/82.0/win64/en-US/Firefox%20Setup%2082.0.msi";
56 | await boots.Install ();
57 | // Two installs back-to-back should be fine
58 | await boots.Install ();
59 | }
60 |
61 | [SkippableFact]
62 | public async Task InvalidInstallerFile ()
63 | {
64 | Skip.If (!Helpers.IsMac && !Helpers.IsWindows, "Not supported on Linux yet");
65 | boots.Url = "https://i.kym-cdn.com/entries/icons/mobile/000/018/012/this_is_fine.jpg";
66 | await Assert.ThrowsAsync (() => boots.Install ());
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Boots.Core/MacUrlResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 | using System.Xml;
6 |
7 | namespace Boots.Core
8 | {
9 | class MacUrlResolver : UrlResolver
10 | {
11 | const string Url = "https://software.xamarin.com/Service/Updates?v=2&pv964ebddd-1ffe-47e7-8128-5ce17ffffb05=0&pv4569c276-1397-4adb-9485-82a7696df22e=0&pvd1ec039f-f3db-468b-a508-896d7c382999=0&pv0ab364ff-c0e9-43a8-8747-3afb02dc7731=0&level=";
12 | static readonly Dictionary ProductIds = new Dictionary {
13 | { Product.Mono, "964ebddd-1ffe-47e7-8128-5ce17ffffb05" },
14 | { Product.XamarinAndroid, "d1ec039f-f3db-468b-a508-896d7c382999" },
15 | { Product.XamariniOS, "4569c276-1397-4adb-9485-82a7696df22e" },
16 | { Product.XamarinMac, "0ab364ff-c0e9-43a8-8747-3afb02dc7731" },
17 | };
18 |
19 | public MacUrlResolver (Bootstrapper boots) : base (boots) { }
20 |
21 | public async override Task Resolve (ReleaseChannel channel, Product product, CancellationToken token = new CancellationToken ())
22 | {
23 | using var httpClient = new HttpClientWithPolicy (Boots);
24 | string level = GetLevel (channel);
25 | string productId = GetProductId (product);
26 |
27 | var uri = new Uri (Url + level);
28 | Boots.Logger.WriteLine ($"Querying {uri}");
29 |
30 | var document = await httpClient.GetXmlDocumentAsync (uri, token);
31 | var node = document.SelectSingleNode ($"/UpdateInfo/Application[@id='{productId}']/Update/@url");
32 | if (node == null) {
33 | throw new XmlException ($"Did not find {product}, at channel {channel}");
34 | }
35 |
36 | string url = node.InnerText;
37 | if (string.IsNullOrEmpty (url)) {
38 | throw new XmlException ($"Did not find {product}, at channel {channel}");
39 | }
40 |
41 | // Just let this throw if it is an invalid Uri
42 | new Uri (url);
43 | return url;
44 | }
45 |
46 | string GetLevel (ReleaseChannel channel)
47 | {
48 | return channel switch {
49 | ReleaseChannel.Stable => "Stable",
50 | ReleaseChannel.Preview => "Beta",
51 | ReleaseChannel.Alpha => "Alpha",
52 | _ => throw new NotImplementedException ($"Unexpected value for release: {channel}"),
53 | };
54 | }
55 |
56 | string GetProductId (Product product)
57 | {
58 | if (!ProductIds.TryGetValue (product, out string id)) {
59 | throw new NotImplementedException ($"Unexpected value for product: {product}");
60 | }
61 | return id;
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Boots.Core/HttpClientWithPolicy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net.Http;
4 | using System.Text.Json;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using System.Xml;
8 |
9 | namespace Boots.Core
10 | {
11 | class HttpClientWithPolicy : IDisposable
12 | {
13 | readonly Bootstrapper boots;
14 | readonly HttpClient client;
15 |
16 | public TimeSpan Timeout => client.Timeout;
17 |
18 | public HttpClientWithPolicy (Bootstrapper boots)
19 | {
20 | this.boots = boots;
21 | client = new HttpClient ();
22 | if (boots.Timeout != null) {
23 | client.Timeout = boots.Timeout.Value;
24 | }
25 | }
26 |
27 | public void Dispose () => client.Dispose ();
28 |
29 | public Task DownloadAsync (Uri uri, string tempFile, CancellationToken token) =>
30 | boots.ActivePolicy.ExecuteAsync (t => DoDownloadAsync (uri, tempFile, t), token);
31 |
32 | protected async virtual Task DoDownloadAsync (Uri uri, string tempFile, CancellationToken token)
33 | {
34 | var request = new HttpRequestMessage (HttpMethod.Get, uri);
35 | var response = await client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead, token);
36 | response.EnsureSuccessStatusCode ();
37 | using var httpStream = await response.Content.ReadAsStreamAsync ();
38 | using var fileStream = File.Create (tempFile);
39 | boots.Logger.WriteLine ($"Writing to {tempFile}");
40 | await httpStream.CopyToAsync (fileStream, 8 * 1024, token);
41 | }
42 |
43 | public virtual Task GetJsonAsync (Uri uri, CancellationToken token) =>
44 | boots.ActivePolicy.ExecuteAsync (t => DoGetJsonAsync (uri, t), token);
45 |
46 | protected async virtual Task DoGetJsonAsync (Uri uri, CancellationToken token)
47 | {
48 | var response = await client.GetAsync (uri, token);
49 | response.EnsureSuccessStatusCode ();
50 | using var stream = await response.Content.ReadAsStreamAsync ();
51 | return await JsonSerializer.DeserializeAsync (stream, cancellationToken: token);
52 | }
53 |
54 | public virtual Task GetXmlDocumentAsync (Uri uri, CancellationToken token) =>
55 | boots.ActivePolicy.ExecuteAsync (t => DoGetXmlDocumentAsync (uri, t), token);
56 |
57 | protected async virtual Task DoGetXmlDocumentAsync (Uri uri, CancellationToken token)
58 | {
59 | var response = await client.GetAsync (uri, token);
60 | response.EnsureSuccessStatusCode ();
61 | var document = new XmlDocument ();
62 | using var stream = await response.Content.ReadAsStreamAsync ();
63 | await Task.Factory.StartNew (() => document.Load (stream), token);
64 | return document;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/boots.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29102.190
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Boots.Core", "Boots.Core\Boots.Core.csproj", "{977D3870-832A-4E80-BB7D-EBADD0C1DE3A}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Boots", "Boots\Boots.csproj", "{5108C889-ABB7-4B95-BAD2-3DF11FDD05EB}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Boots.Tests", "Boots.Tests\Boots.Tests.csproj", "{393FF93B-5A0B-490E-9E28-4B38E579AF7C}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Boots", "Cake.Boots\Cake.Boots.csproj", "{10B653C6-675D-49D1-8BA6-DC62F2131742}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {977D3870-832A-4E80-BB7D-EBADD0C1DE3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {977D3870-832A-4E80-BB7D-EBADD0C1DE3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {977D3870-832A-4E80-BB7D-EBADD0C1DE3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {977D3870-832A-4E80-BB7D-EBADD0C1DE3A}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {5108C889-ABB7-4B95-BAD2-3DF11FDD05EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {5108C889-ABB7-4B95-BAD2-3DF11FDD05EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {5108C889-ABB7-4B95-BAD2-3DF11FDD05EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {5108C889-ABB7-4B95-BAD2-3DF11FDD05EB}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {393FF93B-5A0B-490E-9E28-4B38E579AF7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {393FF93B-5A0B-490E-9E28-4B38E579AF7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {393FF93B-5A0B-490E-9E28-4B38E579AF7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {393FF93B-5A0B-490E-9E28-4B38E579AF7C}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {10B653C6-675D-49D1-8BA6-DC62F2131742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {10B653C6-675D-49D1-8BA6-DC62F2131742}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {10B653C6-675D-49D1-8BA6-DC62F2131742}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {10B653C6-675D-49D1-8BA6-DC62F2131742}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | GlobalSection(ExtensibilityGlobals) = postSolution
41 | SolutionGuid = {72B45E6F-88B9-4166-871D-A0423C6E063E}
42 | EndGlobalSection
43 | EndGlobal
44 |
--------------------------------------------------------------------------------
/Cake.Boots/BootsAddin.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Text;
3 | using System.Threading.Tasks;
4 | using Boots.Core;
5 | using Cake.Core;
6 | using Cake.Core.Annotations;
7 | using Cake.Core.Diagnostics;
8 |
9 | namespace Cake.Boots
10 | {
11 | [CakeAliasCategory("Boots")]
12 | public static class BootsAddin
13 | {
14 | [CakeMethodAlias]
15 | public static async Task Boots (this ICakeContext context, string url, FileType? fileType = default)
16 | {
17 | var boots = new Bootstrapper {
18 | Url = url,
19 | FileType = fileType,
20 | Logger = new CakeWriter (context)
21 | };
22 |
23 | await boots.Install ();
24 | }
25 |
26 | [CakeMethodAlias]
27 | public static async Task Boots (this ICakeContext context, Product product, ReleaseChannel channel = ReleaseChannel.Stable)
28 | {
29 | var boots = new Bootstrapper {
30 | Channel = channel,
31 | Product = product,
32 | Logger = new CakeWriter (context)
33 | };
34 |
35 | await boots.Install ();
36 | }
37 |
38 | [CakeMethodAlias]
39 | public static async Task Boots (this ICakeContext context, BootsSettings settings)
40 | {
41 | var boots = new Bootstrapper {
42 | Logger = new CakeWriter (context)
43 | };
44 |
45 | if (settings.Timeout != null)
46 | boots.Timeout = settings.Timeout;
47 | if (settings.ReadWriteTimeout != null)
48 | boots.ReadWriteTimeout = settings.ReadWriteTimeout.Value;
49 | if (settings.NetworkRetries != null)
50 | boots.NetworkRetries = settings.NetworkRetries.Value;
51 | if (settings.Channel != null)
52 | boots.Channel = settings.Channel.Value;
53 | if (settings.Product != null)
54 | boots.Product = settings.Product.Value;
55 | if (settings.FileType != null)
56 | boots.FileType = settings.FileType;
57 | if (settings.Url != null)
58 | boots.Url = settings.Url;
59 |
60 | await boots.Install ();
61 | }
62 |
63 | class CakeWriter : TextWriter
64 | {
65 | const Verbosity verbosity = Verbosity.Normal;
66 | const LogLevel level = LogLevel.Information;
67 | readonly ICakeContext context;
68 |
69 | public CakeWriter (ICakeContext context)
70 | {
71 | this.context = context;
72 | }
73 |
74 | public override Encoding Encoding => Encoding.Default;
75 |
76 | public override void WriteLine (string value)
77 | {
78 | value ??= "";
79 |
80 | // avoid System.FormatException from string.Format
81 | value = value.Replace ("{", "{{").Replace ("}", "}}");
82 |
83 | context.Log.Write (verbosity, level, value);
84 | }
85 |
86 | public override void WriteLine (string format, params object [] args)
87 | {
88 | context.Log.Write (verbosity, level, format, args);
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Resources/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/samples/HelloForms.iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "scale": "2x",
5 | "size": "20x20",
6 | "idiom": "iphone",
7 | "filename": "Icon40.png"
8 | },
9 | {
10 | "scale": "3x",
11 | "size": "20x20",
12 | "idiom": "iphone",
13 | "filename": "Icon60.png"
14 | },
15 | {
16 | "scale": "2x",
17 | "size": "29x29",
18 | "idiom": "iphone",
19 | "filename": "Icon58.png"
20 | },
21 | {
22 | "scale": "3x",
23 | "size": "29x29",
24 | "idiom": "iphone",
25 | "filename": "Icon87.png"
26 | },
27 | {
28 | "scale": "2x",
29 | "size": "40x40",
30 | "idiom": "iphone",
31 | "filename": "Icon80.png"
32 | },
33 | {
34 | "scale": "3x",
35 | "size": "40x40",
36 | "idiom": "iphone",
37 | "filename": "Icon120.png"
38 | },
39 | {
40 | "scale": "2x",
41 | "size": "60x60",
42 | "idiom": "iphone",
43 | "filename": "Icon120.png"
44 | },
45 | {
46 | "scale": "3x",
47 | "size": "60x60",
48 | "idiom": "iphone",
49 | "filename": "Icon180.png"
50 | },
51 | {
52 | "scale": "1x",
53 | "size": "20x20",
54 | "idiom": "ipad",
55 | "filename": "Icon20.png"
56 | },
57 | {
58 | "scale": "2x",
59 | "size": "20x20",
60 | "idiom": "ipad",
61 | "filename": "Icon40.png"
62 | },
63 | {
64 | "scale": "1x",
65 | "size": "29x29",
66 | "idiom": "ipad",
67 | "filename": "Icon29.png"
68 | },
69 | {
70 | "scale": "2x",
71 | "size": "29x29",
72 | "idiom": "ipad",
73 | "filename": "Icon58.png"
74 | },
75 | {
76 | "scale": "1x",
77 | "size": "40x40",
78 | "idiom": "ipad",
79 | "filename": "Icon40.png"
80 | },
81 | {
82 | "scale": "2x",
83 | "size": "40x40",
84 | "idiom": "ipad",
85 | "filename": "Icon80.png"
86 | },
87 | {
88 | "scale": "1x",
89 | "size": "76x76",
90 | "idiom": "ipad",
91 | "filename": "Icon76.png"
92 | },
93 | {
94 | "scale": "2x",
95 | "size": "76x76",
96 | "idiom": "ipad",
97 | "filename": "Icon152.png"
98 | },
99 | {
100 | "scale": "2x",
101 | "size": "83.5x83.5",
102 | "idiom": "ipad",
103 | "filename": "Icon167.png"
104 | },
105 | {
106 | "scale": "1x",
107 | "size": "1024x1024",
108 | "idiom": "ios-marketing",
109 | "filename": "Icon1024.png"
110 | }
111 | ],
112 | "properties": {},
113 | "info": {
114 | "version": 1,
115 | "author": "xcode"
116 | }
117 | }
--------------------------------------------------------------------------------
/Boots.Core/Bootstrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net.Http;
4 | using System.Runtime.CompilerServices;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using Polly;
8 | using Polly.Timeout;
9 |
10 | [assembly: InternalsVisibleTo ("Boots.Tests")]
11 |
12 | namespace Boots.Core
13 | {
14 | public class Bootstrapper
15 | {
16 | public TimeSpan? Timeout { get; set; }
17 |
18 | public TimeSpan ReadWriteTimeout { get; set; } = TimeSpan.FromMinutes (5);
19 |
20 | public int NetworkRetries { get; set; } = 3;
21 |
22 | public ReleaseChannel? Channel { get; set; }
23 |
24 | public Product? Product { get; set; }
25 |
26 | public FileType? FileType { get; set; }
27 |
28 | public string Url { get; set; } = "";
29 |
30 | public bool DowngradeFirst { get; set; }
31 |
32 | public TextWriter Logger { get; set; } = Console.Out;
33 |
34 | internal AsyncPolicy ActivePolicy { get; set; } = Policy.NoOpAsync ();
35 |
36 | internal void UpdateActivePolicy ()
37 | {
38 | ActivePolicy = Policy
39 | .Handle ()
40 | .Or ()
41 | .Or ()
42 | .RetryAsync (NetworkRetries,
43 | (exc, count) => Logger.WriteLine ($"Retry attempt {count}: {exc}"))
44 | .WrapAsync (Policy.TimeoutAsync (ReadWriteTimeout));
45 | }
46 |
47 | public async Task Install (CancellationToken token = new CancellationToken ())
48 | {
49 | UpdateActivePolicy ();
50 |
51 | if (string.IsNullOrEmpty (Url)) {
52 | if (Channel == null)
53 | throw new ArgumentNullException (nameof (Channel));
54 | if (Product == null)
55 | throw new ArgumentNullException (nameof (Product));
56 |
57 | var resolver = Helpers.IsMac ?
58 | (UrlResolver) new MacUrlResolver (this) :
59 | (UrlResolver) new WindowsUrlResolver (this);
60 | Url = await resolver.Resolve (Channel.Value, Product.Value);
61 | }
62 |
63 | Installer installer;
64 | if (Helpers.IsMac) {
65 | installer = new PkgInstaller (this);
66 | } else if (Helpers.IsWindows) {
67 | if (FileType == null) {
68 | if (Url.EndsWith (".msi", StringComparison.OrdinalIgnoreCase)) {
69 | FileType = global::FileType.msi;
70 | Logger.WriteLine ("Inferring .msi from URL.");
71 | } else if (Url.EndsWith (".vsix", StringComparison.OrdinalIgnoreCase)) {
72 | FileType = global::FileType.vsix;
73 | Logger.WriteLine ("Inferring .vsix from URL.");
74 | }
75 | }
76 | if (FileType == global::FileType.msi) {
77 | installer = new MsiInstaller (this);
78 | } else {
79 | installer = new VsixInstaller (this);
80 | }
81 | } else {
82 | throw new NotSupportedException ("Unsupported platform, neither macOS or Windows detected.");
83 | }
84 |
85 | using var downloader = new Downloader (this, installer.Extension);
86 | await downloader.Download (token);
87 | await installer.Install (downloader.TempFile, token);
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/docs/HowToFindBuilds.md:
--------------------------------------------------------------------------------
1 | # How To Find Builds
2 |
3 | Boots is all about specifying the version of Xamarin / Mono you want to use, but how do you find out about the available versions and where do you get them from?
4 |
5 | ## Latest Builds
6 |
7 | To use the latest stable / preview builds you can simply use boots, by passing in the following arguments:
8 |
9 | | Argument | Description |
10 | |-------------|---------------------------------|
11 | | `--stable` | Uses the latest stable version |
12 | | `--preview` | Uses the latest preview version |
13 |
14 | ```
15 | boots --stable Mono
16 | boots --stable Xamarin.Android
17 | boots --stable Xamarin.iOS
18 | boots --stable Xamarin.Mac
19 | ```
20 |
21 | > Note: this feature is only availale for boots versions 1.0.2.X onwards
22 |
23 |
24 | ## Manual Builds
25 |
26 | If you want to specify a specific version to use, you will have to find the specific package url that you wish to use. The package urls are different for every platform.
27 |
28 | ### Mono
29 |
30 | The latest Mono version can be found on [Mono Downloads](https://www.mono-project.com/download/stable/). Head over to the page and copy the link address for the channel you wish to use:
31 |
32 | 
33 |
34 | The link should look similar to:
35 |
36 | **Mono Version 6.12.0**
37 |
38 | ```
39 | https://download.mono-project.com/archive/6.10.0/macos-10-universal/MonoFramework-MDK-6.10.0.104.macos10.xamarin.universal.pkg
40 | ```
41 |
42 |
43 |
44 | ### Xamarin.Android
45 |
46 | To find the available Xamarin.Android versions you will need to head over to the official [Xamarin.Android repository](https://github.com/xamarin/xamarin-android). You can find the available versions in the [downloads](https://github.com/xamarin/xamarin-android#Downloads) section of the [README.md](https://github.com/xamarin/xamarin-android/blob/master/README.md).
47 |
48 | 
49 |
50 | The link should look similar to:
51 |
52 | **Commercial Xamarin.Android 11.0 (d16-7) for Windows**
53 |
54 | ```
55 | https://aka.ms/xamarin-android-commercial-d16-7-windows
56 | ```
57 |
58 |
59 |
60 |
61 |
62 | ### Xamarin.iOS & Xamarin.Mac
63 |
64 | To find the available Xamarin.iOS / Xamarin.Mac versions you will need to head over to the official [Xamarin.iOS & Xamarin.Mac repository](https://github.com/xamarin/xamarin-macios). You can find the available versions in the [downloads](https://github.com/xamarin/xamarin-macios#downloads) section of the [README.md](https://github.com/xamarin/xamarin-macios/blob/main/README.md).
65 |
66 | 
67 |
68 | Select the version you wish to install & copy the link.
69 |
70 | The link should look similar to:
71 |
72 | **Xamarin.iOS d16.7**
73 |
74 | ```
75 | https://download.visualstudio.microsoft.com/download/pr/c939bb72-556b-4e8a-a9b4-0f90e9b5e336/f906a6ce183fb73f1bcd945ac32f984b/xamarin.ios-14.0.0.0.pkg
76 | ```
77 |
--------------------------------------------------------------------------------
/Boots.Tests/UrlResolverTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using System.Threading.Tasks;
4 | using Boots.Core;
5 | using Xunit;
6 |
7 | namespace Boots.Tests
8 | {
9 | public class UrlResolverTests
10 | {
11 | HttpClient client = new HttpClient ();
12 |
13 | [Theory]
14 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Stable, Product.XamarinAndroid)]
15 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Stable, Product.XamariniOS)]
16 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Stable, Product.XamarinMac)]
17 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Stable, Product.Mono)]
18 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Preview, Product.XamarinAndroid)]
19 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Preview, Product.XamariniOS)]
20 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Preview, Product.XamarinMac)]
21 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Preview, Product.Mono)]
22 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Alpha, Product.XamarinAndroid)]
23 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Alpha, Product.XamariniOS)]
24 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Alpha, Product.XamarinMac)]
25 | [InlineData (typeof (MacUrlResolver), ReleaseChannel.Alpha, Product.Mono)]
26 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Stable, Product.XamarinAndroid)]
27 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Preview, Product.XamarinAndroid)]
28 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Alpha, Product.XamarinAndroid)]
29 |
30 | public async Task Resolve (Type type, ReleaseChannel channel, Product product)
31 | {
32 | var resolver = (UrlResolver) Activator.CreateInstance (type, new Bootstrapper ());
33 | var url = await resolver.Resolve (channel, product);
34 | var response = await client.GetAsync (url, HttpCompletionOption.ResponseHeadersRead);
35 | response.EnsureSuccessStatusCode ();
36 | }
37 |
38 | [Theory]
39 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Stable, Product.XamariniOS)]
40 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Stable, Product.XamarinMac)]
41 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Stable, Product.Mono)]
42 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Preview, Product.XamariniOS)]
43 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Preview, Product.XamarinMac)]
44 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Preview, Product.Mono)]
45 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Alpha, Product.XamariniOS)]
46 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Alpha, Product.XamarinMac)]
47 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Alpha, Product.Mono)]
48 | [InlineData (typeof (WindowsUrlResolver), (ReleaseChannel) 9999, Product.Mono)]
49 | [InlineData (typeof (WindowsUrlResolver), ReleaseChannel.Preview, (Product) 9999)]
50 |
51 | public async Task NotImplemented (Type type, ReleaseChannel channel, Product product)
52 | {
53 | var resolver = (UrlResolver) Activator.CreateInstance (type, new Bootstrapper ());
54 | await Assert.ThrowsAsync (() => resolver.Resolve (channel, product));
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Boots.Core/AsyncProcess.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Text;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | namespace Boots.Core
8 | {
9 | class AsyncProcess : IDisposable
10 | {
11 | readonly Bootstrapper boots;
12 |
13 | public string Command { get; set; } = "";
14 | public string Arguments { get; set; } = "";
15 | public bool Elevate { get; set; } = false;
16 |
17 | Process? process;
18 |
19 | public AsyncProcess (Bootstrapper boots)
20 | {
21 | this.boots = boots;
22 | }
23 |
24 | public AsyncProcess (Bootstrapper boots, string cmd, params string [] argumentList)
25 | : this (boots)
26 | {
27 | Command = cmd;
28 | Arguments = string.Join (" ", argumentList);
29 | }
30 |
31 | Process CreateProcess ()
32 | {
33 | if (!Helpers.IsWindows && Elevate) {
34 | Arguments = $"{Command} {Arguments}";
35 | Command = "/usr/bin/sudo";
36 | }
37 | return new Process {
38 | StartInfo = new ProcessStartInfo {
39 | FileName = Command,
40 | Arguments = Arguments,
41 | UseShellExecute = false,
42 | RedirectStandardError = true,
43 | RedirectStandardOutput = true,
44 | }
45 | };
46 | }
47 |
48 | Task StartAndWait (Process process, CancellationToken token)
49 | {
50 | process.Start ();
51 | process.BeginErrorReadLine ();
52 | process.BeginOutputReadLine ();
53 | return Task.Run (process.WaitForExit, token);
54 | }
55 |
56 | async Task Run (CancellationToken token)
57 | {
58 | process = CreateProcess ();
59 | process.ErrorDataReceived += (sender, e) => {
60 | if (e.Data != null)
61 | boots.Logger.WriteLine (e.Data);
62 | };
63 | process.OutputDataReceived += (sender, e) => {
64 | if (e.Data != null)
65 | boots.Logger.WriteLine (e.Data);
66 | };
67 |
68 | await StartAndWait (process, token);
69 | return process.ExitCode;
70 | }
71 |
72 | public async Task RunAsync (CancellationToken token, bool throwOnError = true)
73 | {
74 | int exitCode = await Run (token);
75 | if (throwOnError && exitCode != 0)
76 | ThrowForExitCode (exitCode);
77 | return exitCode;
78 | }
79 |
80 | public void ThrowForExitCode (int exitCode) =>
81 | throw new Exception ($"'{Command}' with arguments '{Arguments}' exited with code {exitCode}");
82 |
83 | public async Task RunWithOutputAsync (CancellationToken token)
84 | {
85 | var builder = new StringBuilder ();
86 | process = CreateProcess ();
87 | process.ErrorDataReceived += (sender, e) => {
88 | if (e.Data != null)
89 | builder.AppendLine (e.Data);
90 | };
91 | process.OutputDataReceived += (sender, e) => {
92 | if (e.Data != null)
93 | builder.AppendLine (e.Data);
94 | };
95 |
96 | await StartAndWait (process, token);
97 | if (process.ExitCode != 0)
98 | throw new Exception ($"'{Command}' with arguments '{Arguments}' exited with code {process.ExitCode}");
99 | return builder.ToString ();
100 | }
101 |
102 | public async Task TryRunAsync (CancellationToken token)
103 | {
104 | return await Run (token);
105 | }
106 |
107 | public void Dispose ()
108 | {
109 | process?.Dispose ();
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/Boots.Core/WindowsUrlResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | namespace Boots.Core
7 | {
8 | class WindowsUrlResolver : UrlResolver
9 | {
10 | const string ReleaseUrl = "https://aka.ms/vs/17/release/channel";
11 | const string PreviewUrl = "https://aka.ms/vs/17/pre/channel";
12 |
13 | public WindowsUrlResolver (Bootstrapper boots) : base (boots) { }
14 |
15 | public async override Task Resolve (ReleaseChannel channel, Product product, CancellationToken token = new CancellationToken ())
16 | {
17 | using var httpClient = new HttpClientWithPolicy (Boots);
18 | Uri uri = GetUri (channel);
19 | string channelId = GetChannelId (channel);
20 | string productId = GetProductId (product);
21 | string payloadManifestUrl = await GetPayloadManifestUrl (httpClient, uri, channelId, token);
22 | return await GetPayloadUrl (httpClient, payloadManifestUrl, productId, token);
23 | }
24 |
25 | async Task GetPayloadManifestUrl (HttpClientWithPolicy httpClient, Uri uri, string channelId, CancellationToken token)
26 | {
27 | Boots.Logger.WriteLine ($"Querying {uri}");
28 |
29 | var manifest = await httpClient.GetJsonAsync (uri, token);
30 | var channelItem = manifest?.channelItems?.FirstOrDefault (c => c.id == channelId);
31 | if (channelItem == null) {
32 | throw new InvalidOperationException ($"Did not find '{channelId}' at: {uri}");
33 | }
34 |
35 | var payloadManifestUrl = channelItem.payloads?.Select (p => p.url)?.FirstOrDefault ();
36 | if (payloadManifestUrl == null || payloadManifestUrl == "") {
37 | throw new InvalidOperationException ($"Did not find manifest url for '{channelId}' at: {uri}");
38 | }
39 | return payloadManifestUrl;
40 | }
41 |
42 | async Task GetPayloadUrl (HttpClientWithPolicy httpClient, string payloadManifestUrl, string productId, CancellationToken token)
43 | {
44 | var uri = new Uri (payloadManifestUrl);
45 | Boots.Logger.WriteLine ($"Querying {uri}");
46 |
47 | var payload = await httpClient.GetJsonAsync (uri, token);
48 | var url = payload?.packages?.FirstOrDefault (p => p.id == productId)?.payloads?.Select (p => p.url).FirstOrDefault ();
49 | if (url == null || url == "") {
50 | throw new InvalidOperationException ($"Did not find payload url for '{productId}' at: {uri}");
51 | }
52 |
53 | // Just let this throw if it is an invalid Uri
54 | new Uri (url);
55 | return url;
56 | }
57 |
58 | Uri GetUri (ReleaseChannel channel)
59 | {
60 | switch (channel) {
61 | case ReleaseChannel.Stable:
62 | return new Uri (ReleaseUrl);
63 | case ReleaseChannel.Preview:
64 | case ReleaseChannel.Alpha:
65 | return new Uri (PreviewUrl);
66 | default:
67 | throw new NotImplementedException ($"Unexpected value for {nameof (ReleaseChannel)}: {channel}"); ;
68 | }
69 | }
70 |
71 | string GetChannelId (ReleaseChannel channel)
72 | {
73 | switch (channel) {
74 | case ReleaseChannel.Stable:
75 | return "Microsoft.VisualStudio.Manifests.VisualStudio";
76 | case ReleaseChannel.Preview:
77 | case ReleaseChannel.Alpha:
78 | return "Microsoft.VisualStudio.Manifests.VisualStudioPreview";
79 | default:
80 | throw new NotImplementedException ($"Unexpected value for release: {channel}"); ;
81 | }
82 | }
83 |
84 | string GetProductId (Product product)
85 | {
86 | switch (product) {
87 | case Product.XamarinAndroid:
88 | return "Xamarin.Android.Sdk";
89 | case Product.Mono:
90 | case Product.XamariniOS:
91 | case Product.XamarinMac:
92 | throw new NotImplementedException ($"Value for product not implemented on Windows: {product}");
93 | default:
94 | throw new NotImplementedException ($"Unexpected value for product: {product}");
95 | }
96 | }
97 |
98 | class VSManifest
99 | {
100 | public VSPackage []? channelItems { get; set; }
101 | }
102 |
103 | class VSPayload
104 | {
105 | public string? url { get; set; }
106 | }
107 |
108 | class VSPayloadManifest
109 | {
110 | public VSPackage []? packages { get; set; }
111 | }
112 |
113 | class VSPackage
114 | {
115 | public string? id { get; set; }
116 |
117 | public VSPayload []? payloads { get; set; }
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Boots.Tests/HttpClientWithPolicyTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net.Http;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 | using System.Xml;
7 | using Boots.Core;
8 | using Polly.Timeout;
9 | using Xunit;
10 |
11 | namespace Boots.Tests
12 | {
13 | public class HttpClientWithPolicyTests
14 | {
15 | [Fact]
16 | public void InvalidTimeout ()
17 | {
18 | var boots = new Bootstrapper {
19 | Timeout = TimeSpan.FromSeconds (-1),
20 | };
21 | Assert.Throws (() => new HttpClientWithPolicy (boots));
22 | }
23 |
24 | [Fact]
25 | public void DefaultTimeout ()
26 | {
27 | // Mainly validates the 100-second default:
28 | // https://docs.microsoft.com/dotnet/api/system.net.http.httpclient.timeout#remarks
29 | var boots = new Bootstrapper ();
30 | using var client = new HttpClientWithPolicy (boots);
31 | Assert.Equal (TimeSpan.FromSeconds (100), client.Timeout);
32 | }
33 |
34 | [Fact]
35 | public async Task Cancelled ()
36 | {
37 | var boots = new Bootstrapper ();
38 | boots.UpdateActivePolicy ();
39 |
40 | using var client = new AlwaysTimeoutClient (boots);
41 | var token = new CancellationToken (canceled: true);
42 | await Assert.ThrowsAsync (() =>
43 | client.DownloadAsync (new Uri ("http://google.com"), "", token));
44 | Assert.Equal (0, client.TimesCalled);
45 | }
46 |
47 | [Theory]
48 | [InlineData (typeof (AlwaysTimeoutClient), typeof (TimeoutRejectedException))]
49 | [InlineData (typeof (AlwaysThrowsClient), typeof (HttpRequestException))]
50 | [InlineData (typeof (AlwaysThrowsClient), typeof (IOException))]
51 | [InlineData (typeof (AlwaysThrowsClient), typeof (NotImplementedException), 0)]
52 | [InlineData (typeof (AlwaysThrowsClient), typeof (NullReferenceException), 0)]
53 | public async Task TimeoutPolicy (Type clientType, Type exceptionType, int expectedRetries = 5)
54 | {
55 | var writer = new StringWriter ();
56 | var boots = new Bootstrapper {
57 | NetworkRetries = 5,
58 | ReadWriteTimeout = TimeSpan.FromMilliseconds (1),
59 | Logger = writer,
60 | };
61 | boots.UpdateActivePolicy ();
62 |
63 | using var client = (TestClient) Activator.CreateInstance (clientType, new object [] { boots });
64 | client.ExceptionType = exceptionType;
65 | await Assert.ThrowsAsync (exceptionType, () =>
66 | client.DownloadAsync (new Uri ("http://google.com"), "", CancellationToken.None));
67 | Assert.Equal (expectedRetries + 1, client.TimesCalled);
68 | for (int i = 1; i <= expectedRetries; i++) {
69 | Assert.Contains ($"Retry attempt {i}: {exceptionType.FullName}", writer.ToString ());
70 | }
71 | }
72 |
73 | class TestClient : HttpClientWithPolicy
74 | {
75 | public TestClient (Bootstrapper boots) : base (boots) { }
76 |
77 | public int TimesCalled { get; set; }
78 |
79 | public Type ExceptionType { get; set; }
80 | }
81 |
82 | class AlwaysTimeoutClient : TestClient
83 | {
84 | public AlwaysTimeoutClient (Bootstrapper boots) : base (boots) { }
85 |
86 | async Task Forever (CancellationToken token)
87 | {
88 | TimesCalled++;
89 | await Task.Delay (System.Threading.Timeout.Infinite, token);
90 | return default;
91 | }
92 |
93 | protected override Task DoDownloadAsync (Uri uri, string tempFile, CancellationToken token) => Forever