msbuild
msbuild copied to clipboard
Create proper relative symbolic links
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
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?
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)\
@ladipro this PR will need RequiresSymbolicLinksTheory - can you please add it (reusing the RequiresSymbolicLinksFact)
@ladipro this PR will need
RequiresSymbolicLinksTheory- can you please add it (reusing theRequiresSymbolicLinksFact)
Done.
@ladipro this PR will need
RequiresSymbolicLinksTheory- can you please add it (reusing theRequiresSymbolicLinksFact)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.
And apologies for missing Jan's mention.
Friendly ping, we've been waiting for the fix for 6 years for https://github.com/dotnet/msbuild/issues/3730