/// <summary> /// Invokes the builder in a dedicated working directory. /// </summary> private static async Task BuildAsync(IIntuneAppPackageBuilder builder, IIntuneAppPackagingService packagingService, string output, ILogger logger) { var cd = Environment.CurrentDirectory; Environment.CurrentDirectory = output; try { var package = await builder.BuildAsync(null); package.Data.Position = 0; var baseFileName = Path.GetFileNameWithoutExtension(package.App.FileName); File.WriteAllText($"{baseFileName}.intunewin.json", JsonConvert.SerializeObject(package, Formatting.Indented)); await using (var fs = File.Open($"{baseFileName}.intunewin", FileMode.Create, FileAccess.Write, FileShare.Read)) await package.Data.CopyToAsync(fs); await using (var fs = File.Open($"{baseFileName}.portal.intunewin", FileMode.Create, FileAccess.Write, FileShare.Read)) await packagingService.BuildPackageForPortalAsync(package, fs); logger.LogInformation($"Finished writing {baseFileName} package files to {output}."); } finally { Environment.CurrentDirectory = cd; } }
/// <summary> /// Saves a common install.bat file to the working directory that will launch either a 64 bit or 32 bit setup.exe or /// msi depending on the client operating system. /// </summary> /// <param name="builder"></param> /// <returns></returns> public static async Task SaveInstallBatFileAsync(this IIntuneAppPackageBuilder builder) { await typeof(ReflectionUtil).Assembly.SaveEmbeddedResourceAsFileAsync($"{typeof(ReflectionUtil).Namespace}.Install.bat", "Install.bat"); }