Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9509

VSを使わずC#をコンパイルする方法

$
0
0

検証環境

・Windows10 64bit 1909 build 18363.1082
・DotnetFramework x64 v4.0.30319

参考(というかほとんどパクリ…)

https://qiita.com/toshirot/items/dcf7809007730d835cfc

手順

①下記のサンプルcsファイルを作成

test.cs
usingSystem;usingSystem.CodeDom;usingSystem.CodeDom.Compiler;usingSystem.Reflection;usingSystem.Windows.Forms;usingSystem.Drawing;classNeko:Form{[STAThread]publicstaticvoidMain(){GeneratedCodeAttributegeneratedCodeAttribute= new GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator","10.0.0.0);
Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(newNeko());}Neko(){Text="Button Click Sample";ClientSize=newSize(200,200);Buttonbtn1=newButton();TextBoxtxb1=newTextBox();Labellb1=newLabel();btn1.Location=newPoint(50,50);txb1.Location=newPoint(100,100);lb1.Location=newPoint(150,150);btn1.Text="Click!";btn1.Click+=btn1_Click;lb1.Text="test";Controls.AddRange(newControl[]{btn1});Controls.AddRange(newControl[]{txb1});Controls.AddRange(newControl[]{lb1});}voidbtn1_Click(objectsender,System.EventArgse){MessageBox.Show("こんにちはにゃー","挨拶");}}

②コマンドプロントを起動し下記コードを実行

実行
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe D:\test\test.cs

③cmdのカレントディレクトリに"test.exe"が吐き出されるので実行する。
image.png


Viewing all articles
Browse latest Browse all 9509

Trending Articles