Wiki

Ticket #372 (new defect)

Opened 10 years ago

Last modified 10 years ago

MSBuild Task: a file "cobra" in the project directory causes and error on Windows.

Reported by: thriwkin Owned by:
Priority: minor Milestone:
Component: Cobra Compiler Version: 0.9.6
Keywords: MSBuild Task, Cobra.MSBuild.dll Cc:

Description

- On Windows,
- running "msbuild.exe" or "xbuild.exe" fails
- with a correct "X.cobraproj" and
- a file "cobra" in the same directory or in a subdirectory "bin".

msbuild /t:Rebuild  X.cobraproj
==>
...Cobra.targets(149,3): error MSB6003: 
    The specified task executable "cobra" could not be run. 
    The specified executable is not a valid application for this OS platform. [...X.cobraproj]
xbuild /t:Rebuild  X.cobraproj
==>
...Cobra.targets: error : 
    Error executing tool '...cobra': 
        ApplicationName='...cobra', 
        CommandLine=...
        CurrentDirectory=...
        Native error= %1
    is not a valid Win32 application. 

Reproduction:
An example of this scenario:
The directory "Source" of the Cobra compiler source (svn-3116)
contains
- the "cobra.cobraproj" file
- and the file "cobra", a bash script.

A "Rebuild" command, given in the Cobra IDE or on the commandline

msbuild /t:Rebuild  cobra.cobraproj

produces 2 failures:
First it fails because the .cobraproj file does not contain any assembly reference
-- see ticket:371
After having inserted an assembly reference,
it fails because the directory of the "cobra.cobraproj" file contains the file "cobra".
Moving the file "cobra" into a subdirectory "bin" does not help.
After having renamed this file, e.g to "(cobra)", all works well.

Change History

Changed 10 years ago by thriwkin

The failure is caused by the MSBuild Task:

# file "CobraCompiler.cobra" in dir "Cobra.MSBuild"
class CobraCompiler ...
    def generateFullPathToTool as String? is protected, override
        cmd = CobraCommand.find     ## <=== 
        if cmd <> nil
            return cmd.path    ## <=== 
            ...

# file "CobraCommand.cobra", in dir "Cobra.Core"
class CobraCommand
    ...
    def _find(path as String, firstTime as bool) as String?
        ...
        else if Directory.exists(path)
            exts = ['', '.cmd', '.bat', '.exe']    ## <=== 
            ...

Possible fix:

        ...
        else if Directory.exists(path)
            if CobraCore.isRunningOnWindows
                exts = ['.cmd', '.bat', '.exe']
            else
                exts = ...


Note: See TracTickets for help on using tickets.