Skip to content

Install VC Runtime On Downloading windows builds if not installed#367

Open
TheForce172 wants to merge 2 commits intoKnossosNET:mainfrom
TheForce172:InstallVCruntime
Open

Install VC Runtime On Downloading windows builds if not installed#367
TheForce172 wants to merge 2 commits intoKnossosNET:mainfrom
TheForce172:InstallVCruntime

Conversation

@TheForce172
Copy link
Copy Markdown

Does what the title says. Accompaniment to scp-fs2open/fs2open.github.com#7334 to make sure that users have the necessary dlls installed when we start compiling dynamically.

Copy link
Copy Markdown
Contributor

@notimaginative notimaginative left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to support the x86 and arm64 versions as well.

Also the exe should definitely NOT be bundled with KNet. There are permalinks available for them which should be used with a download task, as needed.

@Shivansps
Copy link
Copy Markdown
Member

Shivansps commented Apr 1, 2026

Yes i agree, there is no need to embed the redistributable, it can be downloaded. In fact eventually i want to get rid of all embedded executables.

You did it ok, but instead of embedding it, download it, something like this:

//Determine the cpu arch for vcredist that we need to download, if we need to download, from the FSO build arch NOT the host cpu arch.
//Because you can run x86 on x64/arm64 and x64 on arm64
foreach(var ex in newBuild.executables)
{
if(ex.arch == FsoExecArch.x86)
{
//We have a x86 build check if the vcredist is installed
}
...
}

//Download VC redist
var fileTask = new TaskItemViewModel(); // Crete new task
await Dispatcher.UIThread.InvokeAsync(() => TaskList.Insert(0, fileTask)); //insert task into this job TaskList
Info = "Tasks: " + ProgressCurrent + "/" + (++ProgressBarMax); //Update progress

var destPath = Path.Combine(KnUtils.GetKnossosDataFolderPath(),"{filename}"); //save to knossos data folder in appdata

//not sure if these are the right ones please check
//https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
//https://aka.ms/vc14/vc_redist.x64.exe //this install both arm64 and x64 it says
//https://aka.ms/vc14/vc_redist.x86.exe
//https://aka.ms/vc14/vc_redist.arm64.exe

vas fileUrl = "";
var result = await fileTask.DownloadFile(fileUrl, destPath, "Downloading VCRedist", false, null, cancellationTokenSource); // Start and await to finish

//Always check for cancel before executing the file
if (cancellationTokenSource.IsCancellationRequested)
{
throw new TaskCanceledException();
}

if (result.HasValue && result.Value)
{
//Execute the installer
Info = "Tasks: " + (++ProgressCurrent) + "/" + ProgressBarMax;
}
else
{
throw new Exception("Error while downloading file: " + fileUrl);
}

also, feel free to create one or more private functions inside InstallBuild.cs if you think will make the code shorter.

@notimaginative notimaginative dismissed their stale review April 3, 2026 23:13

Looks okay as far as I can tell, but ShivanSpS knows the code far better than I do so I'll leave the review to him.

I did verify that the x64 vcredist install includes both x64 and arm64 libs, and that the x64 registry key checked here exists on an arm64 system as well, so there's no issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants