Open danipen opened 11 months ago
The logs doesn't give any clue...
2023-09-04 13:36:21.788 [info] [Trace - 13:36:21] Received request 'workspace/configuration - (7)'.
2023-09-04 13:36:21.788 [info] [Trace - 13:36:21] Sending response 'workspace/configuration - (7)'. Processing request took 0ms
2023-09-04 13:36:22.830 [info] [Trace - 13:36:22] Received notification 'window/logMessage'.
2023-09-04 13:36:22.830 [info] [Info - 13:36:22] AvaloniaLanguageServer.Handlers.TextDocumentSyncHandler: ** DidOpenText: file:///Users/danipen/Projects/AvaloniaPreviewerTest/PreviewerTest/MainWindow.axaml | Uri='file:///Users/danipen/Projects/AvaloniaPreviewerTest/PreviewerTest/MainWindow.axaml'```
Could you try using the v0.0.18? You can download it from the release here https://github.com/AvaloniaUI/AvaloniaVSCode/releases/tag/v0.0.18
install it manually in the VS Code
This is should be fixed in latest version, please reopen if you continue to have an issue
@prashantvc sorry, it still happens in 0.0.18
:
I'm using the latest version:
This is rather strange! Do you see the Show Preview
command in the command palette?
Make sure you have XAML file opened when you try to execute the command
No, I don't see that option:
Fixed in v0.0.20
It's not fixed in v0.0.20. Could you please reopening the issue?
Where can I find some logs or something that gives me a clue?
I can find these logs in the Output
> Avalonia Client
pane, but I'm afraid it doesn't give any clue:
2023-10-20 17:35:15.475 [info] Creating language service
2023-10-20 17:35:15.475 [info] Starting Avalonia Language Server...
2023-10-20 17:35:15.475 [info] [Trace - 17:35:15] Sending request 'initialize - (0)'.
2023-10-20 17:35:17.332 [info] [Trace - 17:35:17] Received response 'initialize - (0)' in 1984ms.
2023-10-20 17:35:17.332 [info] [Trace - 17:35:17] Sending notification 'initialized'.
2023-10-20 17:35:17.336 [info] [Trace - 17:35:17] Sending notification 'workspace/didChangeConfiguration'.
2023-10-20 17:35:17.444 [info] [Trace - 17:35:17] Received request 'client/registerCapability - (1)'.
2023-10-20 17:35:17.445 [info] [Trace - 17:35:17] Sending response 'client/registerCapability - (1)'. Processing request took 3ms
2023-10-20 17:35:17.445 [info] [Trace - 17:35:17] Sending notification 'textDocument/didOpen'.
2023-10-20 17:35:17.445 [info] [Trace - 17:35:17] Received request 'workspace/configuration - (2)'.
2023-10-20 17:35:17.446 [info] [Trace - 17:35:17] Sending response 'workspace/configuration - (2)'. Processing request took 0ms
2023-10-20 17:35:17.532 [info] [Trace - 17:35:17] Received request 'workspace/configuration - (3)'.
2023-10-20 17:35:17.532 [info] [Trace - 17:35:17] Sending response 'workspace/configuration - (3)'. Processing request took 1ms
2023-10-20 17:35:17.550 [info] [Trace - 17:35:17] Received request 'workspace/configuration - (4)'.
2023-10-20 17:35:17.550 [info] [Trace - 17:35:17] Sending response 'workspace/configuration - (4)'. Processing request took 0ms
2023-10-20 17:35:17.600 [info] [Trace - 17:35:17] Received notification 'window/logMessage'.
2023-10-20 17:35:17.600 [info] [Info - 17:35:17] AvaloniaLanguageServer.Handlers.TextDocumentSyncHandler: ** DidOpenText: file:///Users/danipen/Projects/PreviewExample/MainWindow.axaml | Uri='file:///Users/danipen/Projects/PreviewExample/MainWindow.axaml'
2023-10-20 17:35:25.487 [info] [Trace - 17:35:25] Sending notification '$/setTrace'.
2023-10-20 17:35:26.972 [info] [Trace - 17:35:26] Sending notification '$/setTrace'.
@prashantvc any progress on this issue? Thanks!
I'm experiencing a similar issue. Or the same issue. It's hard to tell.
The command to open the previewer wasn't available in the editor buttons or the Command Center so I bound a hotkey to it.
Using a hotkey to trigger avalonia.showPreviewToSide
resulted in the following prompt:
Clicking Build
works. Dotnet build the solution and the assets are generated, but avalonia.showPreviewToSide
still can't find the previewer assets.
2023-12-11 07:08:54.605 [info] Previewer assets are not available.
2023-12-11 07:08:57.643 [info] [EXT - INFO] Solution data path path: C:\Users\Noah\AppData\Local\Temp\GroupBox.Avalonia.sln.json
2023-12-11 07:08:57.710 [info] parser process args: C:\WINDOWS\system32\cmd.exe,/d,/s,/c,"dotnet "c:\Users\Noah\.vscode\extensions\avaloniateam.vscode-avalonia-0.0.25\solutionParserTool\SolutionParser.dll" "c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia.sln" --sdk 7.0"
2023-12-11 07:08:58.210 [info] parser process exited 0
2023-12-11 07:08:58.593 [info] Determining projects to restore...
2023-12-11 07:08:59.052 [info] All projects are up-to-date for restore.
2023-12-11 07:09:00.331 [info] Could not extract the MVID from "obj\Debug\net6.0\refint\GroupBox.Avalonia.dll". Are you sure it is a reference assembly?
2023-12-11 07:09:00.331 [info] GroupBox.Avalonia -> c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia\bin\Debug\net6.0\GroupBox.Avalonia.dll
2023-12-11 07:09:00.395 [info] Could not extract the MVID from "obj\Debug\net7.0\refint\GroupBox.Avalonia.dll". Are you sure it is a reference assembly?
2023-12-11 07:09:00.395 [info] GroupBox.Avalonia -> C:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia\bin\Debug\net7.0\GroupBox.Avalonia.dll
2023-12-11 07:09:01.292 [info] Could not extract the MVID from "obj\Debug\net8.0\refint\GroupBox.Avalonia.dll". Are you sure it is a reference assembly?
2023-12-11 07:09:01.295 [info] GroupBox.Avalonia -> c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia\bin\Debug\net8.0\GroupBox.Avalonia.dll
2023-12-11 07:09:02.548 [info] Could not extract the MVID from "obj\Debug\net8.0\refint\GroupBox.Avalonia.Sample.dll". Are you sure it is a reference assembly?
2023-12-11 07:09:02.549 [info] GroupBox.Avalonia.Sample -> c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia.Sample\bin\Debug\net8.0\GroupBox.Avalonia.Sample.dll
2023-12-11 07:09:02.568 [info] Could not extract the MVID from "obj\Debug\net7.0\refint\GroupBox.Avalonia.Sample.dll". Are you sure it is a reference assembly?
2023-12-11 07:09:02.569 [info] GroupBox.Avalonia.Sample -> c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia.Sample\bin\Debug\net7.0\GroupBox.Avalonia.Sample.dll
2023-12-11 07:09:03.211 [info] Could not extract the MVID from "obj\Debug\net6.0\refint\GroupBox.Avalonia.Sample.dll". Are you sure it is a reference assembly?
2023-12-11 07:09:03.212 [info] GroupBox.Avalonia.Sample -> c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia.Sample\bin\Debug\net6.0\GroupBox.Avalonia.Sample.dll
2023-12-11 07:09:03.232 [info]
2023-12-11 07:09:03.233 [info] Build succeeded.
2023-12-11 07:09:03.234 [info] 0 Warning(s)
2023-12-11 07:09:03.234 [info] 0 Error(s)
2023-12-11 07:09:03.234 [info]
2023-12-11 07:09:03.235 [info] Time Elapsed 00:00:04.84
2023-12-11 07:09:03.393 [info] [EXT - INFO] Solution data path path: C:\Users\Noah\AppData\Local\Temp\GroupBox.Avalonia.sln.json
2023-12-11 07:09:03.458 [info] parser process args: C:\WINDOWS\system32\cmd.exe,/d,/s,/c,"dotnet "c:\Users\Noah\.vscode\extensions\avaloniateam.vscode-avalonia-0.0.25\solutionParserTool\SolutionParser.dll" "c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia.sln" --sdk 7.0"
2023-12-11 07:09:04.019 [info] Previewer assets generated at
2023-12-11 07:09:04.019 [info] Command avalonia.previewProcess, file:///c%3A/Repos/BinToss/GroupBox.Avalonia/GroupBox.Avalonia.Sample/MainWindow.axaml
2023-12-11 07:09:04.019 [info] Previewer assets are not available.
2023-12-11 07:09:04.031 [info] parser process exited 0
P.S. I multi-target frameworks i.e. <TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
P.P.S.
dotnet --list-sdks
5.0.416 [C:\Program Files\dotnet\sdk]
6.0.417 [C:\Program Files\dotnet\sdk]
7.0.203 [C:\Program Files\dotnet\sdk]
7.0.311 [C:\Program Files\dotnet\sdk]
7.0.403 [C:\Program Files\dotnet\sdk]
7.0.404 [C:\Program Files\dotnet\sdk]
8.0.100 [C:\Program Files\dotnet\sdk]
https://github.com/AvaloniaUI/AvaloniaVSCode/blob/main/src/vscode-avalonia/src/commands/createPreviewerAssets.ts#L37
const output
's properties are all empty strings.
generatePreviewerAssets
was called with the following args:
"projectPath": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\GroupBox.Avalonia.Sample.csproj"
{
"name": "GroupBox.Avalonia.Sample",
"path": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\GroupBox.Avalonia.Sample.csproj",
"targetPath": "",
"outputType": "WinExe",
"designerHostPath": "",
"targetFramework": "",
"depsFilePath": "",
"runtimeConfigFilePath": "",
"projectReferences": [
"c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\GroupBox.Avalonia\\GroupBox.Avalonia.csproj"
],
"directoryPath": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample",
"intermediateOutputPath": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\obj\\Debug\\Avalonia\\references"
}
Two issues here:
designerHostPath
will be an empty string because AvaloniaPreviewerNetCoreToolPath ~~is not present/assigned in the project file. ~~Instead, it's evaluated during MSBuild/dotnet-build operations.~~ The property *is* evaluated via MSBuild, so it *doesn't* need to be assigned in the project file. I've found that evaluating the property via
dotnet msbuild sample.csproj /getProperty:AvaloniaPreviewerNetCoreToolPathwill result in an empty string in some cases. adding the
/Property:TargetFramework=net6.0` arg allows the property to be evaluated as expected.targetFramework
is undefined when a project multi-targets frameworks. SolutionParser will need to parse TargetFrameworks in addition to TargetFramework. execute(projectPath: string, project: Project): Promise<void> {
// ...
if (projectPath && fs.pathExistsSync(projectPath)) {
if (project.targetFramework === "" && project.targetFrameworks.length > 0) {
// only recognize first TFM in TargetFrameworks. Given "net8.0;net6.0;net7.0", only "net8.0" will be used.
project.targetFramework = project.targetFrameworks[0];
}
// ...
}
-OR-
generatePreviewerAssets(projectPath: string, project: sm.Project): Promise<PreviewerParams | PreviewerParams[]> {
/* -OR- */
// each TFM string can be appended to the dotnet command line argument in generatePreviewerAssets
interface procStartInfo {
cmd: string
args: string[]
}
const template: procStartInfo = {
cmd: "dotnet",
args: ["build", projectPath.putInQuotes(), "-nologo"]
}
let dotnetCmdLines: procStartInfo[];
if (project.targetFramework) {
dotnetCmdLines = [template];
}
else {
// create new procStartInfo for each tfm
dotnetCmdLines = project.targetFrameworks?.map((tfm: string) => {
const newObj = Object.assign({}, template);
newObj.args.push(`--framework=${tfm}`);
return newObj;
});
}
return dotnetCmdLines.map((cmdLine) => {
return new Promise((resolve, reject) => {
const dotnet = spawn(cmdLine.cmd, cmdLine.args);
//... the rest of the original Promise
})
});
P.S. "TFM" is Target Framework Moniker
designerHostPath
is supposed to be determined by the CompletionEngine (see AvaloniaUI/AvaloniaVS). It fails to do so because it assuming assemblies will not be built to TFM-named subfolders.
That is, it's looking for obj/Debug/*.dll
when it should be looking for obj/Debug/net6.0/*.dll
, for instance. I recommend parsing the project for valid TFMs and checking in obj/Debug/
for the most appropriate match. Latest, first in the array, or whatever is decided to be the best option. It may even be preferable to prompt the user for this decision.
I am sorry to here you are hitting this issue. I am going to take a look on priority
I dug into AvaloniaVSCode and AvaloniaVS over the past few weekends. After learning a bit more about the projects in question, I've updated my previous comment with corrections, trace notes, and suggestions.
Authors of similar extensions are requesting easier access–or documentation of existing access–to the ms-dotnettools extensions' 'current' solution file and parsed projects. I spent last week and weekend looking through the existing ms-dotnettools extensions' exports for this data and ways to be notified of when data in the project system updates (e.g. OnChanged events). From what I've learned, the current implementation intends for API users to communicate with a so-called 'brokered service'. This might be refer to the Roslyn host process. Or it may refer to the project system host process. The CSharp and CsDevKit extensions' exports each provide different functions and variables related to 'servers' and the symbol names do not make their purpose clear.
Aside from OmniSharp exports for backwards compatibility, ms-dotnettools.csharp
offers the following:
export interface CSharpExtensionExports {
initializationFinished: () => Promise<void>;
logDirectory: string;
profferBrokeredServices: (container: GlobalBrokeredServiceContainer) => void;
determineBrowserType: () => Promise<string | undefined>;
experimental: CSharpExtensionExperimentalExports;
}
export interface CSharpExtensionExperimentalExports {
sendServerRequest: <Params, Response, Error>(
type: RequestType<Params, Response, Error>,
params: Params,
token: vscode.CancellationToken
) => Promise<Response>;
languageServerEvents: LanguageServerEvents;
}
Note profferBrokeredServices
, experimental.sendServerRequest
, and the deceptively useful-looking experimental.languageServerEvents
. That last one only has two events: Started and ProjectInitializationComplete. experimental.sendServerRequest
allows us to communicate with the extension's out-of-process Roslyn language server. The request types I've found so far would not return the URI of the server's Solution file nor would any requests allow us to listen for solution/project changes.
And msdotnettools.csdevkit
exports this
export interface CSharpDevKitExports {
serviceBroker: IServiceBroker;
getBrokeredServiceServerPipeName: () => Promise<string>;
components: Readonly<{ [key: string]: string }>;
hasServerProcessLoaded: () => boolean;
serverProcessLoaded: vscode.Event<void>;
setupTelemetryEnvironmentAsync: (env: NodeJS.ProcessEnv) => Promise<string | undefined>;
}
serviceBroker
, getBrokeredServiceServerPipeName
, and components
seem to be what the Uno Platform's VSCode extension uses. But...how? components
is a complete mystery to me. However, the other two seem to be what we need investigate for usefulness.
https://github.com/dotnet/vscode-csharp/blob/main/src/shared/assets.ts
This file contains most of the code used by OmniSharp's/CSharp's "generate build and debug assets" prompt. In another IWorkspaceDebugInformationProvider
will provide information such as executable projects, their dependencies, and their solution file(s)...if it's exported by csharp or csdevkit.
This should be fixed in v0.0.27, please reopen the issue if you continue to see this
@danipen Does v0.0.27 resolve your issue? The issue persists on my end.
The issue persist on my end too. Using Avalonia for VSCode v0.0.28
. cc/ @prashantvc
Using Debian based distro, I have the same issue with previewer. Clicking build does nothing, the popup keeps coming up, however, I can build and run manually. It's a real pain without previewer though
@mikson022, post the contents of the $TMPDIR/avalonia.log
and $TMPDIR/$solutionName.json
. Those will help determine the cause of the issue.
@mikson022, post the contents of the
$TMPDIR/avalonia.log
and$TMPDIR/$solutionName.json
. Those will help determine the cause of the issue.
I apologize for my lack of expertise. I recursively searched my /home for the listed files and couldn't find them
Try the following in bash:
if [ -n "${TMPDIR}" ]
then
echo "Printing contents of $TMPDIR/avalonia.log"
cat $TMPDIR/avalonia.log
echo "enter the filename of your .sln sans the .sln extension e.g. 'mySolution' when the solution file is mySolution.sln"
solutionName=read # prompts for user input
echo "Printing contents of $TMPDIR/$solutionName.json:"
cat $TMPDIR/$solutionName.json
else
echo "environment variable TMPDIR is undefined. Env vars are..."
printenv
fi
(I'm not at my desk atm; writing and testing this script in Termux was miserable)
reopening this!
Try the following in bash:
if [ -n "${TMPDIR}" ] then echo "Printing contents of $TMPDIR/avalonia.log" cat $TMPDIR/avalonia.log echo "enter the filename of your .sln sans the .sln extension e.g. 'mySolution' when the solution file is mySolution.sln" solutionName=read # prompts for user input echo "Printing contents of $TMPDIR/$solutionName.json:" cat $TMPDIR/$solutionName.json else echo "environment variable TMPDIR is undefined. Env vars are..." printenv fi
(I'm not at my desk atm; writing and testing this script in Termux was miserable)
environment variable TMPDIR is undefined. Env vars are... SHELL=/bin/bash SESSION_MANAGER=local/MX-HP:@/tmp/.ICE-unix/3166,unix/MX-HP:/tmp/.ICE-unix/3166 WINDOWID=96469833 QT_ACCESSIBILITY=1 COLORTERM=truecolor XDG_CONFIG_DIRS=/etc/xdg XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0 XDG_MENU_PREFIX=xfce- QT_LOGGING_RULES=qt.qpa.xcb.warning=false SSH_AUTH_SOCK=/tmp/ssh-XXXXXXOggbwa/agent.3166 DESKTOP_SESSION=xfce SSH_AGENT_PID=3266 GTK_MODULES=canberra-gtk-module:gail:atk-bridge XDG_SEAT=seat0 PWD=/home/Mikson/Desktop/C#/Automation/MineMate LOGNAME=Mikson XDG_SESSION_DESKTOP=xfce QT_QPA_PLATFORMTHEME=gtk2 XDG_SESSION_TYPE=x11 XAUTHORITY=/home/Mikson/.Xauthority XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/Mikson GDM_LANG=en_US.UTF-8 HOME=/home/Mikson LANG=en_US.UTF-8 LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arc=01;31:.arj=01;31:.taz=01;31:.lha=01;31:.lz4=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.tzo=01;31:.t7z=01;31:.zip=01;31:.z=01;31:.dz=01;31:.gz=01;31:.lrz=01;31:.lz=01;31:.lzo=01;31:.xz=01;31:.zst=01;31:.tzst=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.alz=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.cab=01;31:.wim=01;31:.swm=01;31:.dwm=01;31:.esd=01;31:.avif=01;35:.jpg=01;35:.jpeg=01;35:.mjpg=01;35:.mjpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.webp=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.m4a=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.oga=00;36:.opus=00;36:.spx=00;36:.xspf=00;36:~=00;90:#=00;90:.bak=00;90:.old=00;90:.orig=00;90:.part=00;90:.rej=00;90:.swp=00;90:.tmp=00;90:.dpkg-dist=00;90:.dpkg-old=00;90:.ucf-dist=00;90:.ucf-new=00;90:.ucf-old=00;90:.rpmnew=00;90:.rpmorig=00;90:.rpmsave=00;90: XDG_CURRENT_DESKTOP=XFCE VTE_VERSION=7006 QT_PLATFORMTHEME=gtk2 XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 XDG_SESSION_CLASS=user TERM=xterm-256color USER=Mikson DISPLAY=:0.0 SHLVL=1 XDG_VTNR=7 XDG_SESSION_ID=1 PAPERSIZE=letter XDG_RUNTIME_DIR=/run/user/1000 QT_PLATFORM_PLUGIN=gtk2 XDG_DATA_DIRS=/usr/share/xfce4:/home/Mikson/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin GDMSESSION=xfce DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-GJE93Fqv91,guid=53acc489a33e639e4bce6b8965b2bdae QT_SCALEFACTOR=1 =/usr/bin/printenv
I decided to reinstall VSCode and .NET.
The problem still occurs, however, in a different form, now when I try to preview *.axaml:
Always leading to this:
You don't have an environment variable for the system or user temporary directories so we'll do this differently. Avalonia's extension is one of the few that allows VSCode users to click its "open log file" button.
In VSCode, Open Output
(CTRL+ALT+O), use the Switch Output
menu to switch to Avalonia Client
, and then click the Open Log Output File
button.
Paste the log contents in a code block like so:
2024-01-29 16:05:48.376 [info] Creating language service 2024-01-29 16:05:48.434 [info] Starting Avalonia Language Server... 2024-01-29 16:05:49.119 [info] [Trace - 4:05:49 PM] Sending request 'initialize - (0)'. 2024-01-29 16:05:57.867 [info] [Trace - 4:05:57 PM] Received response 'initialize - (0)' in 8748ms. 2024-01-29 16:05:57.867 [info] [Trace - 4:05:57 PM] Sending notification 'initialized'. 2024-01-29 16:05:57.872 [info] [Trace - 4:05:57 PM] Sending notification 'workspace/didChangeConfiguration'. 2024-01-29 16:05:58.344 [info] [Trace - 4:05:58 PM] Received request 'client/registerCapability - (1)'. 2024-01-29 16:05:58.345 [info] [Trace - 4:05:58 PM] Sending response 'client/registerCapability - (1)'. Processing request took 2ms 2024-01-29 16:05:58.369 [info] [Trace - 4:05:58 PM] Received request 'workspace/configuration - (2)'. 2024-01-29 16:05:58.369 [info] [Trace - 4:05:58 PM] Sending response 'workspace/configuration - (2)'. Processing request took 0ms 2024-01-29 16:05:58.419 [info] [Trace - 4:05:58 PM] Received request 'workspace/configuration - (3)'. 2024-01-29 16:05:58.419 [info] [Trace - 4:05:58 PM] Sending response 'workspace/configuration - (3)'. Processing request took 0ms 2024-01-29 16:09:36.713 [info] [Trace - 4:09:36 PM] Sending request 'shutdown - (1)'. 2024-01-29 16:09:36.825 [info] [Trace - 4:09:36 PM] Received response 'shutdown - (1)' in 165ms. 2024-01-29 16:09:36.825 [info] [Trace - 4:09:36 PM] Sending notification 'exit'. 2024-01-29 16:09:36.826 [info] Language client stopped 2024-01-29 16:09:50.417 [info] Creating language service 2024-01-29 16:09:51.261 [info] Starting Avalonia Language Server... 2024-01-29 16:09:51.281 [info] [Trace - 4:09:51 PM] Sending request 'initialize - (0)'. 2024-01-29 16:09:54.848 [info] [Trace - 4:09:54 PM] Received response 'initialize - (0)' in 3567ms. 2024-01-29 16:09:54.848 [info] [Trace - 4:09:54 PM] Sending notification 'initialized'. 2024-01-29 16:09:55.829 [info] [Trace - 4:09:55 PM] Sending notification 'workspace/didChangeConfiguration'. 2024-01-29 16:09:56.608 [info] [Trace - 4:09:56 PM] Received request 'client/registerCapability - (1)'. 2024-01-29 16:09:56.608 [info] [Trace - 4:09:56 PM] Sending response 'client/registerCapability - (1)'. Processing request took 2ms 2024-01-29 16:09:56.770 [info] [Trace - 4:09:56 PM] Received request 'workspace/configuration - (2)'. 2024-01-29 16:09:56.770 [info] [Trace - 4:09:56 PM] Sending response 'workspace/configuration - (2)'. Processing request took 1ms 2024-01-29 16:09:58.335 [info] [Trace - 4:09:58 PM] Received request 'workspace/configuration - (3)'. 2024-01-29 16:09:58.335 [info] [Trace - 4:09:58 PM] Sending response 'workspace/configuration - (3)'. Processing request took 0ms 2024-01-29 16:11:43.404 [info] [Trace - 4:11:43 PM] Sending request 'shutdown - (1)'. 2024-01-29 16:11:43.506 [info] [Trace - 4:11:43 PM] Received response 'shutdown - (1)' in 148ms. 2024-01-29 16:11:43.506 [info] [Trace - 4:11:43 PM] Sending notification 'exit'. 2024-01-29 16:11:43.512 [info] Language client stopped 2024-01-29 16:11:53.393 [info] Creating language service 2024-01-29 16:11:53.800 [info] Starting Avalonia Language Server... 2024-01-29 16:11:53.824 [info] [Trace - 4:11:53 PM] Sending request 'initialize - (0)'. 2024-01-29 16:11:58.311 [info] [Trace - 4:11:58 PM] Received response 'initialize - (0)' in 4488ms. 2024-01-29 16:11:58.312 [info] [Trace - 4:11:58 PM] Sending notification 'initialized'. 2024-01-29 16:11:59.362 [info] [Trace - 4:11:59 PM] Sending notification 'workspace/didChangeConfiguration'. 2024-01-29 16:11:59.900 [info] [Trace - 4:11:59 PM] Received request 'client/registerCapability - (1)'. 2024-01-29 16:11:59.901 [info] [Trace - 4:11:59 PM] Sending response 'client/registerCapability - (1)'. Processing request took 2ms 2024-01-29 16:12:00.071 [info] [Trace - 4:12:00 PM] Received request 'workspace/configuration - (2)'. 2024-01-29 16:12:00.072 [info] [Trace - 4:12:00 PM] Sending response 'workspace/configuration - (2)'. Processing request took 1ms 2024-01-29 16:12:01.355 [info] [Trace - 4:12:01 PM] Received request 'workspace/configuration - (3)'. 2024-01-29 16:12:01.356 [info] [Trace - 4:12:01 PM] Sending response 'workspace/configuration - (3)'. Processing request took 0ms
Next, we need the parsed solution details. Run "Avalonia: Create previewer assets". The first line will contain the path we need. Open that file and paste its contents into a JSON-syntax code block e.g.
```json
{
"solution": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.sln",
"projects": [
{
"name": "GroupBox.Avalonia",
"path": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia\\GroupBox.Avalonia.csproj",
"targetPath": "",
"outputType": "Library",
"designerHostPath": "",
"targetFramework": "",
"targetFrameworks": [
"net6.0",
"net7.0",
"net8.0"
],
"depsFilePath": "",
"runtimeConfigFilePath": "",
"projectReferences": [],
"directoryPath": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia",
"intermediateOutputPath": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia\\obj\\Debug\\Avalonia\\references"
},
{
"name": "GroupBox.Avalonia.Sample",
"path": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\GroupBox.Avalonia.Sample.csproj",
"targetPath": "",
"outputType": "WinExe",
"designerHostPath": "",
"targetFramework": "",
"targetFrameworks": [
"net6.0",
"net7.0",
"net8.0"
],
"depsFilePath": "",
"runtimeConfigFilePath": "",
"projectReferences": [
"c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\GroupBox.Avalonia\\GroupBox.Avalonia.csproj"
],
"directoryPath": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample",
"intermediateOutputPath": "c:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\obj\\Debug\\Avalonia\\references"
}
],
"files": []
}
I'm not familiar in this, but after troubleshooting a bit, I found that inside the previewerProcess command , the const previewParams is always undefined.
It seems the workspace state is not really getting updated no matter what is done even after building the project or running it.
`export class PreviewerProcess implements Command { id: string = util.AppConstants.previewProcessCommandId;
async execute(mainUri?: vscode.Uri): Promise<PreviewerData> {
util.logger.appendLine(`Command ${this.id}, ${mainUri}`);
let result: PreviewerData = { file: mainUri! };
const previewParams = this._context.workspaceState.get<PreviewerParams>(util.AppConstants.previewerParamState); // this line always returns undefined
if (previewParams && mainUri) {
result = await this.startPreviewerProcess(previewParams, mainUri);
}
return result;
}`
If I force to execute the command previewerAssetsCommand inside the ShowPreviewToSideCommand before anything else
public async execute(mainUri?: vscode.Uri, allUris?: vscode.Uri[]) {
const activeFile = mainUri ?? vscode.window.activeTextEditor?.document.uri;
await vscode.commands.executeCommand(AppConstants.previewerAssetsCommand); // test to force update the workspace
let previewerData = this._processManager.getPreviewerData(activeFile?.toString() ?? "");
if (!previewerData) {
previewerData = await vscode.commands.executeCommand<PreviewerData>(
AppConstants.previewProcessCommandId,
activeFile
);
}
Then the preview works successfully. I only tested this on MacOS.
I had a similar type of day to this one.
Finally solved it.
I'm guessing it's something similar to mine.
Same thing, no "Show preview" and no preview icon.
But here's how it looks for me right now.
Here's how I solved it.
Look at the bottom area of the VS Code window (Select Language Mode).
Click on it and type 'Avalonia xaml' to change it.
Before
After
I had a similar issue. For some reason, despite the extension description saying
after also installing dotnet sdk 7.0 it now works.
The C# source code was updated to require .NET 8, but the DLLs included with the avalonia-vscode haven't been updated in ages. The C# side of this extension has had build errors since...last year? It's trying to call AvaloniaVS method signatures that don't exist and never have.
I've fixed this issue and others in my fork, but the extension's build and release pipeline is manual and tends to include stale artifacts.
Running under macOS. The extension loads fine (see attached picture), and the XAML code completion works fine. However, the previewer is not available for AXAML files.
The project is Avalonia![Screenshot 2023-09-04 at 13 18 39](https://github.com/AvaloniaUI/Avalonia-VSCode-Extension/assets/501613/526949e1-3e00-4009-bdd9-f15395818734)
11.0.4
it's fully built. I tried restarting Visual Studio Code and had no luck.Not sure if related, but every time I open VSCode I get: