unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.76k stars 706 forks source link

[vscode] "Could no find task Uno*" on multi-rooted workspaces #17580

Open yeahg-dev opened 1 month ago

yeahg-dev commented 1 month ago

Type: Bug

Current Behavior

- When I start debug with "Launch Test wiith Custom Task", nothing happens except this error alert is showing. 
- When I start debug with "Launch Test wiith Uno Platfrom Task", nothing happens except this error alert is showing. 
<img width="273" alt="스크린샷 2024-07-17 오후 3 50 37" src="https://github.com/user-attachments/assets/4302d928-554d-4795-b579-f4023e0d31ac">

## Expected Behavior
-  When start debug with "Launch Test with Custom Task", preLaunchTask "build Project" task should be excuted. 
-  When Start debug with "Launch Test with Uno Platform Task", preLaunchTask "Uno: net7.0-android | Debug | android-x64" task should be excuted. (As far as I know, this task belongs to Uno Platform Extension)

## How to reproduce it (as minimally and precisely as possible)
For build related issue consider attaching the .binlog file

## Workaround
"build Project" task referred by lauch.json work successfully in **"not workspace"**.
```json
{
  // Use IntelliSense to find out which attributes exist for C# debugging
  // Use hover for the description of the existing attributes
  // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
  "version": "0.2.0",
  "configurations": [

    {
      "name": "Launch in not workspace",
      "type": "Uno",
      "request": "launch",
      "preLaunchTask": "build Project"
    },
  ]
}

Extension Status

Extension: Dev Kit Mode Debugger: Ready Hot-Reload: Running on port 61370 XAML LSP: Ready

Environment information

Extension version: 0.14.1 VS Code version: Code 1.91.1 (f1e16e1e6214d7c44d078b1f0607b2388f29d729, 2024-07-09T22:07:46.768Z) OS version: Darwin arm64 23.1.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (10 x 2400)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|10, 11, 10| |Memory (System)|32.00GB (3.56GB free)| |Process Argv|--crash-reporter-id b84a933d-ae30-433b-abe7-a8314f276265| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 chatpanelt:31048053 dsvsc021:30996838 jg8ic977:31013176 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 newcmakeconfigv2:31071590 impr_priority:31094925 refactorc:31098050 ccplti:31098112 ```
spouliot commented 1 month ago

The Uno Platform extension provides its own tasks but otherwise it's VS Code that does the match up (between launch and tasks).

