0

I have a project which can be compiled perfectly into vs2012 without ANY warning/error.

When I try to compile the same project using msbuild 3.5 or 3.0 I get this errors:

Microsoft (R) Build Engine, versión 3.5.30729.5420
[Microsoft .NET Framework, versión 2.0.50727.5420]
Copyright (C) Microsoft Corporation 2007. Reservados todos los derechos.

Build started 12/05/2013 22:50:43.
Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" on node 0 (default targets).
  Building solution configuration "Debug|Any CPU".
Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" (1) is building "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Extractor.vbproj" (2) on node 0 (default targets).
Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5".
CoreResGen:
  No hay ningún recurso obsoleto con respecto a sus archivos de código fuente. Se omitirá la generación de recursos.
C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(24): error BC30124: La propiedad sin un especificador 'ReadOnly' o 'WriteOnly' debe proporcionar una instrucci¾n 'Get' y una instrucci¾n 'Set'.
C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30634: La instrucci¾n no puede aparecer dentro del cuerpo de una propiedad. Se supone el final de la propiedad.
C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30025: Falta 'End Property' en Property.
C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(57): error BC32035: El especificador de atributo no es una instrucci¾n completa. Utilice una continuaci¾n de lÝnea para aplicar el atributo a la instrucci¾n siguiente.
C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(61): error BC30456: 'Key' no es un miembro de 'Virtuosa_Game_Packer.Shortcut.HotKeyEventArgs'.
Done Building Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Extractor.vbproj" (default targets) -- FAILED.
Done Building Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" (default targets) -- FAILED.

Build FAILED.

"C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" (default target) (1) ->
"C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Extractor.vbproj" (default target) (2) ->
(CoreCompile target) -> 
  C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(24): error BC30124: La propiedad sin un especificador 'ReadOnly' o 'WriteOnly' debe proporcionar una instrucci¾n 'Get' y una instrucci¾n 'Set'.
  C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30634: La instrucci¾n no puede aparecer dentro del cuerpo de una propiedad. Se supone el final de la propiedad.
  C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30025: Falta 'End Property' en Property.
  C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(57): error BC32035: El especificador de atributo no es una instrucci¾n completa. Utilice una continuaci¾n de lÝnea para aplicar el atributo a la instrucci¾n siguiente.
  C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(61): error BC30456: 'Key' no es un miembro de 'Virtuosa_Game_Packer.Shortcut.HotKeyEventArgs'.

    0 Warning(s)
    5 Error(s)

Time Elapsed 00:00:00.25

Is fully necessary for me to compile this project using msbuild, I need to avoid that errors.

Possible solution 1?: A switch or something else in msbuild.exe to ommit the critical errors?

Possible solution 2?: If someone can help making the necessary modifications to my class (I don't know how to do it by myself):

This is the GlobalHotkeys class where all are the suppossed errors... (Like I said the project can be compiled using the VS IDE without any error or warning):

#Region " GlobalHotkeys Class "

Class Shortcut

    Inherits NativeWindow
    Implements IDisposable

    Protected Declare Function UnregisterHotKey Lib "user32.dll" (ByVal handle As IntPtr, ByVal id As Integer) As Boolean
    Protected Declare Function RegisterHotKey Lib "user32.dll" (ByVal handle As IntPtr, ByVal id As Integer, ByVal modifier As Integer, ByVal vk As Integer) As Boolean

    Event Press(ByVal sender As Object, ByVal e As HotKeyEventArgs)
    Protected EventArgs As HotKeyEventArgs, ID As Integer

    Enum Modifier As Integer
        None = 0
        Alt = 1
        Ctrl = 2
        Shift = 4
    End Enum

    Class HotKeyEventArgs

        Inherits EventArgs
        Property Modifier As Shortcut.Modifier
        Property Key As Keys

    End Class

    Class RegisteredException

        Inherits Exception
        Protected Const s As String = "Shortcut combination is in use."

        Sub New()
            MyBase.New(s)
        End Sub

    End Class

    Private disposed As Boolean

    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
        If Not disposed Then UnregisterHotKey(Handle, ID)
        disposed = True
    End Sub

    Protected Overrides Sub Finalize()
        Dispose(False)
        MyBase.Finalize()
    End Sub

    Sub Dispose() Implements IDisposable.Dispose
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub

    <DebuggerStepperBoundary()>
    Sub New(ByVal modifier As Modifier, ByVal key As Keys)
        CreateHandle(New CreateParams)
        ID = GetHashCode()
        EventArgs = New HotKeyEventArgs With {.Key = key, .Modifier = modifier}
        If Not RegisterHotKey(Handle, ID, modifier, key) Then Throw New RegisteredException
    End Sub

    Shared Function Create(ByVal modifier As Modifier, ByVal key As Keys) As Shortcut
        Return New Shortcut(modifier, key)
    End Function

    Protected Sub New()
    End Sub

    Protected Overrides Sub WndProc(ByRef m As Message)
        Select Case m.Msg
            Case 786
                RaiseEvent Press(Me, EventArgs)
            Case Else
                MyBase.WndProc(m)
        End Select
    End Sub

End Class

#End Region
4

1 に答える 1

4

フレームワークのターゲット バージョンと言語バージョンには違いがあります。新しい言語機能を使用していて、.NET 3.0 または 3.5 をターゲットにしているようです。それは問題ありませんが、これらの言語機能を理解するコンパイラを使用する必要があります

基本的に、MSBuild 4 (または現在のバージョンが何であれ) を使用します。それでも.NET 3.0をターゲットにすることができます。または、古い言語機能に限定してください。Visual Studio には、プロジェクトで使用できる言語バージョンを選択するためのダイアログがあります (少なくとも C# プロジェクトにはあります)。

ここに画像の説明を入力

注: 特定の言語バージョンに制限するのに役立つ同様のオプションが VB にあるかどうかはわかりません。


具体的には、ここでの言語機能は「自動実装プロパティ」であると思われます。古いコンパイラを使用することを主張する場合は、長い構文を使用する必要があります。

于 2013-05-12T21:47:27.590 に答える