Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update script to add API test projects and add empty dependency list in FeatureArea.props file #3474

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 50 additions & 15 deletions tools/GenerateNewControlProject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,38 @@ foreach ($file in $files)
# Add project to FeatureAreas.props
$featureAreasProps = $muxControlsDir + "\FeatureAreas.props";
[xml]$xml = Get-Content $featureAreasProps
foreach ($group in $xml.Project.PropertyGroup)
$featureEnabledName = "Feature" + $controlName + "Enabled"
foreach ($group in $xml.Project.ChildNodes)
{
if ($group.Attributes['Condition'].Value -ne $null -and $group.Attributes['Condition'].Value.Contains("(SolutionName) != 'MUXControlsInnerLoop'"))
if($group.NodeType -eq "Comment")
{
$featureEnabledName = "Feature" + $controlName + "Enabled"
$enabled = $xml.CreateElement($featureEnabledName, $xml.Project.NamespaceURI);
$enabled.AppendChild($xml.CreateTextNode("true"))
$group.AppendChild($enabled);
# Get comment before list of all areas
if($null -ne $group.NextSibling.Attributes -and $null -ne $group.NextSibling.Attributes['Condition'].Value -and $group.NextSibling.Attributes['Condition'].Value.Contains("(SolutionName) != 'MUXControlsInnerLoop'"))
{
# Comment for dependencies
$controlDependenciesComment = $xml.CreateComment(" Dependencies for $($controlName) ")
$xml.Project.InsertBefore($controlDependenciesComment, $group);

# Control dependencies list
$controlDependenciesNode = $xml.CreateElement("PropertyGroup",$xml.Project.NamespaceURI);
$controlDependenciesCondition = "Exists('InnerLoopAreas.props') And `$(SolutionName) == 'MUXControlsInnerLoop' And `$(" + $featureEnabledName + ") == 'true'"
AddAttribute $xml $controlDependenciesNode "Condition" $controlDependenciesCondition
# Make node have empty content and not be a one liner
$controlDependenciesNode.InnerText = "";
$xml.Project.InsertBefore($controlDependenciesNode, $group);
}
}else
{
# Add new control to list of all controls to build
if ($null -ne $group.Attributes['Condition'].Value -and $group.Attributes['Condition'].Value.Contains("(SolutionName) != 'MUXControlsInnerLoop'"))
{
$enabled = $xml.CreateElement($featureEnabledName, $xml.Project.NamespaceURI);
$enabled.AppendChild($xml.CreateTextNode("true"));
$group.AppendChild($enabled);
}
}
}

$xml.Save($featureAreasProps)

# Add project to MUX.vcxproj
Expand All @@ -81,6 +103,7 @@ foreach ($group in $xml.Project.ImportGroup)
$import = $xml.CreateElement("Import", $xml.Project.NamespaceURI);
AddAttribute $xml $import "Project" "..\$controlName\$controlName.vcxitems"
AddAttribute $xml $import "Label" "Shared"
AddAttribute $xml $import "Condition" "`$($($featureEnabledName)) == 'true' Or `$($($featureEnabledName)) == 'productOnly'"
$group.AppendChild($import);
}
}
Expand All @@ -90,9 +113,9 @@ $xml.Save($muxProject)
$testProject = $muxControlsDir + "\test\MUXControls.Test\MUXControls.Test.Shared.targets";
[xml]$xml = Get-Content $testProject
$import = $xml.CreateElement("Import", $xml.Project.NamespaceURI);
AddAttribute $xml $import "Project" "`$(MSBuildThisFileDirectory)\..\..\dev\$controlName\InteractionTests\$($controlName)_InteractionTests.projitems"
AddAttribute $xml $import "Project" "..\..\dev\$controlName\InteractionTests\$($controlName)_InteractionTests.projitems"
AddAttribute $xml $import "Label" "Shared"
AddAttribute $xml $import "Condition" "`$(Feature$($controlName)Enabled) == 'true'"
AddAttribute $xml $import "Condition" "`$($($featureEnabledName)) == 'true'"
$xml.Project.AppendChild($import);
$xml.Save($testProject)

Expand All @@ -102,7 +125,17 @@ $testAppProject = $muxControlsDir + "\test\MUXControlsTestApp\MUXControlsTestApp
$import = $xml.CreateElement("Import", $xml.Project.NamespaceURI);
AddAttribute $xml $import "Project" "`$(MSBuildThisFileDirectory)\..\..\dev\$controlName\TestUI\$($controlName)_TestUI.projitems"
AddAttribute $xml $import "Label" "Shared"
AddAttribute $xml $import "Condition" "`$(Feature$($controlName)Enabled) == 'true'"
AddAttribute $xml $import "Condition" "`$($($featureEnabledName)) == 'true'"
$xml.Project.AppendChild($import);
$xml.Save($testAppProject)

# Add API test project
$testAppProject = $muxControlsDir + "\test\MUXControlsTestApp\MUXControlsTestApp.Shared.targets";
[xml]$xml = Get-Content $testAppProject
$import = $xml.CreateElement("Import", $xml.Project.NamespaceURI);
AddAttribute $xml $import "Project" "`$(MSBuildThisFileDirectory)\..\..\dev\$controlName\APITests\$($controlName)_APITests.projitems"
AddAttribute $xml $import "Label" "Shared"
AddAttribute $xml $import "Condition" "`$($($featureEnabledName)) == 'true'"
$xml.Project.AppendChild($import);
$xml.Save($testAppProject)

Expand All @@ -117,7 +150,7 @@ $id = get-random
# We need double backslash for C# strings below
$cleanMuxControlsDir = $muxControlsDir.Replace("\","\\") + "\\"

echo "$cleanMuxControlsDir"
Write-Output "$cleanMuxControlsDir"

$assemblies=(
"System","EnvDTE","EnvDTE80"
Expand Down Expand Up @@ -158,16 +191,18 @@ namespace SolutionHelper
SolutionFolder newControlFolder = (SolutionFolder)devSolutionFolder.AddSolutionFolder("$controlName").Object;

Console.WriteLine("Adding projects:");
Console.WriteLine("Adding source");
Console.WriteLine(" -Adding source");
newControlFolder.AddFromFile("$($cleanMuxControlsDir)dev\\$($controlName)\\$($controlName).vcxitems");
Console.WriteLine("Adding test UI");
Console.WriteLine(" -Adding API test");
newControlFolder.AddFromFile("$($cleanMuxControlsDir)dev\\$($controlName)\\APITests\\$($controlName)_APITests.shproj");
Console.WriteLine(" -Adding test UI");
newControlFolder.AddFromFile("$($cleanMuxControlsDir)dev\\$($controlName)\\TestUI\\$($controlName)_TestUI.shproj");
Console.WriteLine("Adding interactions test");
Console.WriteLine(" -Adding interactions test");
newControlFolder.AddFromFile("$($cleanMuxControlsDir)dev\\$($controlName)\\InteractionTests\\$($controlName)_InteractionTests.shproj");
Console.WriteLine("Finished adding projects, saving solution");

solution.Close(true);
Console.WriteLine("Saved solution" + solutionName);
Console.WriteLine("Saved solution " + solutionName);
}
}
}
Expand All @@ -189,4 +224,4 @@ $solutionPaths = $vspath + "\Common7\IDE\PublicAssemblies";

Add-Type -ReferencedAssemblies $assemblies -TypeDefinition $source -Language CSharp

iex "[SolutionHelper.SolutionRegister$id]::Main()"
Invoke-Expression "[SolutionHelper.SolutionRegister$id]::Main()"
31 changes: 31 additions & 0 deletions tools/GenerateNewControlProjectFiles/APITests/NEWCONTROLTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using Common;
using System.Collections.Generic;
using Microsoft.UI.Xaml.Controls;
using MUXControlsTestApp.Utilities;

#if USING_TAEF
using WEX.TestExecution;
using WEX.TestExecution.Markup;
using WEX.Logging.Interop;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif

namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests
{

[TestClass]
public class NEWCONTROLTests : ApiTestBase
{
[TestMethod]
public void BasicTest()
{
Log.Comment("NEWCONTROL Basic Test");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>cb2352e2-d633-41a3-8cdc-b28731a4c490</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>NEWCONTROL_APITests</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)NEWCONTROLTests.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>cb2352e2-d633-41a3-8cdc-b28731a4c490</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="NEWCONTROL_APITests.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>