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
There's a difference between the framework target version, and the language version. It sounds like you are using new language features, and targeting .NET 3.0 or 3.5; that's fine, but you'll need to use a compiler that understands those language features.
Basically, use MSBuild 4 (or whatever the current version is). You can still target .NET 3.0 with that. Alternatively, limit yourself to older language features. There is a dialog in Visual Studio for selecting which language version a project should let you use (or there is for C# projects, at least):
Note: I do not know if VB provides a similar option to help you limit yourself to a particular language version.
Specifically, I suspect the language feature here is "auto-implemented properties" - if you insist on using an older compiler, you'll have to use the long-hand syntax.