msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Create proper relative symbolic links

Open manfred-brands opened this issue 2 years ago • 6 comments

Fixes #3730

Context

Symbolic link in the bin folder to obj/Assembly.dll were created just like that.

Changes Made

Converted relative paths to be relative to the target directory resulting in: ../obj/Assembly.dll Modified NativeMethods.MakeSymbolicLink

Testing

Updated one unit test to test both absolute and relative paths. This failed before my changes, succeeds now. As Path.GetRelativePath is not supported on netstandard2.0 and net472, I added a local version with appropriate unit tests.

Notes

manfred-brands avatar Dec 18 '22 02:12 manfred-brands

The azure pipeline doesn't give a proper line number for the failing MacOS test and I don't see any artefacts I can look at. As I don't have access to a Mac I cannot run those test my self. Any suggestions on how to resolve this?

manfred-brands avatar Dec 19 '22 01:12 manfred-brands

Microsoft.Build.UnitTests.CopySymbolicLink_Tests.CopyToDestinationFolderWithSymbolicLinkCheck(useRelative: True)
System.IO.FileNotFoundException : Could not find file '/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/uiack5y3.3xu/2A333ED756AF4dc392E728D0F864A398/tmp5e9beda9b70849c6a8b53561d26ccb64.tmp'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
   at System.IO.File.ReadAllText(String path, Encoding encoding)
   at Microsoft.Build.UnitTests.CopySymbolicLink_Tests.CopyToDestinationFolderWithSymbolicLinkCheck(Boolean useRelative) in /Users/runner/work/1/s/src/Tasks.UnitTests/Copy_Tests.cs:line 2441
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)\

Forgind avatar Dec 21 '22 00:12 Forgind

@ladipro this PR will need RequiresSymbolicLinksTheory - can you please add it (reusing the RequiresSymbolicLinksFact)

JanKrivanek avatar Feb 20 '23 14:02 JanKrivanek

@ladipro this PR will need RequiresSymbolicLinksTheory - can you please add it (reusing the RequiresSymbolicLinksFact)

Done.

manfred-brands avatar Mar 13 '23 06:03 manfred-brands

@ladipro this PR will need RequiresSymbolicLinksTheory - can you please add it (reusing the RequiresSymbolicLinksFact)

Done.

Thank you for taking care of it! We may want to move the code from the constructor to a helper method so it's not duplicated in RequiresSymbolicLinksTheory and RequiresSymbolicLinksFact but that's not a blocking issue.

ladipro avatar Mar 13 '23 07:03 ladipro

And apologies for missing Jan's mention.

ladipro avatar Mar 13 '23 07:03 ladipro

Friendly ping, we've been waiting for the fix for 6 years for https://github.com/dotnet/msbuild/issues/3730

vaboca avatar Apr 02 '25 16:04 vaboca