Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e572e9

Browse files
authored
Allow muxer behind Windows symlink (#99576)
The current logic for the muxer (dotnet.exe) doesn't resolve through symlinkson Windows. For instance, it looks next to the entry point path for things likehostfxr. This means that you cannot use a symlink to dotnet.exe, as it will looknext to your symlink for the runtime, rather than next to the target of the symlink.This PR fixes the problem just for the muxer. To do so, it introduces a new API:fullpath. The existing realpath API has the behavior of always resolving symlinkson Unix, and never resolving symlinks on Windows. The new `fullpath` API replicatesthis behavior, while the old `realpath` API is changed to always resolve symlinks onboth Unix and Windows. Then, the realpath API is used in appropriate places whenresolving paths relative to the muxer to guarantee resolving through symlinks onall platforms.Fixes#83314
1 parent3250965 commit3e572e9

31 files changed

+183
-93
lines changed

‎src/installer/tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private void AbsolutePath()
3131
varbundleDir=Directory.GetParent(bundledApp.Path);
3232
bundleDir.Should().OnlyHaveFiles(new[]
3333
{
34-
Binaries.GetExeFileNameForCurrentPlatform(app.Name),
34+
Binaries.GetExeName(app.Name),
3535
$"{app.Name}.pdb"
3636
});
3737

‎src/installer/tests/HostActivation.Tests/InvalidHost.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ public SharedTestState()
9090
BaseDirectory=TestArtifact.Create(nameof(InvalidHost));
9191
Directory.CreateDirectory(BaseDirectory.Location);
9292

93-
RenamedDotNet=Path.Combine(BaseDirectory.Location,Binaries.GetExeFileNameForCurrentPlatform("renamed"));
93+
RenamedDotNet=Path.Combine(BaseDirectory.Location,Binaries.GetExeName("renamed"));
9494
File.Copy(Binaries.DotNet.FilePath,RenamedDotNet);
9595

96-
UnboundAppHost=Path.Combine(BaseDirectory.Location,Binaries.GetExeFileNameForCurrentPlatform("unbound"));
96+
UnboundAppHost=Path.Combine(BaseDirectory.Location,Binaries.GetExeName("unbound"));
9797
File.Copy(Binaries.AppHost.FilePath,UnboundAppHost);
9898

9999
if(OperatingSystem.IsWindows())
100100
{
101101
// Mark the apphost as GUI, but don't bind it to anything - this will cause it to fail
102-
UnboundAppHostGUI=Path.Combine(BaseDirectory.Location,Binaries.GetExeFileNameForCurrentPlatform("unboundgui"));
102+
UnboundAppHostGUI=Path.Combine(BaseDirectory.Location,Binaries.GetExeName("unboundgui"));
103103
File.Copy(Binaries.AppHost.FilePath,UnboundAppHostGUI);
104104
PEUtils.SetWindowsGraphicalUserInterfaceBit(UnboundAppHostGUI);
105105
}

‎src/installer/tests/HostActivation.Tests/NativeHosting/ComhostSideBySide.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public SharedTestState()
116116
}
117117
}
118118

119-
stringcomsxsName=Binaries.GetExeFileNameForCurrentPlatform("comsxs");
119+
stringcomsxsName=Binaries.GetExeName("comsxs");
120120
ComSxsPath=Path.Combine(comsxsDirectory,comsxsName);
121121
File.Copy(
122122
Path.Combine(RepoDirectoriesProvider.Default.HostTestArtifacts,comsxsName),

‎src/installer/tests/HostActivation.Tests/NativeHosting/SharedTestStateBase.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public SharedTestStateBase()
2121
_baseDirArtifact=TestArtifact.Create("nativeHosting");
2222
BaseDirectory=_baseDirArtifact.Location;
2323

24-
stringnativeHostName=Binaries.GetExeFileNameForCurrentPlatform("nativehost");
24+
stringnativeHostName=Binaries.GetExeName("nativehost");
2525
NativeHostPath=Path.Combine(BaseDirectory,nativeHostName);
2626

2727
// Copy over native host

‎src/installer/tests/HostActivation.Tests/NativeUnitTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class NativeUnitTests
1515
[Fact]
1616
publicvoidNative_Test_Fx_Ver()
1717
{
18-
stringtestPath=Path.Combine(RepoDirectoriesProvider.Default.HostTestArtifacts,Binaries.GetExeFileNameForCurrentPlatform("test_fx_ver"));
18+
stringtestPath=Path.Combine(RepoDirectoriesProvider.Default.HostTestArtifacts,Binaries.GetExeName("test_fx_ver"));
1919

2020
CommandtestCommand=Command.Create(testPath);
2121
testCommand

‎src/installer/tests/HostActivation.Tests/SelfContainedAppLaunch.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void RenameApphost()
9595
{
9696
varapp=sharedTestState.App.Copy();
9797

98-
varrenamedAppExe=app.AppExe+Binaries.GetExeFileNameForCurrentPlatform("renamed");
98+
varrenamedAppExe=app.AppExe+Binaries.GetExeName("renamed");
9999
File.Move(app.AppExe,renamedAppExe,true);
100100

101101
Command.Create(renamedAppExe)

‎src/installer/tests/HostActivation.Tests/SymbolicLinks.cs‎

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public SymbolicLinks(SymbolicLinks.SharedTestState fixture)
2222
}
2323

2424
[Theory]
25-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilege on Windows, so skip test.")]
2625
[InlineData("a/b/SymlinkToApphost")]
2726
[InlineData("a/SymlinkToApphost")]
2827
publicvoidRun_apphost_behind_symlink(stringsymlinkRelativePath)
2928
{
29+
symlinkRelativePath=Binaries.GetExeName(symlinkRelativePath);
3030
using(vartestDir=TestArtifact.Create("symlink"))
3131
{
3232
Directory.CreateDirectory(Path.Combine(testDir.Location,Path.GetDirectoryName(symlinkRelativePath)));
@@ -43,13 +43,14 @@ public void Run_apphost_behind_symlink(string symlinkRelativePath)
4343
}
4444

4545
[Theory]
46-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilege on Windows, so skip test.")]
4746
[InlineData("a/b/FirstSymlink","c/d/SecondSymlink")]
4847
[InlineData("a/b/FirstSymlink","c/SecondSymlink")]
4948
[InlineData("a/FirstSymlink","c/d/SecondSymlink")]
5049
[InlineData("a/FirstSymlink","c/SecondSymlink")]
5150
publicvoidRun_apphost_behind_transitive_symlinks(stringfirstSymlinkRelativePath,stringsecondSymlinkRelativePath)
5251
{
52+
firstSymlinkRelativePath=Binaries.GetExeName(firstSymlinkRelativePath);
53+
secondSymlinkRelativePath=Binaries.GetExeName(secondSymlinkRelativePath);
5354
using(vartestDir=TestArtifact.Create("symlink"))
5455
{
5556
// second symlink -> apphost
@@ -71,15 +72,14 @@ public void Run_apphost_behind_transitive_symlinks(string firstSymlinkRelativePa
7172
}
7273
}
7374

74-
//[Theory]
75-
//[InlineData("a/b/SymlinkToFrameworkDependentApp")]
76-
//[InlineData("a/SymlinkToFrameworkDependentApp")]
77-
[Fact(Skip="Currently failing in OSX with\"No such file or directory\" when running Command.Create. "+
75+
[Theory]
76+
[InlineData("a/b/SymlinkToFrameworkDependentApp")]
77+
[InlineData("a/SymlinkToFrameworkDependentApp")]
78+
[SkipOnPlatform(TestPlatforms.OSX,"Currently failing in OSX with\"No such file or directory\" when running Command.Create. "+
7879
"CI failing to use stat on symbolic links on Linux (permission denied).")]
79-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilege on Windows, so skip test.")]
80-
publicvoidRun_framework_dependent_app_behind_symlink(/*string symlinkRelativePath*/)
80+
publicvoidRun_framework_dependent_app_behind_symlink(stringsymlinkRelativePath)
8181
{
82-
varsymlinkRelativePath=string.Empty;
82+
symlinkRelativePath=Binaries.GetExeName(symlinkRelativePath);
8383

8484
using(vartestDir=TestArtifact.Create("symlink"))
8585
{
@@ -96,14 +96,14 @@ public void Run_framework_dependent_app_behind_symlink(/*string symlinkRelativeP
9696
}
9797
}
9898

99-
[Fact(Skip="Currently failing in OSX with\"No such file or directory\" when running Command.Create. "+
100-
"CI failingto use stat on symbolic links on Linux (permission denied).")]
101-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilegeonWindows, so skip test.")]
99+
[Fact]
100+
[SkipOnPlatform(TestPlatforms.OSX,"Currently failingin OSX with\"No such file or directory\" when running Command.Create. "+
101+
"CI failing to use statonsymbolic links on Linux (permission denied).")]
102102
publicvoidRun_framework_dependent_app_with_runtime_behind_symlink()
103103
{
104104
using(vartestDir=TestArtifact.Create("symlink"))
105105
{
106-
vardotnetSymlink=Path.Combine(testDir.Location,"dotnet");
106+
vardotnetSymlink=Path.Combine(testDir.Location,Binaries.GetExeName("dotnet"));
107107

108108
usingvarsymlink=newSymLink(dotnetSymlink,TestContext.BuiltDotNet.BinPath);
109109
Command.Create(sharedTestState.FrameworkDependentApp.AppExe)
@@ -117,7 +117,6 @@ public void Run_framework_dependent_app_with_runtime_behind_symlink()
117117
}
118118

119119
[Fact]
120-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilege on Windows, so skip test.")]
121120
publicvoidPut_app_directory_behind_symlink()
122121
{
123122
varapp=sharedTestState.SelfContainedApp.Copy();
@@ -138,7 +137,6 @@ public void Put_app_directory_behind_symlink()
138137
}
139138

140139
[Fact]
141-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilege on Windows, so skip test.")]
142140
publicvoidPut_dotnet_behind_symlink()
143141
{
144142
using(vartestDir=TestArtifact.Create("symlink"))
@@ -156,7 +154,6 @@ public void Put_dotnet_behind_symlink()
156154
}
157155

158156
[Fact]
159-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilege on Windows, so skip test.")]
160157
publicvoidPut_app_directory_behind_symlink_and_use_dotnet()
161158
{
162159
varapp=sharedTestState.SelfContainedApp.Copy();
@@ -177,7 +174,6 @@ public void Put_app_directory_behind_symlink_and_use_dotnet()
177174
}
178175

179176
[Fact]
180-
[SkipOnPlatform(TestPlatforms.Windows,"Creating symbolic links requires administrative privilege on Windows, so skip test.")]
181177
publicvoidPut_satellite_assembly_behind_symlink()
182178
{
183179
varapp=sharedTestState.LocalizedApp.Copy();

‎src/installer/tests/Microsoft.NET.HostModel.Tests/Bundle/BundlerConsistencyTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public BundlerConsistencyTests(SharedTestState fixture)
2323
sharedTestState=fixture;
2424
}
2525

26-
privatestaticstringBundlerHostName=Binaries.GetExeFileNameForCurrentPlatform(SharedTestState.AppName);
26+
privatestaticstringBundlerHostName=Binaries.GetExeName(SharedTestState.AppName);
2727
privateBundlerCreateBundlerInstance(BundleOptionsbundleOptions=BundleOptions.None,Versionversion=null,boolmacosCodesign=true)
2828
=>newBundler(BundlerHostName,sharedTestState.App.GetUniqueSubdirectory("bundle"),bundleOptions,targetFrameworkVersion:version,macosCodesign:macosCodesign);
2929

‎src/installer/tests/TestUtils/Binaries.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Microsoft.DotNet.CoreSetup.Test
1515
{
1616
publicstaticclassBinaries
1717
{
18-
publicstaticstringGetExeFileNameForCurrentPlatform(stringexeName)=>
18+
publicstaticstringGetExeName(stringexeName)=>
1919
exeName+(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)?".exe":string.Empty);
2020

2121
publicstatic(string,string)GetSharedLibraryPrefixSuffix()
@@ -37,7 +37,7 @@ public static string GetSharedLibraryFileNameForCurrentPlatform(string libraryNa
3737

3838
publicstaticclassAppHost
3939
{
40-
publicstaticstringFileName=GetExeFileNameForCurrentPlatform("apphost");
40+
publicstaticstringFileName=GetExeName("apphost");
4141
publicstaticstringFilePath=Path.Combine(RepoDirectoriesProvider.Default.HostArtifacts,FileName);
4242
}
4343

@@ -52,7 +52,7 @@ public static class CoreClr
5252

5353
publicstaticclassDotNet
5454
{
55-
publicstaticstringFileName=GetExeFileNameForCurrentPlatform("dotnet");
55+
publicstaticstringFileName=GetExeName("dotnet");
5656
publicstaticstringFilePath=Path.Combine(RepoDirectoriesProvider.Default.HostArtifacts,FileName);
5757
}
5858

@@ -84,7 +84,7 @@ public static class NetHost
8484

8585
publicstaticclassSingleFileHost
8686
{
87-
publicstaticstringFileName=GetExeFileNameForCurrentPlatform("singlefilehost");
87+
publicstaticstringFileName=GetExeName("singlefilehost");
8888
publicstaticstringFilePath=Path.Combine(RepoDirectoriesProvider.Default.HostArtifacts,FileName);
8989
}
9090

‎src/installer/tests/TestUtils/SingleFileTestApp.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public string Bundle(BundleOptions options, out Manifest manifest, Version? bund
9292
{
9393
stringbundleDirectory=GetUniqueSubdirectory("bundle");
9494
varbundler=newBundler(
95-
Binaries.GetExeFileNameForCurrentPlatform(AppName),
95+
Binaries.GetExeName(AppName),
9696
bundleDirectory,
9797
options,
9898
targetFrameworkVersion:bundleVersion,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp