From 3a9a3b7e47d09be63152d561a1bb6db4dc50b88b Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Thu, 14 Jan 2021 00:40:02 +0100 Subject: [PATCH] feat: UWP buildable and deployable under Any CPU - Setting ShouldBuild and ShouldDeploy on the UWP project under AnyCPU configuration for easier switching between projects --- .../UnoSolutionWizard.cs | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/SolutionTemplate/UnoSolutionTemplate.Wizard/UnoSolutionWizard.cs b/src/SolutionTemplate/UnoSolutionTemplate.Wizard/UnoSolutionWizard.cs index e187279d981a..a1cac3387722 100644 --- a/src/SolutionTemplate/UnoSolutionTemplate.Wizard/UnoSolutionWizard.cs +++ b/src/SolutionTemplate/UnoSolutionTemplate.Wizard/UnoSolutionWizard.cs @@ -4,9 +4,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Security.Cryptography.Xml; -using System.Text; -using System.Threading.Tasks; using EnvDTE; using EnvDTE80; using Microsoft.VisualStudio.TemplateWizard; @@ -44,6 +41,7 @@ public void RunFinished() OpenWelcomePage(); SetStartupProject(); + SetUWPAnyCPUBuildableAndDeployable(); SetDefaultConfiguration(); } @@ -79,6 +77,38 @@ private void SetStartupProject() } } + private void SetUWPAnyCPUBuildableAndDeployable() + { + if (_dte?.Solution.SolutionBuild is SolutionBuild2 val) + { + try + { + var anyCpuConfig = val.SolutionConfigurations + .Cast() + .FirstOrDefault(c => c.Name == "Debug" && c.PlatformName == "Any CPU"); + + foreach (SolutionConfiguration2 solutionConfiguration2 in val.SolutionConfigurations) + { + foreach (SolutionContext solutionContext in anyCpuConfig.SolutionContexts) + { + if (solutionContext.ProjectName.EndsWith(".UWP.csproj")) + { + solutionContext.ShouldBuild = true; + solutionContext.ShouldDeploy = true; + } + } + } + } + catch (Exception) + { + } + } + else + { + throw new InvalidOperationException(); + } + } + private void SetDefaultConfiguration() {