Can you attach a test case that demonstrate the issue ? and any other steps (like what's selected in the status bar). Thanks!

note: the mixup between net7.0 and net8.0 is weird

yeahg-dev commented 1 month ago

When Start Debug on not workspace, Uno Platforms's task run well. but on workspace, I think VScode can not find Uno Platform's task.

This is status bar selected.

I uploaded the project to this repo. Please check it out

jeromelaban commented 1 month ago

@yeahg-dev could you give a try at the latest version we published last friday?

yeahg-dev commented 1 month ago

@jeromelaban



Did I misunderstood "latest version we published last friday"? 
or Is there any simple way to use `Uno.WinUI 5.4.0-dev.1004`(which is not compatible with Uno.SDK)? '

The commit applying the above mentioned attempt has been updated on the [repo](https://github.com/yeahg-dev/VSCodeWorkspaceTaskTest), so it would be good to refer to it
jeromelaban commented 1 month ago

Thanks for the update, I should have been more specific. I wanted you to try out the latest Uno Platform VSCode extension to see if it helps. For the update, you may want to upgrade your solution to single project, which makes upgrading to newer version much easier.

yeahg-dev commented 1 month ago

Thanks! But It seems not fixed. still the same error is occuring image

jeromelaban commented 1 month ago

Thanks. Can you take a picture of your vscode, particularly the page that opens when viewing the options of the uno platform extension?

xperiandri commented 1 month ago

There is just no docs how to configure it right. But I figured out how

yeahg-dev commented 1 month ago

@jeromelaban Here is screen capture of VScode.

Uno Extension Settings - User image

Uno Extension Settings - Workspace image

And this is User Task Command Palette on Test workspace image 스크린샷 2024-08-02 오후 1 36 11

yeahg-dev commented 1 month ago

There is just no docs how to configure it right. But I figured out how

Oh Can you share the solution?

spouliot commented 1 month ago

@yeahg-dev sorry for the delay. I don't get quite the same results as you have described.

When I start debug with "Launch Test wiith Custom Task", nothing happens except this error alert is showing. When I start debug with "Launch Test wiith Uno Platfrom Task", nothing happens except this error alert is showing.

Those names do not exist inside your repo.

What I noticed is that your repo seems to use an old Uno templates which has more than one solution, like:

And based on your screenshots you're using the *Mobile.sln solution, which is not at the same level as the .vscode where your custom configuration resides.

When I use DrawerControlSafeAreaTest.sln then I do not have build failures.

When I use DrawerControlSafeAreaTestMobile.sln I do get build failures (but not alerts as you mentioned above).

What happens to you if you use the DrawerControlSafeAreaTest.sln solution file ?

Also, if possible, I suggest you to update to the latest single project templates so you'll have a better overall experience (with a single solution file). That might fix your issue... but I can't be sure since I don't have the same errors as you did.

xperiandri commented 1 month ago

@yeahg-dev https://youtu.be/fr2bjB5KGb4 https://gist.github.com/xperiandri/3812bc86d2bef26c5ac8e1e5f8e62737

spouliot commented 4 weeks ago

@xperiandri hey, I'm not sure I'm following what you're suggesting ?

Your linked gist seems to be a copy of the launch.json that is part of our templates (using dotnet new ... or our online wizard. Am I missing something ?

Side note: except for web assembly, which requires more configuration, a launch.json file is not needed to build/debug Uno applications. Press F5 while a C# file is opened and it will build/deploy using the settings you selected (in the status bar).

xperiandri commented 4 weeks ago

@spouliot maybe it works for you and I would love to see a step-by-step guide to that. But for my scenario of enterprise development where in one solution there may be multiple different runnable projects, I was not managed to successfully apply your approach. Maybe I did something wrong but till now no one made any explanation or tutorial for that.

spouliot commented 4 weeks ago

Hello @xperiandri

maybe it works for you and I would love to see a step-by-step guide to that.

From this guide you have separate step-by-step instructions for VS, VS Code and Rider with, where applicable, OS specific steps.

But for my scenario of enterprise development where in one solution there may be multiple different runnable projects, I was not managed to successfully apply your approach.

We used, before Uno 5 and the single project support, to have several .csproj inside a solution. This is also quite common in the Uno git repository.

IMO the strangest part is that you're using the same launch.json file that our template provides. I would not expect one to work and the other to fail since the input would be the identical. Since it fails for you then there must be a difference somewhere...

Maybe I did something wrong but till now no one made any explanation or tutorial for that.

Do you mind opening a discussion to continue ?

I'd like to figure out what is the problem and, if required, update our code/docs.

Also I'm not sure it's related to the original question where a .code-workspace file, for multi-root workspaces, is being used.

Thanks!

yeahg-dev commented 3 weeks ago

@spouliot Thank you for sharing and kind suggestion! But changing to single solution or single project will be not suitable for my product. Because the purpose of using workspace is to collect folders belonging to different solutions and work on them in a workspace.

When I start debug with "Launch Test wiith Custom Task", nothing happens except this error alert is showing. When I start debug with "Launch Test wiith Uno Platfrom Task", nothing happens except this error alert is showing.

Those names do not exist inside your repo.

Oh I updated latest version 3 weeks ago. maybe you would opened not latest version. In latest you could find "Launch Test wiith Custom Task", and "Launch Test wiith Uno Platfrom Task" when open "Test.code-workspace". Could you check again with the latest version?

spouliot commented 3 weeks ago

Because the purpose of using workspace is to collect folders belonging to different solutions and work on them in a workspace.

Yes but a .code-workspace file is a VS Code only feature, it consolidate various locations inside a single virtual workspace of VS Code.

However it does not affect how the (dotnet) builds are done, dotnet is not aware of normal (or multi-rooted) workspaces. Now it's up to you but you should have no problem using a newer, single project Uno template.

Could you check again with the latest version?

I double checked and I was using the latest version. I likely missed them because of copy/paste errors :) I copied the names from the issue, but they are not an exact match (typo) for the content of https://github.com/yeahg-dev/VSCodeWorkspaceTaskTest/blob/main/.vscode/Test.code-workspace#L21

For some reasons the Microsoft C# (and/or C# DevKit) extension(s) [1] does not load your project this morning, it just keeps spinning ?!?

Screenshot 2024-08-20 at 10 36 20 AM

This works fine with other projects that I used and this is not something related to the Uno extension, I uninstall it to make sure of it.

Note that I am using the pre-release versions of the MS extensions.

I'll try again with the stable releases.

spouliot commented 3 weeks ago

The project loads correctly when using the current stable releases

spouliot commented 3 weeks ago

Filled with Microsoft as https://github.com/dotnet/vscode-csharp/issues/7455

spouliot commented 3 weeks ago

I can duplicate the issue. Even if the extension register the task with every workspace I still get the error 😢

This seems similar to https://github.com/microsoft/vscode/issues/192041 and MS answer is, at best, not very helpful (for the extension that normally provides the task definition).

Side note: adding a .vscode inside a multi-rooted workspace is likely a bad idea since (at least parts of) VS Code can create another .vscode directory inside it. IOW it might not always behave like a normal .vscode subdirectory would.

yeahg-dev commented 3 weeks ago

Thank you for checks and side note!

I don't know if I understood it well, Does Uno Platform Extension also provide task definition?

spouliot commented 3 weeks ago

Does Uno Platform Extension also provide task definition?

Yes, every Uno: * tasks that VS Code offers comes from the extension.

You don't have to create a tasks.json to use them, the extension will provide them on demand when needed.

However you can still add/copy them if you want to customize the tasks.