Skip to content

Commit c50966c

Browse files
authored
Merge pull request #54 from CommunityToolkit/feature/multitarget/netstandard
Add netstandard support to MultiTarget system
2 parents 6bc1f28 + 4692773 commit c50966c

File tree

46 files changed

+355
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+355
-376
lines changed

CommunityToolkit.Tooling.SampleGen.Tests/CommunityToolkit.Tooling.SampleGen.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
<LangVersion>preview</LangVersion>
99
</PropertyGroup>
1010

11-
<ItemGroup>
12-
<Compile Include="..\GlobalUsings.cs" Link="GlobalUsings.cs" />
13-
</ItemGroup>
14-
1511
<ItemGroup>
1612
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
1713
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1814
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
1915
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
2016
</ItemGroup>
2117

18+
<ItemGroup>
19+
<Compile Include="..\GlobalUsings.cs" Link="GlobalUsings.cs" />
20+
</ItemGroup>
21+
2222
<ItemGroup>
2323
<ProjectReference Include="..\CommunityToolkit.Tooling.SampleGen\CommunityToolkit.Tooling.SampleGen.csproj" />
2424
</ItemGroup>

CommunityToolkit.Tooling.SampleGen/ToolkitSampleMetadataGenerator.Documentation.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ public static class ToolkitDocumentRegistry
245245
{{
246246
public static System.Collections.Generic.IEnumerable<{typeof(ToolkitFrontMatter).FullName}> Execute()
247247
{{
248-
{
249-
string.Join("\n ", sampleMetadata.Select(FrontMatterToRegistryCall).ToArray())
250-
}
248+
{string.Join("\n ", sampleMetadata.Select(FrontMatterToRegistryCall).ToArray())}
251249
}}
252250
}}";
253251
}

CommunityToolkit.Tooling.TestGen.Tests/CommunityToolkit.Tooling.TestGen.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99

10-
<ItemGroup>
11-
<Compile Include="..\GlobalUsings.cs" Link="GlobalUsings.cs" />
12-
</ItemGroup>
13-
1410
<ItemGroup>
1511
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
1612
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1713
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
1814
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
1915
</ItemGroup>
2016

17+
<ItemGroup>
18+
<Compile Include="..\GlobalUsings.cs" Link="GlobalUsings.cs" />
19+
</ItemGroup>
20+
2121
<ItemGroup>
2222
<ProjectReference Include="..\CommunityToolkit.Tooling.TestGen\CommunityToolkit.Tooling.TestGen.csproj" />
2323
</ItemGroup>

MultiTarget/DefinedConstants.props

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project>
2+
<PropertyGroup>
3+
<DefineConstants Condition="'$(HasWinUI)' == 'true'">$(DefineConstants);WINUI$(WinUIMajorVersion);</DefineConstants>
4+
5+
<DefineConstants Condition="'$(IsUno)' == 'true'">$(DefineConstants);HAS_UNO;</DefineConstants>
6+
<DefineConstants Condition="'$(IsUwp)' == 'true'">$(DefineConstants);WINDOWS_UWP;NETFX_CORE;</DefineConstants>
7+
<DefineConstants Condition="'$(IsWinAppSdk)' == 'true'">$(DefineConstants);WINDOWS_WINAPPSDK;WINAPPSDK</DefineConstants>
8+
<DefineConstants Condition="'$(IsWasm)' == 'true'">$(DefineConstants);__WASM__;HAS_UNO_WASM;</DefineConstants>
9+
<DefineConstants Condition="'$(IsDroid)' == 'true'">$(DefineConstants);__ANDROID__;</DefineConstants>
10+
<DefineConstants Condition="'$(IsiOS)' == 'true'">$(DefineConstants);__IOS__;</DefineConstants>
11+
<DefineConstants Condition="'$(IsMacOS)' == 'true'">$(DefineConstants);__MACOS__;</DefineConstants>
12+
<DefineConstants Condition="'$(IsWpf)' == 'true'">$(DefineConstants);HAS_UNO_SKIA;__SKIA__;WINDOWS_WPF;</DefineConstants>
13+
<DefineConstants Condition="'$(IsGtk)' == 'true'">$(DefineConstants);HAS_UNO_SKIA;__SKIA__;__GTK__;</DefineConstants>
14+
15+
<DefineConstants Condition="$(IsAllExperimentHead) == 'true'">$(DefineConstants);ALL_SAMPLES</DefineConstants>
16+
</PropertyGroup>
17+
</Project>

MultiTarget/EnabledMultiTargets.props

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!-- Imports the <MultiTarget> values for the current project. -->
2+
<Project>
3+
<PropertyGroup>
4+
<MultiTargetIsSampleProject Condition="$(MSBuildProjectName.EndsWith('.Samples')) == 'true'">true</MultiTargetIsSampleProject>
5+
</PropertyGroup>
6+
7+
<Import Project="$(MSBuildProjectDirectory)\MultiTarget.props" Condition="Exists('$(MSBuildProjectDirectory)\MultiTarget.props') AND '$(MultiTarget)' == ''" />
8+
9+
<!-- If in a sample project, pull the MultiTarget settings from the source project. -->
10+
<!-- This behavior is also implemented in GeneratedAllProjectReferences.ps1 for <ProjectReference> generation. -->
11+
<Import Project="$(MSBuildProjectDirectory)/../src/MultiTarget.props" Condition="$(MultiTargetIsSampleProject) == 'true' AND !Exists('$(MSBuildProjectDirectory)\MultiTarget.props') AND Exists('$(MSBuildProjectDirectory)/../src/MultiTarget.props') AND '$(MultiTarget)' == ''" />
12+
13+
<Import Project="$(MSBuildThisFileDirectory)\Defaults.props" Condition="'$(MultiTarget)' == ''" />
14+
</Project>

MultiTarget/GenerateAllProjectReferences.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Param (
33
[string]$projectPropsOutputDir = "$PSScriptRoot/Generated",
44

55
[Parameter(HelpMessage = "Only projects that support these targets will have references generated for use by deployable heads.")]
6-
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android")
7-
)
6+
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard")
7+
)
88

99
$preWorkingDir = $pwd;
1010
Set-Location $PSScriptRoot;

MultiTarget/GenerateMultiTargetAwareProjectReferenceProps.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Param (
1818
[string]$projectRootPlaceholder = "[ProjectRoot]",
1919

2020
[Parameter(HelpMessage = "Only projects that support these targets will have references generated for use by deployable heads.")]
21-
[ValidateSet("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android")]
22-
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android")
21+
[ValidateSet("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard")]
22+
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard")
2323
)
2424

2525
$preWorkingDir = $pwd;
@@ -58,6 +58,7 @@ $templateContents = $templateContents -replace [regex]::escape("[CanTargetLinuxG
5858
$templateContents = $templateContents -replace [regex]::escape("[CanTargetMacOS]"), "'$(ShouldMultiTarget "macos")'";
5959
$templateContents = $templateContents -replace [regex]::escape("[CanTargetiOS]"), "'$(ShouldMultiTarget "ios")'";
6060
$templateContents = $templateContents -replace [regex]::escape("[CanTargetDroid]"), "'$(ShouldMultiTarget "droid")'";
61+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetNetstandard]"), "'$(ShouldMultiTarget "netstandard")'";
6162

6263
# Save to disk
6364
Set-Content -Path $outputPath -Value $templateContents;

MultiTarget/Library.props

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!-- An end-to-end setup of the MultiTarget system for library projects. -->
2+
<Project>
3+
<PropertyGroup>
4+
<IsLibraryProject>true</IsLibraryProject>
5+
<IsDeployableHead>false</IsDeployableHead>
6+
</PropertyGroup>
7+
8+
<!-- Get the enabled MultiTarget features for this project / run -->
9+
<Import Project="$(ToolingDirectory)\MultiTarget\EnabledMultiTargets.props" />
10+
<Import Project="$(ToolingDirectory)\MultiTarget\EnabledTargetFrameworks.props" />
11+
12+
<!-- Use <MultiTarget> values to define <TargetFrameworks> -->
13+
<Import Project="$(ToolingDirectory)\MultiTarget\MultiTargetToTargetFramework.props" />
14+
15+
<!-- Enable project identifiers -->
16+
<Import Project="$(ToolingDirectory)\MultiTarget\WinUI.TargetVersion.props" />
17+
<Import Project="$(ToolingDirectory)\MultiTarget\MultiTargetIdentifiers.props" />
18+
<Import Project="$(ToolingDirectory)\MultiTarget\DefinedConstants.props" />
19+
20+
<!-- Add platform package dependencies -->
21+
<Import Project="$(ToolingDirectory)\MultiTarget\PackageReferences\Netstandard.props" Condition="$(IsNetstandard) == 'true'" />
22+
<Import Project="$(ToolingDirectory)\MultiTarget\PackageReferences\Uno.props" Condition="$(IsUno) == 'true'" />
23+
<Import Project="$(ToolingDirectory)\MultiTarget\PackageReferences\Uwp.props" Condition="$(IsUwp) == 'true'"/>
24+
<Import Project="$(ToolingDirectory)\MultiTarget\PackageReferences\WinAppSdk.props" Condition="$(IsWinAppSdk) == 'true'"/>
25+
26+
<!-- Configure WinUI -->
27+
<Import Project="$(ToolingDirectory)\MultiTarget\WinUI.AutoIncludeXamlPages.props" Condition="$(HasWinUI) == 'true'" />
28+
<Import Project="$(ToolingDirectory)\MultiTarget\WinUI.Extra.props" Condition="$(HasWinUI) == 'true'" />
29+
30+
<!-- Import Uno and native dependencies for all multitargeted library projects. -->
31+
<Import Project="$(MSBuildProjectDirectory)\Dependencies.props" Condition="Exists('$(MSBuildProjectDirectory)\Dependencies.props')" />
32+
</Project>

0 commit comments

Comments
 (0)