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
6
  • If you cannot afford to update your version of Visual Studio then use the Express edition. May 12, 2013 at 21:25
  • @Hans Passant Thankyou for comment but I don't understanded what you mean, what is the difference if I write the project using Express Edition? The problem is about the version of VS or is about the MSBuild?, I'm using VisualStudio 2012 Ultimate, Ultimate is better than Express Edition?, the project is written in my version of VS2012 May 12, 2013 at 21:31
  • 1
    You are using the wrong version of MSBuild, version 3 instead of 4. It isn't clear why you don't just open the project in VS2012 or use the appropriate Visual Studio Command Prompt shortcut. May 12, 2013 at 21:34
  • Why you say I need to use the msbuild 4.0? I think I'm using the correct version because the project uses Framework 3.0 in the project properties... but maybe I miss other thing?. EDIT: I need to compile the project by clicking a button in a application, that's why I can't use VS command or open the solution. May 12, 2013 at 21:39
  • 1
    It is clearly visible from the error messages that this is a VS2010+ project. Including the usage of VB.NET language syntax that didn't become available until VS2010. That the project targets an earlier version of .NET is not relevant. May 12, 2013 at 21:43

1 Answer 1

4

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):

enter image description here

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.

3
  • thanks for answer, then.. if in my project settings I use "fW3.0" but I compile the project using msbuild 4.0 (and suppossing msbuild will compile it without errors) then the compiled executable will need fw 4.0 or fw3.0 to run?, I'll go to sleep now, I will test it in the morning, thankyou for all May 12, 2013 at 21:54
  • @ElektroHacker no, it won't need .NET 4.0. MSBuild 4.0 can target framework 3.5, 3.0, or 2.0. Or the newer versions. Or even some custom homebrewed framework that you've cobbled together with ildasm, as long as you have a fully working mscorlib.dll/System.dll May 12, 2013 at 21:57
  • @ElektroHacker, this feature of MSBuild/Visual Studio is called multi-targeting, msdn.microsoft.com/en-us/magazine/ff714560.aspx It requires higher MSBuild.exe (4.0) and csc.exe, but the compiled assemblies only require the targeting .NET runtime (3.5 for example)
    – Lex Li
    May 12, 2013 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.