Last active
June 14, 2021 08:23
-
-
Save colejhudson/1a6cff9e19206fbcb3823a877bd065dc to your computer and use it in GitHub Desktop.
Windows WPF Boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows; | |
public partial class Viewer: Window { | |
public Viewer() { | |
this.Title = "Simple Window"; | |
this.Width = 300; | |
this.Height = 300; | |
} | |
} | |
class App { | |
[STAThread] | |
static void Main(string[] argv) { | |
Viewer view = new Viewer(); | |
new Application().Run(view); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Windows, as ever, is a bit persnickety to build on if you want to avoid IDEs. It took | |
:: me about a day to figure out how to properly reference the libraries in use below - eons | |
:: in developement time. It's a bit bizarre to me that assemblies - the windowian alias for | |
:: libraries - lack a standardized addressing scheme (like a shared directory) such that | |
:: they could all be referenced with ease. Theoretically I think this may have been the | |
:: historical purpose of C:\Windows\system32. As its turned out libraries, the broader Windows | |
:: development environment, and documentation thereof is totally haphazard. The prominence | |
:: of GitHub lets me mask over these difficulties by directly consulting the source code of | |
:: others. But it would be nice if Microsoft could make the developer experience a bit more | |
:: cohesive. | |
:: | |
:: Regardless, the correct build command (for this simple program) varies in flavor based on | |
:: whether you're using the 'raw' command prompt (cmd.exe) or the developer command prompt | |
:: as instantiated by Visual Studio (VsDevCmd.bat) [1]. In the former case, the first command | |
:: will build the program. In the latter, an additional reference to 'System.Xaml.dll' must | |
:: be included. | |
:: | |
:: Lastly, by default I'm using the C# compiler (csc.exe) included with .NET at [2]. I suspect | |
:: VsDevCmd.bat uses whichever compiler is included with Visual Studio. | |
:: | |
:: [1] https://docs.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2019#developer-command-prompt | |
:: [2] C:\Windows\Microsoft.NET\Framework\<version>\csc.exe | |
:: Builds with cmd.exe | |
csc /r:WPF\PresentationFramework.dll /r:WPF\PresentationCore.dll /r:WPF\WindowsBase.dll /r:System.Xaml.dll App.cs | |
:: Builds with VsDevCmd.exe | |
:: "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" | |
:: csc /r:WPF\PresentationFramework.dll /r:WPF\PresentationCore.dll /r:WPF\WindowsBase.dll App.cs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment