Files
UnrealEngineUWP/Engine/Source/Programs/UnrealVS/UnrealVS.Shared/BuildStartupProject.cs
Ben Marsh 0f44b8b446 UnrealVS: Fix thread safety warnings when building.
Mainly done by naively adding ThreadUtils.ThrowIfNotOnUIThread() in places where warnings occur and code looks likely to be on UI thread, then tested a few basic operations in the experimental instance. Remaining warnings look more problematic to solve; I will test these more closely and fix them in a future change.

[CL 17091658 by Ben Marsh in ue5-main branch]
2021-08-06 20:29:50 -04:00

63 lines
2.0 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
namespace UnrealVS
{
class BuildStartupProject
{
const int BuildStartupProjectButtonID = 0x1070;
public BuildStartupProject()
{
// BuildStartupProjectButton
{
var CommandID = new CommandID(GuidList.UnrealVSCmdSet, BuildStartupProjectButtonID);
var BuildStartupProjectButtonCommand = new MenuCommand(new EventHandler(BuildStartupProjectButtonHandler), CommandID);
UnrealVSPackage.Instance.MenuCommandService.AddCommand(BuildStartupProjectButtonCommand);
}
}
/// Called when 'BuildStartupProject' button is clicked
void BuildStartupProjectButtonHandler(object Sender, EventArgs Args)
{
ThreadHelper.ThrowIfNotOnUIThread();
// Grab the current startup project
UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out IVsHierarchy ProjectHierarchy);
if (ProjectHierarchy != null)
{
var StartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy);
if (StartupProject != null)
{
// Get the active solution configuration
var ActiveConfiguration =
(SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration;
var SolutionConfiguration = ActiveConfiguration.Name;
var SolutionPlatform = ActiveConfiguration.PlatformName;
// Combine the active solution configuration and platform into a string that Visual Studio
// can use to build the startup project (e.g. "Release|x64")
var BuildPlatformAndConfiguration = SolutionConfiguration + "|" + SolutionPlatform;
// Make sure the Output window is visible
UnrealVSPackage.Instance.DTE.ExecuteCommand("View.Output");
// Kick off the build!
UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.BuildProject(
BuildPlatformAndConfiguration,
StartupProject.UniqueName,
WaitForBuildToFinish: false);
}
}
}
}
}