-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[msi] support for downloading/installing .msi files (#50)
Fixes: #31 This will help us in .NET 6 development. We need to download and install .msi files as part of CI. This also cleaned up a few other things: * `NotSupportedException` would now be thrown on Linux. * Better `async` usage in `PrintLogFileAndDelete()` * Fixed a potential `System.FormatException` in Cake.Boots. This was happening with `.msi` files. * Other general code cleanup.
- Loading branch information
1 parent
adc4986
commit 4bcfbb9
Showing
11 changed files
with
116 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public enum FileType | ||
{ | ||
vsix, | ||
pkg, | ||
msi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Boots.Core | ||
{ | ||
class MsiInstaller : Installer | ||
{ | ||
public MsiInstaller (Bootstrapper boots) : base (boots) { } | ||
|
||
public override string Extension => ".msi"; | ||
|
||
public async override Task Install (string file, CancellationToken token = default) | ||
{ | ||
if (string.IsNullOrEmpty (file)) | ||
throw new ArgumentException (nameof (file)); | ||
if (!File.Exists (file)) | ||
throw new FileNotFoundException ($"{Extension} file did not exist: {file}", file); | ||
|
||
var log = Path.GetTempFileName (); | ||
try { | ||
using (var proc = new AsyncProcess (Boots) { | ||
Command = "msiexec", | ||
Arguments = $"/i \"{file}\" /qn /L*V \"{log}\"", | ||
Elevate = true, | ||
}) { | ||
await proc.RunAsync (token); | ||
} | ||
} finally { | ||
await PrintLogFileAndDelete (log, token); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters