❔ Compiling XAML + CSharp from commandline
Lets say I have a need to compile specific code files into an assembly. I have a mechanism through CSC.exe to do this, I can feed it an array of .cs files and provided they are cromulent, they will compile into an assembly. I now want to compile XAML (WPF) and C# into an assembly in the same way. The CSC.exe compiler does not do XAML (please correct me if this is wrong). Without using MSBuild, is there a method by which I can compile say a single Window.xaml and Window.xaml.cs into an assembly at the command line?
17 Replies
Not gonna lie, it seems like some really weird stuff you're doing there
Not only using
csc
to compile loose files, but trying to compile XAML as well
Any reason you don't want to just, you know, build/publish the project?I play Ultima Online on a free server. There is a third party "Assistant" appplication named Razor that allows for scripting macros that affect the game (e.g. move north, dig tile, inspect backpack, etc). Within the last couple of years it has allowed IronPython scripts and C# scripts in addition to the ClassicUO syntax scripts. The C# scripts that it allows for right now can handle Windows Forms UI. I personally do not like Win Forms UI and want to see if I can get some WPF going on in there.
Winforms and WPF are not interchangeable
I have access to the Razor codebase: https://github.com/RazorEnhanced/RazorEnhanced
GitHub
GitHub - RazorEnhanced/RazorEnhanced: Razor Enhanced, an advanced f...
Razor Enhanced, an advanced fork of Razor, the 2D .NET assistant for Ultima Online - GitHub - RazorEnhanced/RazorEnhanced: Razor Enhanced, an advanced fork of Razor, the 2D .NET assistant for Ultim...
If whatever they have is based on Winforms, it's based on Winforms
That's that
And I can make modifications to its compile methodology.
It is "based on winforms" because it is using only CSC compiler and Winforms is written entirely in C#. If there is a method by which I can compile XAML and C# files as necessary into a viable assembly, then I can add that functionality into the application.
If it's based on Winforms, it's based on Winforms
You can't mix and match UI frameworks
Yes you can. I have run a lot of WPF windows through a Win Forms application before.
And vice versa I am pretty sure
In those instances however, I was using MSBuild to build the project. I do not have that luxury here so I am looking for how one would do it "manually".
Using CSC is already hacky as it is
If there is any way to compile XAML files to separate assemblies with CSC, then may god have mercy on our souls, I thankfully don't know of such method
Well as I understand it (and I have not looked into further than a cursory glance at this point) there is a XMLC.exe compiler, but I havent gotten around to looking into how that is used or how the output can be merged with the CSC compiler output into a single assembly.
Everything that I see so far related to XAMLC is from a Xamarin standpoint.
look at how they handle UseWpf in the sdk
go through the project files and understand the build
Which project files?
Oh hO!!! Load the XAML via a XamlReader and set the result to the content of the Window. Call CSC only to compile.
Source: https://iditect.com/article/wpf-program-compilation-from-command-line-to-visual-studio.html
Example 2
from Microsoft sdk
targets and props
Ahh
I can't find any references to a xamlc with regards to WPF after ~2007, and there are no search results in the VS tooling folder
XamlReader may be your best option
Yar Im thinking so.
I am back in front of the computer now so imma give it a shot
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run /close
- otherwise I will mark this as stale and this post will be archived until there is new activity.