Skip to content

Commit

Permalink
Use undocumented direct download links (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rans4ckeR authored Jan 19, 2023
1 parent 6033e9b commit 42ddbbb
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 12 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/publishcustomicon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish with custom icon

on:
workflow_dispatch:
inputs:
iconurl:
description: 'Icon URL'
required: true
default: 'https://raw.githubusercontent.com/Rampastring/dta-xna-cncnet-client/master/DXMainClient/clienticon.ico'
type: string

jobs:
publish:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0

- name: Set Icon
run: curl ${{ github.event.inputs.iconurl }} -o mainclienticon.ico

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@main
with:
dotnet-version: '7.x.x'

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@main
with:
versionSpec: '5.x'

- name: Determine Version
uses: gittools/actions/gitversion/execute@main

- name: Publish
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

- uses: actions/upload-artifact@main
name: Upload Artifacts
with:
name: artifacts
path: ./bin/Release/net7.0-windows/win-x86/publish
4 changes: 2 additions & 2 deletions CnCNet.LauncherStub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<Title>CnCNet Launcher</Title>
<Description>Launcher for CnCNet Client</Description>
<Company>CnCNet</Company>
<Product>CnCNet</Product>
<Copyright>Copyright © CnCNet, Rampastring 2011-2022</Copyright>
<Product>CnCNet Client Launcher</Product>
<Copyright>Copyright © CnCNet, Rampastring 2011-2023</Copyright>
<Trademark></Trademark>
<AssemblyName>CnCNet.LauncherStub</AssemblyName>
<RootNamespace>CnCNet.LauncherStub</RootNamespace>
Expand Down
2 changes: 2 additions & 0 deletions CnCNet.LauncherStub.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{31CF936D-B0E9-4B0B-9D87-255E3514164A}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\publish.yml = .github\workflows\publish.yml
.github\workflows\publishcustomicon.yml = .github\workflows\publishcustomicon.yml
EndProjectSection
EndProject
Global
Expand Down
2 changes: 1 addition & 1 deletion ComponentMissingMessageForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private void LblDotNetLink_LinkClicked(object sender, LinkLabelLinkClickedEventA
{
using var _ = Process.Start(new ProcessStartInfo
{
FileName = e.Link!.LinkData as string,
FileName = ((Uri)e.Link!.LinkData).ToString(),
UseShellExecute = true
});
}
Expand Down
2 changes: 1 addition & 1 deletion IncompatibleGPUMessageForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private void LblXNALink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
{
using var _ = Process.Start(new ProcessStartInfo
{
FileName = e.Link!.LinkData as string,
FileName = ((Uri)e.Link!.LinkData).ToString(),
UseShellExecute = true
});
}
Expand Down
32 changes: 24 additions & 8 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace CnCNet.LauncherStub;

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand All @@ -13,8 +14,23 @@ internal sealed class Program
private const string Resources = "Resources";
private const string Binaries = "Binaries";
private const int DotNetMajorVersion = 7;
private const string DotNetDownloadLink = "https://dotnet.microsoft.com/download/dotnet/7.0/runtime";
private const string XnaDownloadLink = "https://www.microsoft.com/download/details.aspx?id=27598";

private static readonly Uri XnaDownloadLink = new("https://www.microsoft.com/download/details.aspx?id=27598");
private static readonly Uri DotNetX64RuntimeDownloadLink = new(FormattableString.Invariant($"https://aka.ms/dotnet/{DotNetMajorVersion}.0/dotnet-runtime-win-x64.exe"));
private static readonly Uri DotNetX64DesktopRuntimeDownloadLink = new(FormattableString.Invariant($"https://aka.ms/dotnet/{DotNetMajorVersion}.0/windowsdesktop-runtime-win-x64.exe"));
private static readonly Uri DotNetX86RuntimeDownloadLink = new(FormattableString.Invariant($"https://aka.ms/dotnet/{DotNetMajorVersion}.0/dotnet-runtime-win-x86.exe"));
private static readonly Uri DotNetX86DesktopRuntimeDownloadLink = new(FormattableString.Invariant($"https://aka.ms/dotnet/{DotNetMajorVersion}.0/windowsdesktop-runtime-win-x86.exe"));
private static readonly Uri DotNetArm64RuntimeDownloadLink = new(FormattableString.Invariant($"https://aka.ms/dotnet/{DotNetMajorVersion}.0/dotnet-runtime-win-arm64.exe"));
private static readonly Uri DotNetArm64DesktopRuntimeDownloadLink = new(FormattableString.Invariant($"https://aka.ms/dotnet/{DotNetMajorVersion}.0/windowsdesktop-runtime-win-arm64.exe"));
private static readonly IReadOnlyDictionary<(Architecture Architecture, bool Desktop), Uri> DotNetDownloadLinks = new Dictionary<(Architecture Architecture, bool Desktop), Uri>
{
{ (Architecture.X64, false), DotNetX64RuntimeDownloadLink },
{ (Architecture.X64, true), DotNetX64DesktopRuntimeDownloadLink },
{ (Architecture.X86, false), DotNetX86RuntimeDownloadLink },
{ (Architecture.X86, true), DotNetX86DesktopRuntimeDownloadLink },
{ (Architecture.Arm64, false), DotNetArm64RuntimeDownloadLink },
{ (Architecture.Arm64, true), DotNetArm64DesktopRuntimeDownloadLink }
}.AsReadOnly();

private static bool automaticX86Fallback;

Expand Down Expand Up @@ -121,10 +137,10 @@ private static void AutoRun()
RunDX();
}

private static void SetLinkLabelUrl(LinkLabel linkLabel, string url)
private static void SetLinkLabelUrl(LinkLabel linkLabel, Uri uri)
{
linkLabel.Text = url;
linkLabel.Links[0].LinkData = url;
linkLabel.Text = uri.ToString();
linkLabel.Links[0].LinkData = uri;
}

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

ShowMissingComponentForm(missingComponent, DotNetDownloadLink);
ShowMissingComponentForm(missingComponent, DotNetDownloadLinks[(architecture, true)]);
}

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

ShowMissingComponentForm(missingComponent, DotNetDownloadLink);
ShowMissingComponentForm(missingComponent, DotNetDownloadLinks[(architecture, false)]);
}

return dotnetHost!;
}

private static void ShowMissingComponentForm(string missingComponent, string downloadLink)
private static void ShowMissingComponentForm(string missingComponent, Uri downloadLink)
{
using var messageForm = new ComponentMissingMessageForm();

Expand Down

0 comments on commit 42ddbbb

Please sign in to comment.