Skip to content
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

Subsequent XABuild do not run #4306

Closed
kant2002 opened this issue Feb 21, 2020 · 5 comments · Fixed by #4332
Closed

Subsequent XABuild do not run #4306

kant2002 opened this issue Feb 21, 2020 · 5 comments · Fixed by #4332
Assignees

Comments

@kant2002
Copy link
Contributor

Steps to Reproduce

In non-admin console.

  1. bin\Debug\bin\xabuild.exe Xamarin.Android-Tests.sln /restore /p:Configuration=Debug /bl:bin\TestDebug\msbuild-build-tests.binlog /p:HOME=f:\d\build
  2. bin\Debug\bin\xabuild.exe Xamarin.Android-Tests.sln /restore /p:Configuration=Debug /bl:bin\TestDebug\msbuild-build-tests.binlog /p:HOME=f:\d\build

Expected Behavior

Symlinks removed

Actual Behavior

First run is ok.
On second run

Removing old symlink: bin\Debug\lib\xamarin.android\xbuild\Microsoft

Unhandled Exception: System.IO.IOException: The directory is not empty.
...
   at System.IO.Directory.Delete(String path)
   at Xamarin.Android.Build.XABuild.Main() in d:\d\kant\GitHub\xamarin-android\tools\xabuild\XABuild.cs:line 67
@kant2002
Copy link
Contributor Author

Ok. I think I miss one important details.

  • GitHub Xamarin location - Phisical drive 2, disk D:
  • Visual Studio Location - Phisical drive 1, disk C:
  • Android Toolset (generally HOME) - Phisical drive 2, disk F:

I strongly suspect that this can cause issue like that when symlink point to another physical drive

@jonathanpeppers
Copy link
Member

@kant2002 do you have "Developer Mode" enabled? https://github.com/xamarin/xamarin-android/blob/f9f5b6cd120484b13df74e94638e07411d8693fa/Documentation/workflow/UsingYourBuild.md#using-your-xamarinandroid-build

I don't know if Windows symlinks work across drives, I have a single 2 TB drive.

@kant2002
Copy link
Contributor Author

Yes. I do have Developer Mode enabled. I will do my research on Windows symlinks and Win32 API, I probably will be able to diagnose that issue, just give me some more time. I mention multiple drives, since I vaguely remember that something can be off in that scenario and this potentially can be important. If you don't mind, my investigation comes in form of PR.

@jonathanpeppers
Copy link
Member

@kant2002 you can try the mklink /D command to do the same thing we are doing:

https://docs.microsoft.com/windows-server/administration/windows-commands/mklink

Let me know if that works across drives, in general, thanks! You might also try an elevated cmd to see if that works. Developer mode should work without elevation, though.

kant2002 added a commit to kant2002/xamarin-android that referenced this issue Feb 26, 2020
For some reasons `Path.GetFullPath (path)` and `GetRealPath (path)` has values which was different case and it reports `bin\Debug\lib\xamarin.android\xbuild\Microsoft` as symlink.
Example difference in cases:
```
d:\xamarin-android\bin\Debug\lib\xamarin.android\xbuild\Microsoft <-> D:\xamarin-android\bin\Debug\lib\xamarin.android\xbuild\Microsoft
```

Fix dotnet#4306
@kant2002
Copy link
Contributor Author

I have a feling that there slight misunderstanding. I have no problem create symlink, the problem with removing existing symlink by XABuild.

But real cause is more then funny. see upcoming PR

jonpryor pushed a commit that referenced this issue Feb 26, 2020
Fixes: #4306

Context: c36229c

[`Path.GetFullPath()`][0] and [`GetFinalPathNameByHandleW()`][1] may
return paths with different cases, in particular the file system
drive character may be lower-case with `GetFinalPathNameByHandleW()`
and upper-case with `Path.GetFullPath()`:

  *          Path.GetFullPath(): D:\xamarin-android\bin\Debug\lib\xamarin.android\xbuild\Microsoft
  * GetFinalPathNameByHandleW(): d:\xamarin-android\bin\Debug\lib\xamarin.android\xbuild\Microsoft


This case difference could cause  `xabuild` to attempt to remove a
directory when it didn't otherwise need to, which would cause build
failures when building within a non-elevated command prompt as the
directories -- which were actually symbolic links -- could not be
removed by a non-administrative user.

[0]: https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getfullpath?view=netframework-4.8
[1]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew
@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
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 a pull request may close this issue.

5 participants