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`
* When `$(SingleProject)` is `true`:
  * `MauiSingleProject`, `LaunchProfiles`
  * `XamarinStaticLaunchProfiles` older than Dev17
  * `LaunchProfilesGroupByPlatformFilters` otherwise

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 30, 2021
1 parent f245183 commit b5033f1
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 57 deletions.
6 changes: 6 additions & 0 deletions .nuspec/Microsoft.Maui.Controls.SingleProject.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

<PropertyGroup Condition=" '$(SingleProject)' == 'true' ">
<PlatformsProjectFolder Condition=" '$(PlatformsProjectFolder)' == '' ">Platforms\</PlatformsProjectFolder>
<!-- Required - Enable Launch Profiles for .NET 6 iOS/Android -->
<_KeepLaunchProfiles>true</_KeepLaunchProfiles>
<!-- Android -->
<EnableDefaultAndroidItems>false</EnableDefaultAndroidItems>
<AndroidProjectFolder Condition=" '$(AndroidProjectFolder)' == '' ">$(PlatformsProjectFolder)Android\</AndroidProjectFolder>
Expand Down Expand Up @@ -78,6 +80,10 @@
<ItemGroup Condition=" '$(SingleProject)' == 'true' ">
<ProjectCapability Include="MauiSingleProject" />
<ProjectCapability Include="LaunchProfiles" />
<!-- If VS is older than Dev17 -->
<ProjectCapability Include="XamarinStaticLaunchProfiles" Condition=" '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' &lt; '17.0' " />
<!-- Otherwise define LaunchProfilesGroupByPlatformFilters by default -->
<ProjectCapability Include="LaunchProfilesGroupByPlatformFilters" Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &gt;= '17.0' " />
</ItemGroup>

</Project>
14 changes: 0 additions & 14 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

<PropertyGroup Condition="'$(SingleProject)' == 'true'">
<!-- Required - Enable Launch Profiles for .NET 6 iOS/Android -->
<_KeepLaunchProfiles>true</_KeepLaunchProfiles>
</PropertyGroup>
<ItemGroup Condition="'$(SingleProject)' == 'true'">
<!-- Required - Setup Single Project features -->
<ProjectCapability Include="MauiSingleProject" />

<!-- 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>

<!-- HACK: Prevent the Platform checks -->
<Target Name="ValidateWinUIPlatform" />
<Target Name="BinPlaceBootstrapDll" />
Expand Down
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,12 @@
<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="Maui" Condition=" '$(UseMaui)' == 'true' " />
<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 b5033f1

Please sign in to comment.