Cake: Error finding csc.exe when building iOS Library project

Created on 5 Sep 2017  路  6Comments  路  Source: cake-build/cake

What You Are Seeing?

I have a sln with multiple library projects (PCL, Android, iOS, UWP, .Net4.6), all but the iOS project build fine by just calling DotNetBuild(solutionFile); but the iOS project gives this error

(CoreCompile target) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(88,5):
    error MSB6004: The specified task executable location "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\Roslyn\csc.exe" is invalid.

What is Expected?

Build completes successfully

What version of Cake are you using?

0.21.1

Are you running on a 32 or 64 bit system?

64

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

VSTS (Hosted VS2017)

How Did You Get This To Happen? (Steps to Reproduce)

Build an iOS Library project

Output Log

Most helpful comment

I tracked it down to this code https://github.com/cake-build/cake/blob/3514e4066245981715d4e66f36c64397f4618ec6/src/Cake.Common/Tools/MSBuild/MSBuildResolver.cs#L104 and my workaround was to stop using DotNetBuild and go back to manually calling MsBuild and XBuild depending on platform in order to set SetMSBuildPlatform(MSBuildPlatform.x86) on MSBuild.

It seems like Cake should either expose MSBuildPlatform on DotNetBuildSettings or provide an additional settings action on DotNetBuild() that takes MSBuildSettings.

Or perhaps I'm just doing something wrong.

All 6 comments

I tracked it down to this code https://github.com/cake-build/cake/blob/3514e4066245981715d4e66f36c64397f4618ec6/src/Cake.Common/Tools/MSBuild/MSBuildResolver.cs#L104 and my workaround was to stop using DotNetBuild and go back to manually calling MsBuild and XBuild depending on platform in order to set SetMSBuildPlatform(MSBuildPlatform.x86) on MSBuild.

It seems like Cake should either expose MSBuildPlatform on DotNetBuildSettings or provide an additional settings action on DotNetBuild() that takes MSBuildSettings.

Or perhaps I'm just doing something wrong.

I worked around it like this

new MSBuildSettings
    {
        ToolVersion = MSBuildToolVersion.VS2017,
        MSBuildPlatform = (Cake.Common.Tools.MSBuild.MSBuildPlatform)1
    }

Hey @ChaseFlorell, unless I'm forgetting something DotNetBuild takes DotNetBuildSettings not MSBuildSettings

ah, my mistake. I'm just using MSBuild() which takes MSBuildSettings.
I ran into the exact same issue as you using MSBuild(), so that's why I posted the solution. I guess I just didn't read it close enough.

Are you able to use MSBuild instead of DotNetBuild?

Yeah. As per my comment above I'm just calling XBuild & MSBuild directly since DotNetBuild is just a (very) simple abstraction over them. So I pass in DotNetBuildSettings to my build method, then branch on IsRunningOnUnix() and copy the fields from DotNetBuildSettings to the relevant X or MS build settings manually, and also set MSBuildPlatform = MSBuildPlatform.x86 and ToolVersion = MSBuildToolVersion.VS2017

Yip and mono now ships with MSBuild, so that and .NET Core CLI will likely be the recommended way going forward.

DotnetBuild alias came before .NET CLI existed, IMHO it adds more confusion than benefit, so not unlikely it'll be obsoleted in the future.

Was this page helpful?
0 / 5 - 0 ratings