-
Notifications
You must be signed in to change notification settings - Fork 564
[xabuild] Find Microsoft.Portable.CSharp.targets #3959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[xabuild] Find Microsoft.Portable.CSharp.targets #3959
Conversation
Context: https://github.com/xamarin/xamarin-android/pull/3393/files Builds for PR dotnet#3393 were failing on Windows because `Microsoft.Portable.CSharp.targets` couldn't be found: > bin\Debug\bin\xabuild /bl Xamarin.Android-Tests.sln ... ...\xamarin-android\external\Java.Interop\lib\mono.linq.expressions\Mono.Linq.Expressions.csproj(108,3): error MSB4019: The imported project "...\xamarin-android\bin\Debug\lib\xamarin.android\xbuild\Microsoft\Portable\v4.0\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. Turns Out that there are *multiple* `Microsoft` directories of consequence, and we need *all* of them to build, including: * `%ProgramFiles(x86)%\Microsoft Visual Studio\2019\*\MSBuild\Microsoft` * `%ProgramFiles(x86)%\MSBuild\Microsoft\Portable` `xabuild.exe` would symlink the first one into `bin\$(Configuration)\lib\xamarin.android\xbuild`, but not the latter, and lack of the `Microsoft\Portable` directory prevented `Microsoft.Portable.CSharp.targets` from being found. Update `xabuild.exe` to know about `%ProgramFiles(x86)%\MSBuild\Microsoft`. Furthermore, because we now have two `Microsoft` directories, `Microsoft` must now become a "normal" directory, which contains symlinks to *all* the known child directories. To support this, "invert" the `symbolicLinks` dictionary so that the keys are the in-tree paths, making it easier to detect when we need to do such merges. Finally, add code to detect if an existing "conflicting" directory (such as `Microsoft`) is a symlink, and remove it if necessary. This should allow `git pull` + rebuild scenarios to work.
|
Just a thought, should we convert
|
|
Locally, I didn’t see it find Converting |
jonathanpeppers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested locally, and these changes seem to work on my machine.
I couldn't find any tests that uses PCLs, so maybe this wasn't actually working before?
tools/xabuild/XABuild.cs
Outdated
| var prevTargetDir = symbolicLinks [inTreeTargetsDir]; | ||
| symbolicLinks.Remove (inTreeTargetsDir); | ||
| if (Directory.Exists (inTreeTargetsDir) && SymbolicLink.IsPathSymlink (inTreeTargetsDir)) { | ||
| Console.WriteLine ($"# jonp: Removing path? {inTreeTargetsDir}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's fine to print this all the time, and just remove the #jonp comment?
Context: dotnet#3959 (comment) Get rid of `#jonp` from the message!
Context: dotnet/android#3959 (comment) Changes: jbevain/mono.linq.expressions@e3372fb...7973f86 * jbevain/mono.linq.expressions@7973f862: Port to .NET SDK style projects
Context: dotnet/android#3959 (comment) Changes: jbevain/mono.linq.expressions@e3372fb...7973f86 * jbevain/mono.linq.expressions@7973f862: Port to .NET SDK style projects
Context: https://github.com/xamarin/xamarin-android/pull/3393/files
Builds for PR #3393 were failing on Windows because
Microsoft.Portable.CSharp.targetscouldn't be found:Turns Out that there are multiple
Microsoftdirectories ofconsequence, and we need all of them to build, including:
%ProgramFiles(x86)%\Microsoft Visual Studio\2019\*\MSBuild\Microsoft%ProgramFiles(x86)%\MSBuild\Microsoft\Portablexabuild.exewould symlink the first one intobin\$(Configuration)\lib\xamarin.android\xbuild, but not the latter,and lack of the
Microsoft\Portabledirectory preventedMicrosoft.Portable.CSharp.targetsfrom being found.Update
xabuild.exeto know about%ProgramFiles(x86)%\MSBuild\Microsoft.Furthermore, because we now have two
Microsoftdirectories,Microsoftmust now become a "normal" directory, which containssymlinks to all the known child directories. To support this,
"invert" the
symbolicLinksdictionary so that the keys are thein-tree paths, making it easier to detect when we need to do such
merges.
Finally, add code to detect if an existing "conflicting" directory
(such as
Microsoft) is a symlink, and remove it if necessary.This should allow
git pull+ rebuild scenarios to work.