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 回答