Skip to content

Commit

Permalink
[release/6.0-preview4] Update dependencies from dotnet/icu (#51501)
Browse files Browse the repository at this point in the history
* 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

* Try to use File.Delete and dispose

* Resolve merge conflict

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Andy Gocke <andy@commentout.net>
Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
Co-authored-by: Andy Gocke <angocke@microsoft.com>
  • Loading branch information
5 people authored Apr 21, 2021
1 parent 20b88d5 commit 27f3c26
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 57 deletions.
2 changes: 1 addition & 1 deletion eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="6.0.0-preview.4.21212.2">
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="6.0.0-preview.4.21216.1">
<Uri>https://github.com/dotnet/icu</Uri>
<Sha>313017d0effca6e8ade5fefc8e580224e65d8525</Sha>
</Dependency>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<!-- ILLink -->
<MicrosoftNETILLinkTasksVersion>6.0.100-preview.2.21215.2</MicrosoftNETILLinkTasksVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-preview.4.21212.2</MicrosoftNETCoreRuntimeICUTransportVersion>
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-preview.4.21216.1</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- Mono LLVM -->
<runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>9.0.1-alpha.1.21212.1</runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>
<runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>9.0.1-alpha.1.21212.1</runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ public class AppHostUsedWithSymbolicLinks : IClassFixture<AppHostUsedWithSymboli
{
private SharedTestState sharedTestState;

private void CreateSymbolicLink(string source, string target)
{
if (!SymbolicLinking.MakeSymbolicLink(source, target, out var errorString))
throw new Exception($"Failed to create symbolic link '{source}' targeting: '{target}': {errorString}");
}

public AppHostUsedWithSymbolicLinks(AppHostUsedWithSymbolicLinks.SharedTestState fixture)
{
sharedTestState = fixture;
Expand All @@ -44,7 +38,7 @@ public void Run_apphost_behind_symlink(string symlinkRelativePath)
Directory.CreateDirectory(Path.Combine(testDir, Path.GetDirectoryName(symlinkRelativePath)));
var symlinkFullPath = Path.Combine(testDir, symlinkRelativePath);

CreateSymbolicLink(symlinkFullPath, appExe);
using var symlink = new SymLink(symlinkFullPath, appExe);
Command.Create(symlinkFullPath)
.CaptureStdErr()
.CaptureStdOut()
Expand All @@ -66,21 +60,21 @@ public void Run_apphost_behind_transitive_symlinks(string firstSymlinkRelativePa

var fixture = sharedTestState.StandaloneAppFixture_Published
.Copy();

var appExe = fixture.TestProject.AppExe;
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)
Command.Create(symlink1.SrcPath)
.CaptureStdErr()
.CaptureStdOut()
.Execute()
Expand Down Expand Up @@ -108,10 +102,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)
Expand All @@ -137,9 +130,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()
Expand All @@ -162,7 +155,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()
Expand All @@ -186,8 +179,8 @@ 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()
Expand All @@ -210,7 +203,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()
Expand All @@ -231,10 +224,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()
Expand Down Expand Up @@ -264,12 +257,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()
Expand Down
70 changes: 43 additions & 27 deletions src/installer/tests/TestUtils/SymbolicLinking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 27f3c26

Please sign in to comment.