Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile WPF program with command line?

Tags:

c#

wpf

I need to compile simple WPF application, which I have written using Visual Studio, with the command line C# compiler (i.e csc.exe).

Problem is the error CS0103 — the compiler says that there is no InitializeComponent() method in my program. But that's wrong, because I add System.Xaml.dll. Does anybody know how to solve this?

like image 818
Andrew Lawmaking Avatar asked Nov 02 '15 21:11

Andrew Lawmaking


People also ask

What are WPF commands?

Commanding is an input mechanism in Windows Presentation Foundation (WPF) which provides input handling at a more semantic level than device input. Examples of commands are the Copy, Cut, and Paste operations found on many applications.

How do I get command line arguments in WPF?

Right click on your WPF project in Solution Explorer and select properties. It will display the Window given below. Select Debug option and write the file path in the command line argument.

How do I run a WPF file in Linux?

Option 1: . NET Core 3.0's support for WPF, a WPF application can run on Linux under Wine. Wine is a compatibility layer which allows Windows applications on Linux and other OSes, including . NET Core Windows applications.


1 Answers

Building with MSBuild will be the easier path than with csc.exe. Get the path to the correct MSBuild (Path to MSBuild), since you can have multiple MSBuild versions on your computer, most of the time one per Visual Studio installation.

Then, simply build your project file:

msbuild YourProject.csproj /p:Configuration=Release

and the output will be in the bin/Release folder.

like image 56
Manuel Allenspach Avatar answered Sep 27 '22 20:09

Manuel Allenspach