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.
Build completes successfully
0.21.1
64
Windows
VSTS (Hosted VS2017)
Build an iOS Library project
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.
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
DotNetBuildand go back to manually callingMsBuildandXBuilddepending on platform in order to setSetMSBuildPlatform(MSBuildPlatform.x86)on MSBuild.It seems like Cake should either expose
MSBuildPlatformonDotNetBuildSettingsor provide an additional settings action onDotNetBuild()that takesMSBuildSettings.Or perhaps I'm just doing something wrong.