Skip to content

Commit 42ddbbb

Browse files
authored
Use undocumented direct download links (#6)
1 parent 6033e9b commit 42ddbbb

File tree

6 files changed

+74
-12
lines changed

6 files changed

+74
-12
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish with custom icon
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
iconurl:
7+
description: 'Icon URL'
8+
required: true
9+
default: 'https://raw.githubusercontent.com/Rampastring/dta-xna-cncnet-client/master/DXMainClient/clienticon.ico'
10+
type: string
11+
12+
jobs:
13+
publish:
14+
runs-on: windows-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@main
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set Icon
22+
run: curl ${{ github.event.inputs.iconurl }} -o mainclienticon.ico
23+
24+
- name: Setup .NET Core SDK
25+
uses: actions/setup-dotnet@main
26+
with:
27+
dotnet-version: '7.x.x'
28+
29+
- name: Install GitVersion
30+
uses: gittools/actions/gitversion/setup@main
31+
with:
32+
versionSpec: '5.x'
33+
34+
- name: Determine Version
35+
uses: gittools/actions/gitversion/execute@main
36+
37+
- name: Publish
38+
run: dotnet publish DTALauncherStub.csproj --configuration Release --no-self-contained -p:PublishSingleFile=true -r win-x86 -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
39+
40+
- uses: actions/upload-artifact@main
41+
name: Upload Artifacts
42+
with:
43+
name: artifacts
44+
path: ./bin/Release/net7.0-windows/win-x86/publish

CnCNet.LauncherStub.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<Title>CnCNet Launcher</Title>
77
<Description>Launcher for CnCNet Client</Description>
88
<Company>CnCNet</Company>
9-
<Product>CnCNet</Product>
10-
<Copyright>Copyright © CnCNet, Rampastring 2011-2022</Copyright>
9+
<Product>CnCNet Client Launcher</Product>
10+
<Copyright>Copyright © CnCNet, Rampastring 2011-2023</Copyright>
1111
<Trademark></Trademark>
1212
<AssemblyName>CnCNet.LauncherStub</AssemblyName>
1313
<RootNamespace>CnCNet.LauncherStub</RootNamespace>

CnCNet.LauncherStub.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{31CF936D-B0E9-4B0B-9D87-255E3514164A}"
99
ProjectSection(SolutionItems) = preProject
1010
.editorconfig = .editorconfig
11+
.github\workflows\publish.yml = .github\workflows\publish.yml
12+
.github\workflows\publishcustomicon.yml = .github\workflows\publishcustomicon.yml
1113
EndProjectSection
1214
EndProject
1315
Global

ComponentMissingMessageForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private void LblDotNetLink_LinkClicked(object sender, LinkLabelLinkClickedEventA
1515
{
1616
using var _ = Process.Start(new ProcessStartInfo
1717
{
18-
FileName = e.Link!.LinkData as string,
18+
FileName = ((Uri)e.Link!.LinkData).ToString(),
1919
UseShellExecute = true
2020
});
2121
}

IncompatibleGPUMessageForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private void LblXNALink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
1818
{
1919
using var _ = Process.Start(new ProcessStartInfo
2020
{
21-
FileName = e.Link!.LinkData as string,
21+
FileName = ((Uri)e.Link!.LinkData).ToString(),
2222
UseShellExecute = true
2323
});
2424
}

Program.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace CnCNet.LauncherStub;
22

33
using System;
4+
using System.Collections.Generic;
45
using System.Diagnostics;
56
using System.IO;
67
using System.Linq;
@@ -13,8 +14,23 @@ internal sealed class Program
1314
private const string Resources = "Resources";
1415
private const string Binaries = "Binaries";
1516
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();
1834

1935
private static bool automaticX86Fallback;
2036

@@ -121,10 +137,10 @@ private static void AutoRun()
121137
RunDX();
122138
}
123139

124-
private static void SetLinkLabelUrl(LinkLabel linkLabel, string url)
140+
private static void SetLinkLabelUrl(LinkLabel linkLabel, Uri uri)
125141
{
126-
linkLabel.Text = url;
127-
linkLabel.Links[0].LinkData = url;
142+
linkLabel.Text = uri.ToString();
143+
linkLabel.Links[0].LinkData = uri;
128144
}
129145

130146
private static void StartProcess(string relativePath, bool run32Bit = false, bool runDesktop = true)
@@ -166,7 +182,7 @@ private static FileInfo CheckAndRetrieveDotNetHost(Architecture architecture, bo
166182
{
167183
string missingComponent = FormattableString.Invariant($"'.NET Desktop Runtime' version {DotNetMajorVersion} for platform {architecture}");
168184

169-
ShowMissingComponentForm(missingComponent, DotNetDownloadLink);
185+
ShowMissingComponentForm(missingComponent, DotNetDownloadLinks[(architecture, true)]);
170186
}
171187

172188
FileInfo? dotnetHost = GetDotNetHost(architecture);
@@ -175,13 +191,13 @@ private static FileInfo CheckAndRetrieveDotNetHost(Architecture architecture, bo
175191
{
176192
string missingComponent = FormattableString.Invariant($"'.NET Runtime' version {DotNetMajorVersion} for platform {architecture}");
177193

178-
ShowMissingComponentForm(missingComponent, DotNetDownloadLink);
194+
ShowMissingComponentForm(missingComponent, DotNetDownloadLinks[(architecture, false)]);
179195
}
180196

181197
return dotnetHost!;
182198
}
183199

184-
private static void ShowMissingComponentForm(string missingComponent, string downloadLink)
200+
private static void ShowMissingComponentForm(string missingComponent, Uri downloadLink)
185201
{
186202
using var messageForm = new ComponentMissingMessageForm();
187203

0 commit comments

Comments
 (0)