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

Better error message attempting to target net6.0-android from .NET 8 #8003

Closed
jpobst opened this issue May 1, 2023 · 1 comment · Fixed by #8047
Closed

Better error message attempting to target net6.0-android from .NET 8 #8003

jpobst opened this issue May 1, 2023 · 1 comment · Fixed by #8047
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Milestone

Comments

@jpobst
Copy link
Contributor

jpobst commented May 1, 2023

In #7900 we removed the ability to target net6.0-android from a .NET 8 install.

However if a user attempts this, they receive an incorrect error message:

.../Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools-net6 
.../Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore 

If they attempt to run dotnet workload restore as instructed, they receive:

.../8.0.100-preview.3/microsoft.net.sdk.android/WorkloadManifest.targets(7,5): error : Could not resolve SDK "Microsoft.Android.Sdk.net6". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
.../8.0.100-preview.3/microsoft.net.sdk.android/WorkloadManifest.targets(7,5): error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
.../8.0.100-preview.3/microsoft.net.sdk.android/WorkloadManifest.targets(7,5): error :   The NuGetSdkResolver did not resolve this SDK because there was no version specified in the project or global.json.
.../8.0.100-preview.3/microsoft.net.sdk.android/WorkloadManifest.targets(7,5): error :   MSB4276: The default SDK resolver failed to resolve SDK "Microsoft.Android.Sdk.net6" because directory "/Users/runner/hostedtoolcache/dotnet/sdk/8.0.100-preview.3.23178.7/Sdks/Microsoft.Android.Sdk.net6/Sdk" did not exist.

We need to provide a better error message to the user letting them know this scenario isn't possible rather than provide instructions that will not work.

This issue should be reproducible with the following TF:

<TargetFrameworks>net6.0-android;net8.0-android</TargetFrameworks>
@jpobst jpobst added the Area: App+Library Build Issues when building Library projects or Application projects. label May 1, 2023
@jpobst jpobst added this to the .NET 8 milestone May 1, 2023
@ghost ghost added the needs-triage Issues that need to be assigned. label May 1, 2023
@jpobst jpobst removed the needs-triage Issues that need to be assigned. label May 1, 2023
@jonathanpeppers
Copy link
Member

Hopefully next week, I'll have some info from the .NET SDK team to introduce something like:

https://github.com/dotnet/sdk/blob/8222c335dc288ce9b4d9f3525571701d7a382f7c/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.EolTargetFrameworks.targets#L28

We'd have some property like $(CheckEolWorkload) to opt out of it, but this would warn in the .NET 6 workload(s) and error in .NET 8 workload(s) if your $(TargetFrameworkVersion) is v6.0.

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue May 10, 2023
Context: https://aka.ms/maui-support-policy
Context: dotnet#8003

To be able to emit a new build warning:

    dotnet\sdk\6.0.409\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(35,5):
    warning NETSDK1138: The workload 'android' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy.

We can emit a new item group, such as:

    <ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
      <EolWorkload Include="android" Url="https://aka.ms/maui-support-policy" />
    </ItemGroup>

Changes in the .NET SDK can be found at: TBD

Where a new `_CheckForEolWorkloads` MSBuild target will emit the warning:

    <Target Name="_CheckForEolWorkloads" AfterTargets="_CheckForUnsupportedNETCoreVersion"
            Condition="'@(EolWorkload)' != '' and '$(CheckEolWorkloads)' == 'true'">
        <NETSdkWarning ResourceName="WorkloadIsEol"
                       FormatArguments="%(EolWorkload.Identity);$([MSBuild]::ValueOrDefault('%(EolWorkload.Url)', 'https://aka.ms/dotnet-core-support'))" />
    </Target>

This does not fully solve dotnet#8003 as future changes are likely needed in
the .NET 8 `android` workload.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue May 10, 2023
Context: https://aka.ms/maui-support-policy
Context: dotnet#8003

