Skip to content

[build] Fixes needed to build Xamarin.Android.sln with 'dotnet build' - #6390

Merged
jonpryor merged 2 commits into
mainfrom
dotnet-build
Oct 20, 2021
Merged

jonpryor merged 2 commits into
mainfrom
dotnet-build

Conversation

@jpobst

@jpobst jpobst commented Oct 13, 2021 •

Copy link
Copy Markdown
Contributor

Some fixes that were required to get Xamarin.Android.sln to build with dotnet build on Mac:

dotnet build Xamarin.Android.sln -m:1

Largely this is just path separator fixes for instances where .NET's msbuild doesn't fix paths that Mono's msbuild does.

Additionally change api-compat to run on dotnet when building with dotnet build. Mono allows you to Process.Start ("blah.exe") and it will automagically change it to "mono blah.exe" behind your back. .NET doesn't do this, so we need to explicitly call mono or dotnet when running on .NET. We went with dotnet as long as we were making changes anyways.

Note: This is not an exhaustive PR of needed changes, but combined with #6388 it's pretty close.

Also note: This does not attempt to eliminate Mono from the build, targets that <Exec> out to run .exe processes (like api-merge.exe) still use Mono.

@jpobst
jpobst force-pushed the dotnet-build branch 5 times, most recently from 57b12d3 to 766305e Compare October 14, 2021 18:08
@jpobst
jpobst marked this pull request as ready for review October 14, 2021 23:10
@jpobst
jpobst requested a review from pjcollins October 14, 2021 23:10
@dellis1972

Copy link
Copy Markdown
Contributor

This seems to work

  <Target Name="Test">
    <Message Text="$([System.IO.Path]::DirectorySeparatorChar)" />
  </Target>

So we might be able to setup a property which contains DirectorySeparatorChar so its not all /

@jonathanpeppers

Copy link
Copy Markdown
Member

@dellis1972 about $([System.IO.Path]::DirectorySeparatorChar), I found that / seems to generally be used more in newer .NET (core) related MSBuild targets.

I find it's used most often in dotnet/sdk, and they're not using \ hardly at all anymore. Maybe we should follow this for new code?

@jpobst

jpobst commented Oct 15, 2021

Copy link
Copy Markdown
Contributor Author

It seems like always using / is a good option, since Windows happily accepts it.

The only quirk I found is that if you are starting a relative path with ../ instead of ..\ the value needs to be quoted on Windows.

Works:

<Exec Command='MyBinary.exe ..\output.txt' />
<Exec Command='MyBinary.exe &quot;../output.txt&quot;' />

Doesn't work:

<Exec Command='MyBinary.exe ../output.txt' />

@jonpryor

Copy link
Copy Markdown
Contributor

Some questions:

  1. How "complete" is this? "This is not an exhaustive PR of needed changes" implies it's not complete.
  2. Should we create a new build lane which uses dotnet build on macOS, a'la 214dd76, or should we just update & replace the current macOS build job when this is complete?
  3. Even if this isn't complete (1) and we don't want to create or replace an existing CI lane (2), should this be merged anyway until (1)+(2) can be done?

What's the expected "strategy" here?

@jpobst

jpobst commented Oct 18, 2021 •

Copy link
Copy Markdown
Contributor Author

I have it building locally with dotnet build, but it requires additional hack(s) that I'm not yet sure how to do properly. So we cannot set up a new lane or replace the existing one yet.

I think which strategy we eventually decide to do will come down to if we intend to continue supporting building with mono msbuild. I suspect any build system we aren't testing in CI will quickly bit-rot. If we are comfortable losing the ability to build with mono then we should switch the existing Mac/Win lanes to use dotnet. If not, we will need to build both with 2 lanes.

These fixes seem rather trivial and compatible with the current system, so I think we should go ahead and commit them.

jpobst and others added 2 commits October 19, 2021 09:07
@jonpryor
jonpryor merged commit c791cb4 into main Oct 20, 2021
@jonpryor
jonpryor deleted the dotnet-build branch October 20, 2021 13:26
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants