Initial commit: .NET NativeAOT Microsoft 365 en-US offline .img downloader and setup installer
This commit is contained in:
commit
5daecad2f2
10 files changed
+3864
No files matched your search
+19
@@ -0,0 +1,19 @@
|
|||||||
|
# Build outputs & intermediates
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
dist/
|
||||||
|
installer/bin/
|
||||||
|
installer/obj/
|
||||||
|
installer/payload.gz
|
||||||
|
|
||||||
|
# Generated build icon (re-generated automatically by build.ps1, or keep src/app.ico tracked)
|
||||||
|
# Local download artifacts
|
||||||
|
*.img
|
||||||
|
*.part
|
||||||
|
*.meta
|
||||||
|
|
||||||
|
# IDE / OS files
|
||||||
|
.vs/
|
||||||
|
.vscode/
|
||||||
|
Thumbs.db
|
||||||
|
Desktop.ini
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<PublishAot>true</PublishAot>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
<OptimizationPreference>Speed</OptimizationPreference>
|
||||||
|
<StripSymbols>true</StripSymbols>
|
||||||
|
<ApplicationManifest>src\app.manifest</ApplicationManifest>
|
||||||
|
<ApplicationIcon>src\app.ico</ApplicationIcon>
|
||||||
|
<AssemblyName>M365IsoDownloader</AssemblyName>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Company>M365 Tools</Company>
|
||||||
|
<Product>Microsoft 365 Offline Image Downloader</Product>
|
||||||
|
<Description>Single-file .NET NativeAOT GUI for checking and downloading Microsoft 365 en-US offline .img installers.</Description>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="installer\**" />
|
||||||
|
<EmbeddedResource Remove="installer\**" />
|
||||||
|
<None Remove="installer\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Microsoft 365 Offline Image Downloader (`en-US`) — .NET NativeAOT
|
||||||
|
|
||||||
|
A single-file, zero-dependency Windows desktop GUI (`dist\M365IsoDownloader.exe`) compiled ahead-of-time to native `win-x64` machine code with **.NET 9 NativeAOT** (`<PublishAot>true</PublishAot>`).
|
||||||
|
|
||||||
|
## Supported Editions (`en-US`, 32-bit & 64-bit)
|
||||||
|
- **Microsoft 365 Apps for Enterprise** (`O365ProPlusRetail.img`)
|
||||||
|
- **Microsoft 365 Apps for Business** (`O365BusinessRetail.img`)
|
||||||
|
- **Microsoft 365 Personal / Family** (`O365HomePremRetail.img`)
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
- **True `.NET NativeAOT` Single-File `.exe`:** Compiled directly to native x64 machine code with no JIT, no external DLLs, and no `.NET` runtime required on target Windows 10/11 PCs.
|
||||||
|
- **Crisp Windows 11 Desktop UI:** Hardware-composited rounded window corners, Per-Monitor v2 High-DPI scaling, ClearType typography, and double-buffered GDI+ Fluent card layout.
|
||||||
|
- **Instant Build Inspection (Zero Full Download Needed):** Sends HTTP `HEAD` + a 192 KB HTTP `Range` request (`bytes=32768-229375`) to read the ISO-9660 volume header and display the exact `16.0.xxxxx.xxxxx` build version, publish date, and file size before downloading.
|
||||||
|
- **Local `.img` Build Comparison:** Reads byte `32768` of any existing `.img` files in your save folder to compare local vs. CDN builds (`Up to Date` vs. `Update Available`).
|
||||||
|
- **Pause & Resume Support:** Streams via `SocketsHttpHandler` (HTTP/2 + TLS 1.3) into `.img.part` files with `ETag` verification, live transfer speed, and ETA.
|
||||||
|
- **Automatic CDN Fallback:** Uses `/db/` primary endpoints and transparently falls back to `/pr/`.
|
||||||
|
|
||||||
|
## Building from Source
|
||||||
|
Requires the `.NET 9+ SDK` and Visual Studio 2022 C++ Build Tools (`MSVC` + Windows SDK):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\build.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
Output executable: `dist\M365IsoDownloader.exe`
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
|
$srcDir = Join-Path $root "src"
|
||||||
|
$installerDir = Join-Path $root "installer"
|
||||||
|
$distDir = Join-Path $root "dist"
|
||||||
|
New-Item -ItemType Directory -Force -Path $distDir | Out-Null
|
||||||
|
|
||||||
|
# 1. Generate multi-resolution Windows .ico file (16, 32, 48, 256 px) if not already created
|
||||||
|
$icoPath = Join-Path $srcDir "app.ico"
|
||||||
|
if (-not (Test-Path $icoPath)) {
|
||||||
|
Add-Type -AssemblyName System.Drawing
|
||||||
|
|
||||||
|
function New-IconPngBytes([int]$size) {
|
||||||
|
$bmp = New-Object System.Drawing.Bitmap($size, $size, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
||||||
|
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||||
|
$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
||||||
|
$g.Clear([System.Drawing.Color]::Transparent)
|
||||||
|
|
||||||
|
$pad = [float]($size * 0.06)
|
||||||
|
$rectSize = [float]($size - 2 * $pad)
|
||||||
|
$radius = [float]($size * 0.22)
|
||||||
|
$d = $radius * 2
|
||||||
|
|
||||||
|
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
|
||||||
|
$path.AddArc($pad, $pad, $d, $d, 180, 90)
|
||||||
|
$path.AddArc($pad + $rectSize - $d, $pad, $d, $d, 270, 90)
|
||||||
|
$path.AddArc($pad + $rectSize - $d, $pad + $rectSize - $d, $d, $d, 0, 90)
|
||||||
|
$path.AddArc($pad, $pad + $rectSize - $d, $d, $d, 90, 90)
|
||||||
|
$path.CloseFigure()
|
||||||
|
|
||||||
|
$brush = New-Object System.Drawing.Drawing2D.LinearGradientBrush(
|
||||||
|
(New-Object System.Drawing.PointF(0, 0)),
|
||||||
|
(New-Object System.Drawing.PointF($size, $size)),
|
||||||
|
[System.Drawing.Color]::FromArgb(255, 0, 114, 214),
|
||||||
|
[System.Drawing.Color]::FromArgb(255, 0, 74, 152)
|
||||||
|
)
|
||||||
|
$g.FillPath($brush, $path)
|
||||||
|
|
||||||
|
$strokeW = [Math]::Max(1.6, [float]($size * 0.095))
|
||||||
|
$pen = New-Object System.Drawing.Pen([System.Drawing.Color]::White, $strokeW)
|
||||||
|
$pen.StartCap = [System.Drawing.Drawing2D.LineCap]::Round
|
||||||
|
$pen.EndCap = [System.Drawing.Drawing2D.LineCap]::Round
|
||||||
|
$pen.LineJoin = [System.Drawing.Drawing2D.LineJoin]::Round
|
||||||
|
|
||||||
|
$cx = [float]($size * 0.5)
|
||||||
|
$topY = [float]($size * 0.24)
|
||||||
|
$tipY = [float]($size * 0.62)
|
||||||
|
$wingDx = [float]($size * 0.19)
|
||||||
|
$wingY = [float]($size * 0.44)
|
||||||
|
$trayY = [float]($size * 0.76)
|
||||||
|
$trayHalf = [float]($size * 0.24)
|
||||||
|
|
||||||
|
$g.DrawLine($pen, $cx, $topY, $cx, $tipY)
|
||||||
|
$g.DrawLine($pen, ($cx - $wingDx), $wingY, $cx, $tipY)
|
||||||
|
$g.DrawLine($pen, ($cx + $wingDx), $wingY, $cx, $tipY)
|
||||||
|
$g.DrawLine($pen, ($cx - $trayHalf), $trayY, ($cx + $trayHalf), $trayY)
|
||||||
|
|
||||||
|
$ms = New-Object System.IO.MemoryStream
|
||||||
|
$bmp.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||||
|
$pen.Dispose(); $brush.Dispose(); $path.Dispose(); $g.Dispose(); $bmp.Dispose()
|
||||||
|
return ,$ms.ToArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
$sizes = @(16, 32, 48, 256)
|
||||||
|
$pngBlobs = @()
|
||||||
|
foreach ($s in $sizes) { $pngBlobs += ,(New-IconPngBytes $s) }
|
||||||
|
|
||||||
|
$fs = [System.IO.File]::Open($icoPath, [System.IO.FileMode]::Create)
|
||||||
|
$bw = New-Object System.IO.BinaryWriter($fs)
|
||||||
|
$bw.Write([uint16]0); $bw.Write([uint16]1); $bw.Write([uint16]$sizes.Count)
|
||||||
|
$offset = 6 + (16 * $sizes.Count)
|
||||||
|
for ($i = 0; $i -lt $sizes.Count; $i++) {
|
||||||
|
$s = $sizes[$i]; $blob = $pngBlobs[$i]
|
||||||
|
$dimByte = if ($s -ge 256) { [byte]0 } else { [byte]$s }
|
||||||
|
$bw.Write($dimByte); $bw.Write($dimByte); $bw.Write([byte]0); $bw.Write([byte]0)
|
||||||
|
$bw.Write([uint16]1); $bw.Write([uint16]32)
|
||||||
|
$bw.Write([uint32]$blob.Length); $bw.Write([uint32]$offset)
|
||||||
|
$offset += $blob.Length
|
||||||
|
}
|
||||||
|
for ($i = 0; $i -lt $sizes.Count; $i++) { $bw.Write($pngBlobs[$i]) }
|
||||||
|
$bw.Flush(); $bw.Close(); $fs.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2. Locate .NET SDK (system or portable scratch SDK)
|
||||||
|
$dotnetExe = $null
|
||||||
|
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
|
||||||
|
$sdks = & dotnet --list-sdks 2>$null
|
||||||
|
if ($sdks) { $dotnetExe = (Get-Command dotnet).Source }
|
||||||
|
}
|
||||||
|
if (-not $dotnetExe) {
|
||||||
|
$portableDotnet = Join-Path (Split-Path -Parent $root) ".dotnet\dotnet.exe"
|
||||||
|
if (Test-Path $portableDotnet) { $dotnetExe = $portableDotnet }
|
||||||
|
}
|
||||||
|
if (-not $dotnetExe) {
|
||||||
|
throw "No .NET SDK found. Install the .NET 9+ SDK and Visual Studio C++ Build Tools."
|
||||||
|
}
|
||||||
|
|
||||||
|
$env:DOTNET_CLI_TELEMETRY_OPTOUT = "1"
|
||||||
|
$env:DOTNET_NOLOGO = "1"
|
||||||
|
|
||||||
|
# 3. Publish Portable NativeAOT single-file executable (skip overwriting if currently running)
|
||||||
|
$portableExe = Join-Path $distDir "M365IsoDownloader.exe"
|
||||||
|
$isRunning = @(Get-Process -Name "M365IsoDownloader" -ErrorAction SilentlyContinue).Count -gt 0
|
||||||
|
if (-not $isRunning -or -not (Test-Path $portableExe)) {
|
||||||
|
$projFile = Join-Path $root "M365IsoDownloader.csproj"
|
||||||
|
& $dotnetExe publish $projFile -c Release -r win-x64 --nologo -o $distDir
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "NativeAOT app publish failed with exit code $LASTEXITCODE"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "M365IsoDownloader.exe is currently running; preserving existing binary in dist\."
|
||||||
|
}
|
||||||
|
|
||||||
|
# 4. Compress M365IsoDownloader.exe into installer\payload.gz and publish NativeAOT Setup Installer
|
||||||
|
$setupProj = Join-Path $installerDir "M365IsoDownloader.Setup.csproj"
|
||||||
|
if (Test-Path $setupProj) {
|
||||||
|
$payloadGz = Join-Path $installerDir "payload.gz"
|
||||||
|
$inFs = New-Object System.IO.FileStream($portableExe, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite)
|
||||||
|
$outFs = [System.IO.File]::Create($payloadGz)
|
||||||
|
$gz = New-Object System.IO.Compression.GZipStream($outFs, [System.IO.Compression.CompressionLevel]::Optimal)
|
||||||
|
$inFs.CopyTo($gz)
|
||||||
|
$gz.Dispose()
|
||||||
|
$outFs.Dispose()
|
||||||
|
$inFs.Dispose()
|
||||||
|
|
||||||
|
$setupOutDir = Join-Path $installerDir "bin\publish"
|
||||||
|
& $dotnetExe publish $setupProj -c Release -r win-x64 --nologo -o $setupOutDir
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "NativeAOT setup installer publish failed with exit code $LASTEXITCODE"
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-Item (Join-Path $setupOutDir "M365IsoDownloader-Setup.exe") (Join-Path $distDir "M365IsoDownloader-Setup.exe") -Force
|
||||||
|
Remove-Item $payloadGz -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up any non-exe artifacts in dist
|
||||||
|
Get-ChildItem $distDir -File | Where-Object { $_.Extension -ne ".exe" } | Remove-Item -Force
|
||||||
|
|
||||||
|
Write-Host "`nBuilt .NET NativeAOT deliverables in dist\:"
|
||||||
|
Get-ChildItem $distDir -Filter "*.exe" | ForEach-Object {
|
||||||
|
Write-Host (" {0,-32} {1,6:N2} MB ({2})" -f $_.Name, ($_.Length / 1MB), $_.FullName)
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net9.0-windows</TargetFramework>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<PublishAot>true</PublishAot>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
<OptimizationPreference>Size</OptimizationPreference>
|
||||||
|
<StripSymbols>true</StripSymbols>
|
||||||
|
<ApplicationManifest>..\src\app.manifest</ApplicationManifest>
|
||||||
|
<ApplicationIcon>..\src\app.ico</ApplicationIcon>
|
||||||
|
<AssemblyName>M365IsoDownloader-Setup</AssemblyName>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Company>M365 Tools</Company>
|
||||||
|
<Product>Microsoft 365 Offline Image Downloader Setup</Product>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="payload.gz" LogicalName="AppPayload.gz" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<clear />
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
+2452
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="M365IsoDownloader.app"/>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- Windows 10 and Windows 11 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<windowsSettings>
|
||||||
|
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||||
|
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
||||||
|
</windowsSettings>
|
||||||
|
</application>
|
||||||
|
</assembly>
|
||||||
Reference in new issue
Block a user