-
Notifications
You must be signed in to change notification settings - Fork 697
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
Can't get error output from XamlCompiler.exe #10027
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you! Open similar issues:
|
One of the big issues here is that the only supported way of using the Xaml compiler is through MSBuild. So there really should be a feature request to provide a supported version of the Xaml compiler that can be run from the command line. I will need to check my notes, because I did do a lot of work to figure out how to use the Xaml compiler from the command line. But be aware, this is going to be unsupported by Microsoft. I'll either edit this post or do another reply when I have figured everything out. |
Right, this will be a long post. It will also include some steps from other tools since they are required for everything to work correctly when you get to the compilation stage. I will list things in the order that Visual Studio did them at 17.7, since that was when I did this work. This was also using the Windows App SDK 1.4.2. Again, some of these can be done slightly out of order.
At this point, the source and header files for the project have been generated. It then does the precompiled header compile, compile the rest of the source files for the project and then links it. The last step is to make the .pri file for the project. I glossed over some of this, but remember if you set Visual Studio to diagnostic logging, then you can get all of these steps. Now, out of all those steps, the important thing for the Xaml compiler is the generation of the merged .winmd for your project for the second pass. The contents of the generated XamlMetaDataProvider.idl is:
The namespace I have there is just the namespace that I was using for the manual project. This name isn't special, but you must make it match everything in your project. The contents of XamlMetaDataProvider.cpp is:
Basically, the contents of the file is generated in XamlMetaDataProvider.g.cpp and XamlMetaDataProvider.cpp only exists to pull the real contents in. Now for the not very fun part, the Xaml compiler input itself. The main .json format follows what is in ICompileXamlInputs region of CompileXaml.cs. But the actual accepted values are not really documented there, I had to really dig through the source code and use diagnostic Visual Studio output to get anywhere. Any references follow the public interface of MSBuildItem.cs. Now, the reference assemblies ends up being a pretty large list. It lists all of the .winmd files from the Windows App SDK, the WebView2 .winmd file, any other .winmd from NuGet packages or projects, and any referenced platform .winmd file by contract. It does not reference the full Windows.winmd. Two examples of the referenced .winmd files are
The paths are specific to my system and the fact that the project was a manual use of the Xaml compiler. But for the ReferenceAssemblies lst, the FullPath and ItemSpec values are always equal. IsSystemReference is true for anything in the Windows SDK, otherwise the remaining values are false or empty strings. But it is important that you set these paths to their location on your system. The list of reference assemblies took up 1213 lines of my input.json files. To give an example of the input.json files I used, the pass 1 file is:
The reference assemblies have been stripped to save a lot of space.
There is very little difference between them, but there are some differences. First, CompileMode is set to RealBuildPass1 for pass 1 and RealBuildPass2 for pass 2. There is also the IsPass1 property that is true for pass 1 and false for pass2. LocalAssembly is null for pass 1, but must be a reference to your application's .winmd for pass 2. These should be the most important points, but if you want, I can double check what I have with the latest version of the tools to be sure that things still work. I can get things packaged up into a small .zip file with more instructions. I will remind you at this point that this is unsupported, so do not take this as Microsoft approved. |
...which looks extremely helpful! Lots of things I would otherwise have to have puzzled out myself. |
Well, I double checked with the Windows App SDK 1.6 and the latest VC, and it still works. |
Describe the bug
I'm trying to experiment with using the standalone
XamlCompiler.exe
. One thing I noticed is that it doesn't seem to really report any errors, it just fails with exit code 1.Upon closer inspection, it seems any entry added to the
ConsoleLogger
used by the standalone program isn't really output in the case of error.The only use of
ConsoleLogger.Entries
is inSaveResults()
. That, however, is only executed in the case of success:microsoft-ui-xaml/src/src/XamlCompiler/BuildTasks/ConsoleCompileXaml.cs
Line 77 in 35c590b
So it seems if there's an error, the actual message isn't actually output anywhere...
Steps to reproduce the bug
XamlCompiler.exe
that successfully parses:XamlCompiler.exe
manuallyExpected behavior
No response
Screenshots
The standalone compiler should report errors, at least to the console, if it doesn't produce an output json.
NuGet package version
WinUI 3 - Windows App SDK 1.6.0: 1.6.240829007
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response
The text was updated successfully, but these errors were encountered: