Windows: How to compile WPF XAML-based program from command line?

坚强是说给别人听的谎言 提交于 2019-12-24 12:59:42

问题


I'm not very impressed with Visual Studio Express 2013, which is the free version of Visual Studio. I would greatly prefer to just compile my C# program form the command line. I've located the compiler csc.exe and I located the DLL files for .NET, but how can I compile a XAML file?


回答1:


You want to use MSBuild (MSDN). This is the standard way to compile .NET projects from command line. This is also the compiler that Visual Studio uses internally. You have to have a .csproj/.sln file for it to work, but it will be the fastest and most effective way to get to where it sounds like you want to be.




回答2:


You're looking for MSBuild. Visual Studio projects are XML scripts for MSBuild. To build a project or solution, you can use the following commands:

MSBuild MyApp.sln
MSBuild MyApp.csproj

Building XAML files is far from trivial and C# compiler isn't enough for this. The most recent MSBuild targets for XAML is in the C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Xaml.targets file. But doing all this manually isn't the best idea, you'll just overcomplicate things even if you manage to do everything without MSBuild.



来源:https://stackoverflow.com/questions/22316544/windows-how-to-compile-wpf-xaml-based-program-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!