From fa98ec10e49b99332b07136fc5fdb262084262a6 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Mon, 19 Apr 2021 17:00:59 +0000 Subject: [PATCH 1/3] Update dependencies from https://github.com/dotnet/icu build 20210416.1 Microsoft.NETCore.Runtime.ICU.Transport From Version 6.0.0-preview.4.21212.2 -> To Version 6.0.0-preview.4.21216.1 --- eng/Version.Details.xml | 2 +- eng/Versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index d565758df050d..5c969b34b5b4d 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,6 +1,6 @@ - + https://github.com/dotnet/icu 313017d0effca6e8ade5fefc8e580224e65d8525 diff --git a/eng/Versions.props b/eng/Versions.props index fa4e877d412d9..7e7b1a1e34a9c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -167,7 +167,7 @@ 6.0.100-preview.2.21215.2 - 6.0.0-preview.4.21212.2 + 6.0.0-preview.4.21216.1 9.0.1-alpha.1.21212.1 9.0.1-alpha.1.21212.1 From fe173a023e5e92208694c2259279f5f0a3cc2028 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Tue, 20 Apr 2021 10:32:39 -0700 Subject: [PATCH 2/3] Try to use File.Delete and dispose --- .../AppHostUsedWithSymbolicLinks.cs | 54 +++++--------- .../tests/TestUtils/SymbolicLinking.cs | 70 ++++++++++++------- 2 files changed, 60 insertions(+), 64 deletions(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs index b36fb4311791f..c457b668e611c 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs @@ -16,12 +16,6 @@ public class AppHostUsedWithSymbolicLinks : IClassFixture apphost - string secondSymbolicLink = Path.Combine(testDir, secondSymlinkRelativePath); - CreateSymbolicLink(secondSymbolicLink, appExe); + using var secondSymbolicLink = new SymLink(Path.Combine(testDir, secondSymlinkRelativePath), appExe); // first symlink -> second symlink - string firstSymbolicLink = Path.Combine(testDir, firstSymlinkRelativePath); - CreateSymbolicLink(firstSymbolicLink, secondSymbolicLink); + using var firstSymbolicLink = new SymLink(Path.Combine(testDir, firstSymlinkRelativePath), secondSymbolicLink.SrcPath); - Command.Create(firstSymbolicLink) + Command.Create(firstSymbolicLink.SrcPath) .CaptureStdErr() .CaptureStdOut() .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello World"); - - if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - Directory.Delete(firstSymbolicLink); - Directory.Delete(secondSymbolicLink); - } } //[Theory] @@ -114,10 +100,9 @@ public void Run_framework_dependent_app_behind_symlink(/* string symlinkRelative var builtDotnet = fixture.BuiltDotnet.BinPath; var testDir = Directory.GetParent(fixture.TestProject.Location).ToString(); Directory.CreateDirectory(Path.Combine(testDir, Path.GetDirectoryName(symlinkRelativePath))); - var symlinkFullPath = Path.Combine(testDir, symlinkRelativePath); - CreateSymbolicLink(symlinkFullPath, appExe); - Command.Create(symlinkFullPath) + using var symlink = new SymLink(Path.Combine(testDir, symlinkRelativePath), appExe); + Command.Create(symlink.SrcPath) .CaptureStdErr() .CaptureStdOut() .EnvironmentVariable("DOTNET_ROOT", builtDotnet) @@ -143,9 +128,9 @@ public void Run_framework_dependent_app_with_runtime_behind_symlink() var dotnetSymlink = Path.Combine(testDir, "dotnet"); var dotnetDir = fixture.BuiltDotnet.BinPath; - CreateSymbolicLink(dotnetSymlink, dotnetDir); + using var symlink = new SymLink(dotnetSymlink, dotnetDir); Command.Create(appExe) - .EnvironmentVariable("DOTNET_ROOT", dotnetSymlink) + .EnvironmentVariable("DOTNET_ROOT", symlink.SrcPath) .CaptureStdErr() .CaptureStdOut() .Execute() @@ -168,7 +153,7 @@ public void Put_app_directory_behind_symlink() var binDirNewPath = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutTheBinDirSomewhereElse"); Directory.Move(binDir, binDirNewPath); - CreateSymbolicLink(binDir, binDirNewPath); + using var symlink = new SymLink(binDir, binDirNewPath); Command.Create(appExe) .CaptureStdErr() .CaptureStdOut() @@ -192,18 +177,13 @@ public void Put_dotnet_behind_symlink() var testDir = Directory.GetParent(fixture.TestProject.Location).ToString(); var dotnetSymlink = Path.Combine(testDir, "dotnet"); - CreateSymbolicLink(dotnetSymlink, dotnetExe); - Command.Create(dotnetSymlink, fixture.TestProject.AppDll) + using var symlink = new SymLink(dotnetSymlink, dotnetExe); + Command.Create(symlink.SrcPath, fixture.TestProject.AppDll) .CaptureStdErr() .CaptureStdOut() .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello World"); - - if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - Directory.Delete(dotnetSymlink); - } } [Fact] @@ -221,7 +201,7 @@ public void Put_app_directory_behind_symlink_and_use_dotnet() var binDirNewPath = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutTheBinDirSomewhereElse"); Directory.Move(binDir, binDirNewPath); - CreateSymbolicLink(binDir, binDirNewPath); + using var symlink = new SymLink(binDir, binDirNewPath); dotnet.Exec(fixture.TestProject.AppDll) .CaptureStdErr() .CaptureStdOut() @@ -242,10 +222,10 @@ public void Put_app_directory_behind_symlink_and_use_dotnet_run() var dotnet = fixture.SdkDotnet; var binDir = fixture.TestProject.OutputDirectory; - var binDirNewPath = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutTheBinDirSomewhereElse"); + var binDirNewPath = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutTheBinDirSomewhereElse"); Directory.Move(binDir, binDirNewPath); - CreateSymbolicLink(binDir, binDirNewPath); + using var symlink = new SymLink(binDir, binDirNewPath); dotnet.Exec("run") .WorkingDirectory(fixture.TestProject.Location) .CaptureStdErr() @@ -275,12 +255,12 @@ public void Put_satellite_assembly_behind_symlink() var firstSatelliteDir = Directory.GetDirectories(binDir).Single(dir => dir.Contains("kn-IN")); var firstSatelliteNewDir = Path.Combine(satellitesDir, "kn-IN"); Directory.Move(firstSatelliteDir, firstSatelliteNewDir); - CreateSymbolicLink(firstSatelliteDir, firstSatelliteNewDir); + using var symlink1 = new SymLink(firstSatelliteDir, firstSatelliteNewDir); var secondSatelliteDir = Directory.GetDirectories(binDir).Single(dir => dir.Contains("ta-IN")); var secondSatelliteNewDir = Path.Combine(satellitesDir, "ta-IN"); Directory.Move(secondSatelliteDir, secondSatelliteNewDir); - CreateSymbolicLink(secondSatelliteDir, secondSatelliteNewDir); + using var symlink2 = new SymLink(secondSatelliteDir, secondSatelliteNewDir); Command.Create(appExe) .CaptureStdErr() diff --git a/src/installer/tests/TestUtils/SymbolicLinking.cs b/src/installer/tests/TestUtils/SymbolicLinking.cs index 564a25f714650..81ed64bf115d7 100644 --- a/src/installer/tests/TestUtils/SymbolicLinking.cs +++ b/src/installer/tests/TestUtils/SymbolicLinking.cs @@ -2,63 +2,79 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.IO; using System.Runtime.InteropServices; +#nullable enable + namespace Microsoft.DotNet.CoreSetup.Test { - public static class SymbolicLinking + public sealed class SymLink : IDisposable { - static class Kernel32 + public string SrcPath { get; private set; } + public SymLink(string src, string dest) { - [Flags] - internal enum SymbolicLinkFlag + if (!MakeSymbolicLink(src, dest, out var errorMessage)) { - IsFile = 0x0, - IsDirectory = 0x1, - AllowUnprivilegedCreate = 0x2 + throw new IOException($"Error creating symbolic link at {src} pointing to {dest}: {errorMessage}"); } - - [DllImport("kernel32.dll", SetLastError = true)] - internal static extern bool CreateSymbolicLink( - string symbolicLinkName, - string targetFileName, - SymbolicLinkFlag flags); + SrcPath = src; } - static class libc + public void Dispose() { - [DllImport("libc", SetLastError = true)] - internal static extern int symlink( - string targetFileName, - string linkPath); - - [DllImport("libc", CharSet = CharSet.Ansi)] - internal static extern IntPtr strerror(int errnum); + if (SrcPath is not null) + { + File.Delete(SrcPath); + SrcPath = null!; + } } - public static bool MakeSymbolicLink(string symbolicLinkName, string targetFileName, out string errorMessage) + private static bool MakeSymbolicLink(string symbolicLinkName, string targetFileName, out string errorMessage) { errorMessage = string.Empty; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Kernel32.CreateSymbolicLink(symbolicLinkName, targetFileName, Kernel32.SymbolicLinkFlag.IsFile)) + if (!CreateSymbolicLink(symbolicLinkName, targetFileName, SymbolicLinkFlag.IsFile)) { int errno = Marshal.GetLastWin32Error(); errorMessage = $"CreateSymbolicLink failed with error number {errno}"; return false; } } - else + else { - if (libc.symlink(targetFileName, symbolicLinkName) == -1) + if (symlink(targetFileName, symbolicLinkName) == -1) { int errno = Marshal.GetLastWin32Error(); - errorMessage = Marshal.PtrToStringAnsi(libc.strerror(errno)); - return false; + errorMessage = Marshal.PtrToStringAnsi(strerror(errno))!; + return false; } } return true; } + + [Flags] + private enum SymbolicLinkFlag + { + IsFile = 0x0, + IsDirectory = 0x1, + AllowUnprivilegedCreate = 0x2 + } + + [DllImport("kernel32.dll", SetLastError = true)] + private static extern bool CreateSymbolicLink( + string symbolicLinkName, + string targetFileName, + SymbolicLinkFlag flags); + + [DllImport("libc", SetLastError = true)] + private static extern int symlink( + string targetFileName, + string linkPath); + + [DllImport("libc", CharSet = CharSet.Ansi)] + private static extern IntPtr strerror(int errnum); } } From 4dadbe513ae65f423080d2f68138dfd51dd4af0f Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Tue, 20 Apr 2021 15:35:40 -0700 Subject: [PATCH 3/3] Resolve merge conflict --- .../AppHostUsedWithSymbolicLinks.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs index dbb60c4b58592..f360bd2a25820 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUsedWithSymbolicLinks.cs @@ -65,16 +65,16 @@ public void Run_apphost_behind_transitive_symlinks(string firstSymlinkRelativePa var testDir = Directory.GetParent(fixture.TestProject.Location).ToString(); // second symlink -> apphost - string secondSymbolicLink = Path.Combine(testDir, secondSymlinkRelativePath); - Directory.CreateDirectory(Path.GetDirectoryName(secondSymbolicLink)); - CreateSymbolicLink(secondSymbolicLink, appExe); + string symlink2Path = Path.Combine(testDir, secondSymlinkRelativePath); + Directory.CreateDirectory(Path.GetDirectoryName(symlink2Path)); + using var symlink2 = new SymLink(symlink2Path, appExe); // first symlink -> second symlink - string firstSymbolicLink = Path.Combine(testDir, firstSymlinkRelativePath); - Directory.CreateDirectory(Path.GetDirectoryName(firstSymbolicLink)); - CreateSymbolicLink(firstSymbolicLink, secondSymbolicLink); + string symlink1Path = Path.Combine(testDir, firstSymlinkRelativePath); + Directory.CreateDirectory(Path.GetDirectoryName(symlink1Path)); + using var symlink1 = new SymLink(symlink1Path, symlink2Path); - Command.Create(firstSymbolicLink.SrcPath) + Command.Create(symlink1.SrcPath) .CaptureStdErr() .CaptureStdOut() .Execute()