2013년 5월 31일 금요일

[미완] csc.exe를 사용해서 c#작성

분류 > c#, .Net

Visual Studio 명령 프롬프트
csc -?
(csd=C-Sharp Compiler)

메모장으로 c#코드 작성

Visual Studio 명령 프롬프트 실행
명령 프롬프트에
csc /target:exe C#파일명.cs
csc /t:exe C#파일명.cs
csc C#파일명.cs

그럼 같은 폴더에 C#파일명.exe생성됨

원칙은 dll을 지정(여러개는;로 추가)해야하지만
csc가 자동으로 등록됨

여러 .cs파일 명시
하지만 *.cs하면 폴더에 있는 모든 .cs파일 컴파일


설정들은 .rsp로
.rsp
# 외부 어셈블리 참조
/r:system.Windows.Forms.dll
#출력 형식 및 컴파일할 파일
/target:exe /out:TestApp.exe *.cs

csc @Testapp.rsp

c#컴파일러는 csc.exe 파일이 있는 디렉터리에 기본 응답파일(csc.rsp)을 갖고 있었서
그냥 csc *.cs도 된다

2013년 5월 24일 금요일

2013년 5월 1일 수요일

[미완] using 정렬

분류 > c#, vs

참조
http://weblogs.asp.net/dfindley/archive/2007/02/07/vs-net-macro-to-group-and-sort-your-using-statements.aspx


Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports System.Collections.Generic
Imports System.Text
Imports System.Text.RegularExpressions

Public Module SortUsing

    Dim _usingPattern As Regex = New Regex( _
        "\s*(?<using>using\s*(?<group>\w+)[^;]*);", _
        RegexOptions.IgnoreCase _
        Or RegexOptions.Multiline _
        Or RegexOptions.ExplicitCapture _
        Or RegexOptions.CultureInvariant _
        Or RegexOptions.Compiled _
    )

    Public Sub SortUsing()
        If Not DTE.ActiveDocument Is Nothing Then
            Dim sel As TextSelection = DTE.ActiveDocument.Selection

            If sel.Text.Contains(vbCrLf) Then
                If sel.ActivePoint Is sel.BottomPoint Then sel.SwapAnchor()
                sel.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn, True)
                sel.SwapAnchor()
                sel.EndOfLine(True)

                Dim groups As New SortedList(Of String, List(Of String))()
                For Each match As Match In _usingPattern.Matches(sel.Text)
                    Dim u As String = match.Groups("using").Value
                    Dim g As String = match.Groups("group").Value

                    ' System usings sort at the top
                    If g = "System" Then g = "_" + g

                    Dim list As List(Of String)
                    If Not groups.TryGetValue(g, list) Then
                        list = New List(Of String)()
                        groups.Add(g, list)
                    End If
                    list.Add(u)
                Next

                Dim builder As New StringBuilder()
                For Each group As KeyValuePair(Of String, List(Of String)) In groups
                    If builder.Length > 0 Then builder.AppendLine() ' 여기 주석치면 라인 없어짐
                    group.Value.Sort()
                    For Each line As String In group.Value
                        builder.Append(line)
                        builder.AppendLine(";")
                    Next
                Next

                sel.DeleteLeft()
                sel.Insert(builder.ToString())
            End If
        End If
    End Sub

End Module

[미완] 프로세스 종료 도스 명령어

분류 > 도스

taskkill

예) 메모장 종료
taskkill /f /im notepad.exe