Skip to content

Commit

Permalink
[templates] remove Directory.Build.targets, add @(ProjectCapability) (#…
Browse files Browse the repository at this point in the history
…1433)

* [templates] remove Directory.Build.targets, add @(ProjectCapability)

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`

* Remove CI trimming workaround

* Update WinUI.SingleProject.targets

* Update Directory.Build.targets

Co-authored-by: Jonathan Dick <jond@hey.com>
Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
  • Loading branch information
3 people committed Jul 26, 2021
1 parent 84e84c8 commit f835baf
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 74 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>
22 changes: 1 addition & 21 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,7 @@
<Import Project="eng\AndroidX.targets" />
<Import Project="eng\Microsoft.Extensions.targets" />

<!-- Temporarily disable the linker for net6.0-ios and net6.0-maccatalyst until we get machine pools with Big Sur and Xcode 12.5 is stable -->
<PropertyGroup Condition=" '$(CI)' == 'true' ">
<PublishTrimmed Condition=" '$(TargetFramework)' == 'net6.0-ios' or '$(TargetFramework)' == 'net6.0-maccatalyst' ">false</PublishTrimmed>
</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" />

<!-- semi HACK: by default, WinUI includes all @(None) with .bmp/.png as @(Content) and adds that to the .pri -->
Expand All @@ -39,4 +19,4 @@
<FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" TargetingPackVersion="10.0.18362.19" />
</ItemGroup>

</Project>
</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
26 changes: 0 additions & 26 deletions src/Templates/src/templates/maui-blazor/Directory.Build.targets

This file was deleted.

26 changes: 0 additions & 26 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,5 @@
<!-- Workarounds for WinUI when $(SingleProject) is true -->
<Project>
<!-- Required - Overwrite tasks that are not needed when multitargeting -->
<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 f835baf

Please sign in to comment.