MrMiketheripper
MrMiketheripper

Reputation: 143

Unable to use xbuild to build solution (Mono)

When trying to use xbuild to build my solution through Mono on Mac and Linux (haven't tested under Windows yet), I get this strange error that I've been unable to find anywhere else.

Errors:

/Users/macbook/git/DiscordSharp/DiscordSharp.sln (default targets) ->
(Build target) ->
/Users/macbook/git/DiscordSharp/DiscordSharp/DiscordSharp.csproj (default targets) ->
/Library/Frameworks/Mono.framework/Versions/4.2.2/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

    /Library/Frameworks/Mono.framework/Versions/4.2.2/lib/mono/4.5/Microsoft.CSharp.targets: error : Tool executable '/MSBuild/14.0/Bin/mcs.exe' could not be found

     1 Warning(s)
     1 Error(s)

Time Elapsed 00:00:02.0472770
MacBooks-MacBook:DiscordSharp macbook$ 

Interestingly enough, I am able to open the solution in MonoDevelop and build it that way. The projects in the solution target Mono / .NET Framework 4.5. I'm running Mono 4.2 SR1 (4.2.2.30).

What could be causing this issue and in what way could I fix it? This problem prevented me from using TravisCI with this project and I have yet to find a fix for it.

Upvotes: 1

Views: 7691

Answers (1)

SushiHangover
SushiHangover

Reputation: 74094

The .csproj file is only defining a non-Unix CscToolPath for a Platform conditional (OS should be used...), not sure what the requirement is for v14 for Windows(?), so as a test:

vi DiscordSharp/DiscordSharp.csproj

Remove:

<PropertyGroup Condition="'$(Platform)' != 'Unix'">
    <CscToolPath>$(MSBuildProgramFiles32)\MSBuild\14.0\Bin</CscToolPath>
</PropertyGroup>

Rebuild project and it should work fine:

nuget restore
xbuild DiscordSharp.sln

If v14 MSbuild is required for Windows, you can use the following:

<PropertyGroup Condition="'$(OS)' != 'Unix'">
    <CscToolPath>$(MSBuildProgramFiles32)\MSBuild\14.0\Bin</CscToolPath>
</PropertyGroup>

http://www.mono-project.com/archived/porting_msbuild_projects_to_xbuild/

Then the following should run fine with no errors:

xbuild /target:clean
xbuild /target:build

Upvotes: 2

Related Questions