Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[workload] move SingleProject.targets to Microsoft.Maui.Sdk #3281

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

jonathanpeppers
Copy link
Member

Description of Change

Fixes: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1428787

Currently, if you mimic a design-time build that would happen inside
Visual Studio:

> dotnet new maui
> dotnet build -f net6.0-android -t:Compile -p:DesignTimeBuild=true -p:BuildingInsideVisualStudio=true -p:SkipCompilerExecution=true --no-restore

This fails because of the --no-restore flag:

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.101-preview.11.74\tools\Xamarin.Android.Common.targets(511,3):
error XA1018: Specified AndroidManifest file does not exist: foo\AndroidManifest.xml.

I was able to reproduce this failure in our template tests in
dotnet.cake.

In 974cac4, several of .NET MAUI's MSBuild targets were moved to
library-packs, such as Microsoft.Maui.Controls.Build.Tasks. This
means that files like Microsoft.Maui.Controls.SingleProject.targets
won't be evaluated until NuGet restore completes.

To solve this problem:

  • Move Microsoft.Maui.Controls.SingleProject.targets and
    Microsoft.Maui.Controls.DefaultItems.targets to the
    Microsoft.Maui.Sdk pack. These .targets are no longer affected by
    $(MauiVersion), and just exist in the workload.

  • Stop importing these files in Microsoft.Maui.Controls.targets in
    Microsoft.Maui.Controls.Build.Tasks.

  • Import these files in Microsoft.Maui.Sdk.After.targets.

Overall, I think the loss of $(MauiVersion) is fine for the moved
.targets files, because they are not invoking MSBuild tasks.

The design-time build tests now complete successfully.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

Nope

@Eilon Eilon added the area-setup Installation, setup, requirements, maui-check, workloads, platform support label Nov 5, 2021
Fixes: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1428787

Currently, if you mimic a design-time build that would happen inside
Visual Studio:

    > dotnet new maui
    > dotnet build -f net6.0-android -t:Compile -p:DesignTimeBuild=true -p:BuildingInsideVisualStudio=true -p:SkipCompilerExecution=true --no-restore

This fails because of the `--no-restore` flag:

    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.101-preview.11.74\tools\Xamarin.Android.Common.targets(511,3):
    error XA1018: Specified AndroidManifest file does not exist: foo\AndroidManifest.xml.

I was able to reproduce this failure in our template tests in
`dotnet.cake`.

In 974cac4, several of .NET MAUI's MSBuild targets were moved to
`library-packs`, such as `Microsoft.Maui.Controls.Build.Tasks`. This
means that files like `Microsoft.Maui.Controls.SingleProject.targets`
won't be evaluated until NuGet restore completes.

To solve this problem:

* Move `Microsoft.Maui.Controls.SingleProject.targets` and
  `Microsoft.Maui.Controls.DefaultItems.targets` to the
  `Microsoft.Maui.Sdk` pack. These `.targets` are no longer affected by
  `$(MauiVersion)`, and just exist in the workload.

* Stop importing these files in `Microsoft.Maui.Controls.targets` in
  `Microsoft.Maui.Controls.Build.Tasks`.

* Import these files in `Microsoft.Maui.Sdk.After.targets`.

Overall, I think the loss of `$(MauiVersion)` is fine for the moved
`.targets` files, because they are not invoking MSBuild tasks.

The design-time build tests now complete successfully.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review November 5, 2021 22:07
@mattleibow mattleibow merged commit 81d6107 into dotnet:main Nov 9, 2021
@jonathanpeppers jonathanpeppers deleted the design-time-builds branch November 9, 2021 17:21
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
@samhouts samhouts added the fixed-in-6.0.101-preview.11.3 Look for this fix in 6.0.101-preview.11.3! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-setup Installation, setup, requirements, maui-check, workloads, platform support fixed-in-6.0.101-preview.11.3 Look for this fix in 6.0.101-preview.11.3!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants