1
1
namespace CnCNet . LauncherStub ;
2
2
3
3
using System ;
4
+ using System . Collections . Generic ;
4
5
using System . Diagnostics ;
5
6
using System . IO ;
6
7
using System . Linq ;
@@ -13,8 +14,23 @@ internal sealed class Program
13
14
private const string Resources = "Resources" ;
14
15
private const string Binaries = "Binaries" ;
15
16
private const int DotNetMajorVersion = 7 ;
16
- private const string DotNetDownloadLink = "https://dotnet.microsoft.com/download/dotnet/7.0/runtime" ;
17
- private const string XnaDownloadLink = "https://www.microsoft.com/download/details.aspx?id=27598" ;
17
+
18
+ private static readonly Uri XnaDownloadLink = new ( "https://www.microsoft.com/download/details.aspx?id=27598" ) ;
19
+ private static readonly Uri DotNetX64RuntimeDownloadLink = new ( FormattableString . Invariant ( $ "https://aka.ms/dotnet/{ DotNetMajorVersion } .0/dotnet-runtime-win-x64.exe") ) ;
20
+ private static readonly Uri DotNetX64DesktopRuntimeDownloadLink = new ( FormattableString . Invariant ( $ "https://aka.ms/dotnet/{ DotNetMajorVersion } .0/windowsdesktop-runtime-win-x64.exe") ) ;
21
+ private static readonly Uri DotNetX86RuntimeDownloadLink = new ( FormattableString . Invariant ( $ "https://aka.ms/dotnet/{ DotNetMajorVersion } .0/dotnet-runtime-win-x86.exe") ) ;
22
+ private static readonly Uri DotNetX86DesktopRuntimeDownloadLink = new ( FormattableString . Invariant ( $ "https://aka.ms/dotnet/{ DotNetMajorVersion } .0/windowsdesktop-runtime-win-x86.exe") ) ;
23
+ private static readonly Uri DotNetArm64RuntimeDownloadLink = new ( FormattableString . Invariant ( $ "https://aka.ms/dotnet/{ DotNetMajorVersion } .0/dotnet-runtime-win-arm64.exe") ) ;
24
+ private static readonly Uri DotNetArm64DesktopRuntimeDownloadLink = new ( FormattableString . Invariant ( $ "https://aka.ms/dotnet/{ DotNetMajorVersion } .0/windowsdesktop-runtime-win-arm64.exe") ) ;
25
+ private static readonly IReadOnlyDictionary < ( Architecture Architecture , bool Desktop ) , Uri > DotNetDownloadLinks = new Dictionary < ( Architecture Architecture , bool Desktop ) , Uri >
26
+ {
27
+ { ( Architecture . X64 , false ) , DotNetX64RuntimeDownloadLink } ,
28
+ { ( Architecture . X64 , true ) , DotNetX64DesktopRuntimeDownloadLink } ,
29
+ { ( Architecture . X86 , false ) , DotNetX86RuntimeDownloadLink } ,
30
+ { ( Architecture . X86 , true ) , DotNetX86DesktopRuntimeDownloadLink } ,
31
+ { ( Architecture . Arm64 , false ) , DotNetArm64RuntimeDownloadLink } ,
32
+ { ( Architecture . Arm64 , true ) , DotNetArm64DesktopRuntimeDownloadLink }
33
+ } . AsReadOnly ( ) ;
18
34
19
35
private static bool automaticX86Fallback ;
20
36
@@ -121,10 +137,10 @@ private static void AutoRun()
121
137
RunDX ( ) ;
122
138
}
123
139
124
- private static void SetLinkLabelUrl ( LinkLabel linkLabel , string url )
140
+ private static void SetLinkLabelUrl ( LinkLabel linkLabel , Uri uri )
125
141
{
126
- linkLabel . Text = url ;
127
- linkLabel . Links [ 0 ] . LinkData = url ;
142
+ linkLabel . Text = uri . ToString ( ) ;
143
+ linkLabel . Links [ 0 ] . LinkData = uri ;
128
144
}
129
145
130
146
private static void StartProcess ( string relativePath , bool run32Bit = false , bool runDesktop = true )
@@ -166,7 +182,7 @@ private static FileInfo CheckAndRetrieveDotNetHost(Architecture architecture, bo
166
182
{
167
183
string missingComponent = FormattableString . Invariant ( $ "'.NET Desktop Runtime' version { DotNetMajorVersion } for platform { architecture } ") ;
168
184
169
- ShowMissingComponentForm ( missingComponent , DotNetDownloadLink ) ;
185
+ ShowMissingComponentForm ( missingComponent , DotNetDownloadLinks [ ( architecture , true ) ] ) ;
170
186
}
171
187
172
188
FileInfo ? dotnetHost = GetDotNetHost ( architecture ) ;
@@ -175,13 +191,13 @@ private static FileInfo CheckAndRetrieveDotNetHost(Architecture architecture, bo
175
191
{
176
192
string missingComponent = FormattableString . Invariant ( $ "'.NET Runtime' version { DotNetMajorVersion } for platform { architecture } ") ;
177
193
178
- ShowMissingComponentForm ( missingComponent , DotNetDownloadLink ) ;
194
+ ShowMissingComponentForm ( missingComponent , DotNetDownloadLinks [ ( architecture , false ) ] ) ;
179
195
}
180
196
181
197
return dotnetHost ! ;
182
198
}
183
199
184
- private static void ShowMissingComponentForm ( string missingComponent , string downloadLink )
200
+ private static void ShowMissingComponentForm ( string missingComponent , Uri downloadLink )
185
201
{
186
202
using var messageForm = new ComponentMissingMessageForm ( ) ;
187
203
0 commit comments