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] add support for 'dotnet test' and 'net6.0' #3017

Merged
merged 1 commit into from
Oct 18, 2021

Conversation

jonathanpeppers
Copy link
Member

Description of Change

Fixes: dotnet/sdk#21845

If you create a net6.0 class library with UseMaui=true, dotnet test fails with:

Testhost process exited with error: It was not possible to find any compatible framework version
The framework 'Microsoft.Maui.Core', version '**FromWorkload**' (x64) was not found.

@dsplaisted suggested adding %(RuntimePackAlwaysCopyLocal) to any
@(KnownFrameworkReference) that is meant for net6.0:

dotnet/sdk#21845 (comment)

If a class library does not have a platform specified, then the
Microsoft.Maui.*.any packs are brought in. These packs need
%(RuntimePackAlwaysCopyLocal) for dotnet test to work.

I added a sample project that appears to work now:

> .\bin\dotnet\dotnet.exe test .\src\Controls\samples\Controls.Sample.Tests\Controls.Sample.Tests.csproj
Determining projects to restore...
Restored C:\src\maui\src\Controls\samples\Controls.Sample.Tests\Controls.Sample.Tests.csproj (in 1.89 sec).
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
Controls.Sample.Tests -> C:\src\maui\src\Controls\samples\Controls.Sample.Tests\bin\Debug\net6.0\Controls.Sample.Tests.dll
Test run for C:\src\maui\src\Controls\samples\Controls.Sample.Tests\bin\Debug\net6.0\Controls.Sample.Tests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: < 1 ms - Controls.Sample.Tests.dll (net6.0)

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?

No

Fixes: dotnet/sdk#21845

If you create a `net6.0` class library with `UseMaui=true`, `dotnet
test` fails with:

    Testhost process exited with error: It was not possible to find any compatible framework version
    The framework 'Microsoft.Maui.Core', version '**FromWorkload**' (x64) was not found.

@dsplaisted suggested adding `%(RuntimePackAlwaysCopyLocal)` to any
`@(KnownFrameworkReference)` that is meant for `net6.0`:

dotnet/sdk#21845 (comment)

If a class library does not have a platform specified, then the
`Microsoft.Maui.*.any` packs are brought in. These packs need
`%(RuntimePackAlwaysCopyLocal)` for `dotnet test` to work.

I added a sample project that appears to work now:

    > .\bin\dotnet\dotnet.exe test .\src\Controls\samples\Controls.Sample.Tests\Controls.Sample.Tests.csproj
    Determining projects to restore...
    Restored C:\src\maui\src\Controls\samples\Controls.Sample.Tests\Controls.Sample.Tests.csproj (in 1.89 sec).
    You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
    Controls.Sample.Tests -> C:\src\maui\src\Controls\samples\Controls.Sample.Tests\bin\Debug\net6.0\Controls.Sample.Tests.dll
    Test run for C:\src\maui\src\Controls\samples\Controls.Sample.Tests\bin\Debug\net6.0\Controls.Sample.Tests.dll (.NETCoreApp,Version=v6.0)
    Microsoft (R) Test Execution Command Line Tool Version 17.0.0
    Copyright (c) Microsoft Corporation.  All rights reserved.
    Starting test execution, please wait...
    A total of 1 test files matched the specified pattern.
    Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: < 1 ms - Controls.Sample.Tests.dll (net6.0)
@jonathanpeppers
Copy link
Member Author

I see my new test, going to merge this.

image

@jonathanpeppers jonathanpeppers merged commit b088ec3 into dotnet:main Oct 18, 2021
@jonathanpeppers jonathanpeppers deleted the dotnet-test branch October 18, 2021 21:58
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@samhouts samhouts added the fixed-in-6.0.101-preview.10 Look for this fix in 6.0.101-preview.10! 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.10 Look for this fix in 6.0.101-preview.10!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running dotnet test on a project that uses optional workloads can't find them
4 participants