Skip to content

Commit

Permalink
[templates] remove Directory.Build.targets, add @(ProjectCapability)
Browse files Browse the repository at this point in the history
The `Directory.Build.targets` files in the templates were a collection
of workarounds that were needed until .NET MAUI was a workload. When
.NET MAUI was a NuGet package, this was the only way to set required
values for the IDE before NuGet restore. In the early days, you had to
unload/reload MAUI projects after NuGet restore.

We can remove `Directory.Build.targets` from templates now, and
consolidate `@(ProjectCapability)` so this is defined by the workload.

The following capabilities are defined for the IDE:

* `Maui`
* `MauiSingleProject`, `LaunchProfiles`, `XamarinStaticLaunchProfiles`
  when `$(SingleProject)` is `true`

These new capabilities are defined to identify projects (via telemetry)
that bring in portions of .NET MAUI:

* `MauiAssets`
* `MauiBlazor`
* `MauiCore`
* `MauiEssentials`

Other changes:

* `$(_KeepLaunchProfiles)` is set by default when `$(SingleProject)`
  is `true`.
* WinUI workarounds are moved into `WinUI.SingleProject.targets`.
* Fixed `sdk-manifests` casing for `src/DotNet/DotNet.csproj -t:Install`
  • Loading branch information
jonathanpeppers committed Jun 23, 2021
1 parent aa8cc82 commit c936c6d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 43 deletions.
8 changes: 8 additions & 0 deletions .nuspec/Microsoft.Maui.Controls.SingleProject.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- "Single Project" support -->
<Project>
<PropertyGroup Condition=" '$(SingleProject)' == 'true' ">
<!-- Required - Enable Launch Profiles for .NET 6 iOS/Android -->
<_KeepLaunchProfiles>true</_KeepLaunchProfiles>
<!-- Android -->
<EnableDefaultAndroidItems>false</EnableDefaultAndroidItems>
<AndroidProjectFolder Condition=" '$(AndroidProjectFolder)' == '' ">Android\</AndroidProjectFolder>
Expand Down Expand Up @@ -60,5 +62,11 @@
<ItemGroup Condition=" '$(SingleProject)' == 'true' ">
<ProjectCapability Include="MauiSingleProject" />
<ProjectCapability Include="LaunchProfiles" />
<!--
Optional - Enables a list of TFM's and device categories in the debug menu.
This allows easily toggling of debug target TFM by selecting the platform.
If removed, top level debug targets show as a list of devices for the selected TFM.
-->
<ProjectCapability Include="XamarinStaticLaunchProfiles" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/DotNet/DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<_WorkloadFiles Include="$(_InstallTempDirectory)data/WorkloadManifest.*" />
</ItemGroup>
<CopyWorkloadFiles
Name="Microsoft.NET.Sdk.Maui"
Name="microsoft.net.sdk.maui"
Files="@(_WorkloadFiles)"
WorkloadDirectory="$(MSBuildExtensionsPath)../../sdk-manifests/$(DotNetPreviewVersionBand)"
VersionBand="$(DotNetPreviewVersionBand)"
Expand Down
21 changes: 0 additions & 21 deletions src/Templates/src/templates/maui-blazor/Directory.Build.targets

This file was deleted.

21 changes: 0 additions & 21 deletions src/Templates/src/templates/maui-mobile/Directory.Build.targets

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@
<Analyzer Include="$(MSBuildThisFileDirectory)../targets/Microsoft.Maui.Controls.Xaml.dll" />
<Analyzer Include="$(MSBuildThisFileDirectory)../targets/Microsoft.Maui.Controls.SourceGen.dll" />
</ItemGroup>
<!-- @(ProjectCapability) used to identify parts of Maui -->
<ItemGroup>
<ProjectCapability Include="MauiAssets" Condition=" '$(UseMaui)' == 'true' or '$(UseMauiAssets)' == 'true' " />
<ProjectCapability Include="MauiBlazor" Condition=" '$(UsingMicrosoftNETSdkRazor)' == 'true' " />
<ProjectCapability Include="MauiCore" Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' " />
<ProjectCapability Include="MauiEssentials" Condition=" '$(UseMaui)' == 'true' or '$(UseMauiEssentials)' == 'true' " />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- Workarounds for WinUI when $(SingleProject) is true -->
<Project>
<!-- Required - Overwrite tasks that are not needed when multitargeting -->
<Target Name="ValidateWinUIPlatform" />
<Target Name="BinPlaceBootstrapDll" />
</Project>
1 change: 1 addition & 0 deletions src/Workload/Microsoft.Maui.Controls.Sdk/Sdk/WinUI.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
/>
</ItemGroup>
</Target>
<Import Project="WinUI.SingleProject.targets" Condition=" '$(SingleProject)' == 'true' " />
</Project>

0 comments on commit c936c6d

Please sign in to comment.