C
C#2y ago
tigey

❔ 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
Angius
Angius2y ago
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?
tigey
tigeyOP2y ago
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.
Angius
Angius2y ago
Winforms and WPF are not interchangeable
tigey
tigeyOP2y ago
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...
Angius
Angius2y ago
If whatever they have is based on Winforms, it's based on Winforms That's that
tigey
tigeyOP2y ago
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.
Angius
Angius2y ago
If it's based on Winforms, it's based on Winforms You can't mix and match UI frameworks
tigey
tigeyOP2y ago
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".
Angius
Angius2y ago
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
tigey
tigeyOP2y ago
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.
Anton
Anton2y ago
look at how they handle UseWpf in the sdk go through the project files and understand the build
tigey
tigeyOP2y ago
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
Anton
Anton2y ago
from Microsoft sdk targets and props
tigey
tigeyOP2y ago
Ahh
Trinitek
Trinitek2y ago
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
tigey
tigeyOP2y ago
Yar Im thinking so. I am back in front of the computer now so imma give it a shot
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server