[templates] remove Directory.Build.targets, add @(ProjectCapability)#1433
Conversation
| 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" /> |
There was a problem hiding this comment.
@tondat is suggesting in Teams we might change to:
<ItemGroup>
<ProjectCapability Include="MauiSingleProject" />
<ProjectCapability Include="LaunchProfilesGroupByPlatformFilters"/>
<ProjectCapability Include="BuildOnlyActiveTargetFrameworkOnDebug" />
</ItemGroup>Also, a target that would improve the developer loop (until we get the appropriate Project System changes);
<Target Name="ComputeXamarinTargetFrameworks" BeforeTargets="_ComputeTargetFrameworkItems">
<PropertyGroup>
<TargetFrameworks Condition="'$(TargetFramework)' == '' AND '$(_SelectedTargetFramework)' != ''">$(_SelectedTargetFramework)</TargetFrameworks>
</PropertyGroup>
<Message Text="SelectedTargetFramework = $(_SelectedTargetFramework)" />
<Message Text="TargetFramework = $(TargetFramework)" />
<Message Text="TargetFrameworks = $(TargetFrameworks)" />
<Message Text="BuildingInsideVisualStudio = $(BuildingInsideVisualStudio)" />
</Target>I'll want to test this target a bit, and probably refactor it.
There was a problem hiding this comment.
Final capabilities might be:
<ItemGroup>
<ProjectCapability Include="MauiSingleProject" />
<ProjectCapability Include="XamarinStaticLaunchProfiles" Condition=" '$(VisualStudioVersion)' < '17.0' " />
<ProjectCapability Include="LaunchProfilesGroupByPlatformFilters" Condition=" '$(VisualStudioVersion)' >= '17.0' " />
<ProjectCapability Include="BuildOnlyActiveTargetFrameworkOnDebug" />
</ItemGroup>LaunchProfilesGroupByPlatformFilters is Dev17-only, and you can't have XamarinStaticLaunchProfiles at the same time.
c936c6d to
c53e06d
Compare
ComputeXamarinTargetFrameworks targetIt does not appear that adding this target will currently work: This needs to run in the "outer" build when ProjectCapabilityI think the current logic here is right, but my IDE isn't working as expected. I don't have a way to select my Android emulator, it fails to deploy when I hit the Play button: TBD if this is an IDE issue, or something else related to workloads. |
|
|
c53e06d to
b5033f1
Compare
b5033f1 to
db88124
Compare
| @@ -10,20 +10,6 @@ | |||
| <PublishTrimmed Condition=" '$(TargetFramework)' == 'net6.0-ios' or '$(TargetFramework)' == 'net6.0-maccatalyst' ">false</PublishTrimmed> | |||
There was a problem hiding this comment.
Maybe. I know I did in my pr and I think the issue was that we were using Xcode 12. Now with Xcode 13 all over, we probably can remove it.
| <Target Name="ValidateWinUIPlatform" /> | ||
| <Target Name="BinPlaceBootstrapDll" /> |
There was a problem hiding this comment.
Does this come in late enough? The WinUI targets from the nugets create this target, and we have to overwrite with a dummy.
There was a problem hiding this comment.
This is imported as late as a workload can do it:
We'd need to test, but if it doesn't work we'd have to put the Directory.Build.targets back.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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`
24a67a3 to
72f5134
Compare

Description of Change
The
Directory.Build.targetsfiles in the templates were a collectionof 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.targetsfrom templates now, andconsolidate
@(ProjectCapability)so this is defined by the workload.The following capabilities are defined for the IDE:
MauiMauiSingleProject,LaunchProfiles,XamarinStaticLaunchProfileswhen
$(SingleProject)istrueThese new capabilities are defined to identify projects (via telemetry)
that bring in portions of .NET MAUI:
MauiAssetsMauiBlazorMauiCoreMauiEssentialsOther changes:
$(_KeepLaunchProfiles)is set by default when$(SingleProject)is
true.WinUI.SingleProject.targets.sdk-manifestscasing forsrc/DotNet/DotNet.csproj -t:InstallPR Checklist
Does this PR touch anything that might affect accessibility?
No