微软.net installer源码解析

2020-11-14

微软源码地址  dotnet/install-scripts/blob/master/src/dotnet-install.ps1

代码

   [string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
   [string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
if ($NoCdn) {
    $AzureFeed = $UncachedFeed
}
 
    if ($Runtime -eq "dotnet") {
        $VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version"
    }
    elseif ($Runtime -eq "aspnetcore") {
        $VersionFileUrl = "$UncachedFeed/aspnetcore/Runtime/$Channel/latest.version"
    }
    elseif ($Runtime -eq "windowsdesktop") {
        $VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version"
    }
    elseif (-not $Runtime) {
        if ($Coherent) {
            $VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.coherent.version"
        }
        else {
            $VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.version"
        }
    }
获取版本号 
https://dotnetcli.azureedge.net/dotnet/Sdk/Current/latest.version
https://dotnetcli.azureedge.net/dotnet/Sdk/LTS/latest.version
 
安装包 原始地址
https://dotnetcli.azureedge.net/dotnet
cdn 地址
https://dotnetcli.blob.core.windows.net/dotnet
 
下载 https://dotnetcli.blob.core.windows.net/dotnet/Sdk/版本号/dotnet-sdk-版本号-win-x64.zip
例如
 https://dotnetcli.blob.core.windows.net/dotnet/Sdk/3.1.404/dotnet-sdk-3.1.404-win-x64.zip
 
可以获取所有版本的安装包