To be able to emit a new build warning:

    dotnet\sdk\6.0.409\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(35,5):
    warning NETSDK1138: The workload 'android' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy.

We can emit a new item group, such as:

    <ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
      <EolWorkload Include="android" Url="https://aka.ms/maui-support-policy" />
    </ItemGroup>

Changes in the .NET SDK can be found at: TBD

Where a new `_CheckForEolWorkloads` MSBuild target will emit the warning:

    <Target Name="_CheckForEolWorkloads" AfterTargets="_CheckForUnsupportedNETCoreVersion"
            Condition="'@(EolWorkload)' != '' and '$(CheckEolWorkloads)' == 'true'">
        <NETSdkWarning ResourceName="WorkloadIsEol"
                       FormatArguments="%(EolWorkload.Identity);$([MSBuild]::ValueOrDefault('%(EolWorkload.Url)', 'https://aka.ms/dotnet-core-support'))" />
    </Target>

This does not fully solve dotnet#8003 as future changes are likely needed in
the .NET 8 `android` workload.
jonpryor pushed a commit that referenced this issue May 16, 2023
Context: https://aka.ms/maui-support-policy
Context: #8003
Context: dotnet/sdk#32426

.NET Android is part of .NET MAUI, and the support policy for
.NET MAUI is:

> A major version of .NET MAUI receives support for a minimum of 6
> months after a successor (the next major release) ships.

We are now (roughly) at the "6 months after a successor ships" window:
[.NET MAUI for .NET 7.0 was released 2022-Nov-8][0], meaning support
for .NET MAUI for .NET 6.0 ends May 2023, i.e. "now".

dotnet/sdk#32426 adds support for an optional workload to specify
that it is no longer supported by adding an item to the
`@(EolWorkload)` item group:

	<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
	  <EolWorkload Include="android" Url="https://aka.ms/maui-support-policy" />
	</ItemGroup>

This will cause `dotnet build` to issue a new NETSDK1138 build warning:

	dotnet\sdk\6.0.409\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(35,5):
	warning NETSDK1138: The workload 'android' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy.

which will gracefully inform our customers that the version they're
using is no longer supported.  If necessary, the warning can be
disabled by setting the `$(CheckEolWorkloads)` MSBuild property to False.

TODO: This does not fully solve issue #8003 as future changes are
likely needed in the .NET 8 `android` workload.

[0]: https://devblogs.microsoft.com/dotnet/dotnet-maui-dotnet-7/
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue May 17, 2023
Fixes: dotnet#8003

Add a new `Eol.targets` file to be imported for `net6.0-android`
projects. It contains the necessary/minimal settings to emit the build
error:

    Microsoft.NET.EolTargetFrameworks.targets(35,5): error NETSDK1202:
    The workload 'android' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy.

We will probably need the latest .NET SDK to flow to us, in order to
write a test. I could only test locally by editing `.targets` files in
the .NET SDK.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue May 24, 2023
Fixes: dotnet#8003

Add a new `Eol.targets` file to be imported for `net6.0-android`
projects. It contains the necessary/minimal settings to emit the build
error:

    Microsoft.NET.EolTargetFrameworks.targets(35,5): error NETSDK1202:
    The workload 'android' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy.

We will probably need the latest .NET SDK to flow to us, in order to
write a test. I could only test locally by editing `.targets` files in
the .NET SDK.
jonpryor pushed a commit that referenced this issue May 26, 2023
Fixes: #8003

Add a new `Eol.targets` file to be imported for `net6.0-android`
projects.  It contains the necessary/minimal settings to emit the
build error:

	Microsoft.NET.EolTargetFrameworks.targets(35,5): error NETSDK1202:
	The workload 'android' is out of support and will not receive security updates in the future.
	Please refer to https://aka.ms/maui-support-policy for more information about the support policy.

We will probably need the latest .NET SDK to flow to us, in order to
write a test.  I could only test locally by editing `.targets` files
in the .NET SDK.
@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants