|
1 | | -using System; |
| 1 | +using CSharpRepl.Services.Roslyn.References; |
| 2 | +using System; |
2 | 3 | using System.Collections.Generic; |
3 | 4 | using System.IO; |
4 | 5 | using System.IO.Abstractions.TestingHelpers; |
5 | | -using CSharpRepl.Services.Roslyn.References; |
| 6 | +using System.Runtime.InteropServices; |
6 | 7 | using Xunit; |
7 | 8 |
|
8 | 9 | namespace CSharpRepl.Tests; |
@@ -41,6 +42,82 @@ public void GetSharedFrameworkConfiguration_Net5GlobalInstallation_IsLocated() |
41 | 42 | ); |
42 | 43 | } |
43 | 44 |
|
| 45 | + [Fact] |
| 46 | + public void GetSharedFrameworkConfiguration_Net10Installation_IsLocated() |
| 47 | + { |
| 48 | + var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> |
| 49 | + { |
| 50 | + { @"/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref/9.0.0/data/FrameworkList.xml", string.Empty }, |
| 51 | + { @"/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref/9.0.0/ref/net9.0/Microsoft.CSharp.dll", string.Empty }, |
| 52 | + { @"/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref/10.0.0/data/FrameworkList.xml", string.Empty }, |
| 53 | + { @"/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref/10.0.0/ref/net10.0/Microsoft.CSharp.dll", string.Empty }, |
| 54 | + { @"/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref/10.0.1/data/FrameworkList.xml", string.Empty }, |
| 55 | + { @"/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref/10.0.1/ref/net10.0/Microsoft.CSharp.dll", string.Empty }, |
| 56 | + |
| 57 | + { @"/Program Files/dotnet/shared/Microsoft.NETCore.App/9.0.2/Microsoft.CSharp.dll", string.Empty }, |
| 58 | + { @"/Program Files/dotnet/shared/Microsoft.NETCore.App/10.0.0/Microsoft.CSharp.dll", string.Empty }, |
| 59 | + { @"/Program Files/dotnet/shared/Microsoft.NETCore.App/10.0.1/Microsoft.CSharp.dll", string.Empty } |
| 60 | + }); |
| 61 | + |
| 62 | + var locator = new DotNetInstallationLocator( |
| 63 | + logger: new TestTraceLogger(), io: fileSystem, |
| 64 | + dotnetRuntimePath: @"/Program Files/dotnet/", |
| 65 | + userProfilePath: @"/Users/bob/" |
| 66 | + ); |
| 67 | + |
| 68 | + var (refPath, implPath) = locator.FindInstallation("Microsoft.NETCore.App", new Version(10, 0, 1)); |
| 69 | + |
| 70 | + Assert.Equal( |
| 71 | + CrossPlatform(@"/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref/10.0.1/ref/net10.0"), |
| 72 | + CrossPlatform(refPath) |
| 73 | + ); |
| 74 | + Assert.Equal( |
| 75 | + CrossPlatform(@"/Program Files/dotnet/shared/Microsoft.NETCore.App/10.0.1"), |
| 76 | + CrossPlatform(implPath) |
| 77 | + ); |
| 78 | + } |
| 79 | + |
| 80 | + [Fact] |
| 81 | + public void GetSharedFrameworkConfiguration_Net10UsesNuGetWhenNotInstalledGlobally() |
| 82 | + { |
| 83 | + string platform = OperatingSystem.IsWindows() ? "win" |
| 84 | + : OperatingSystem.IsLinux() ? "linux" |
| 85 | + : OperatingSystem.IsMacOS() ? "osx" |
| 86 | + : null; |
| 87 | + |
| 88 | + var architecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(); |
| 89 | + |
| 90 | + var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> |
| 91 | + { |
| 92 | + // existing global runtimes but none for net10 |
| 93 | + { @"/Program Files/dotnet/shared/Microsoft.NETCore.App/9.0.0/Microsoft.CSharp.dll", string.Empty }, |
| 94 | + |
| 95 | + // reference assemblies in .nuget installation |
| 96 | + { @"/Users/bob/.nuget/packages/microsoft.netcore.app.ref/10.0.0/data/FrameworkList.xml", string.Empty }, |
| 97 | + { @"/Users/bob/.nuget/packages/microsoft.netcore.app.ref/10.0.0/ref/net10.0/Microsoft.CSharp.dll", string.Empty }, |
| 98 | + |
| 99 | + // implementation assemblies in .nuget installation |
| 100 | + { @$"/Users/bob/.nuget/packages/microsoft.netcore.app.runtime.{platform}-{architecture}/10.0.0/runtimes/{platform}-{architecture}/lib/net10.0/Microsoft.CSharp.dll", string.Empty }, |
| 101 | + }); |
| 102 | + |
| 103 | + var locator = new DotNetInstallationLocator( |
| 104 | + logger: new TestTraceLogger(), io: fileSystem, |
| 105 | + dotnetRuntimePath: @"/Program Files/dotnet/", |
| 106 | + userProfilePath: @"/Users/bob/" |
| 107 | + ); |
| 108 | + |
| 109 | + var (refPath, implPath) = locator.FindInstallation("Microsoft.NETCore.App", new Version(10, 0, 0)); |
| 110 | + |
| 111 | + Assert.Equal( |
| 112 | + CrossPlatform(@"/Users/bob/.nuget/packages/microsoft.netcore.app.ref/10.0.0/ref/net10.0"), |
| 113 | + CrossPlatform(refPath) |
| 114 | + ); |
| 115 | + Assert.Equal( |
| 116 | + CrossPlatform(@$"/Users/bob/.nuget/packages/microsoft.netcore.app.runtime.{platform}-{architecture}/10.0.0/runtimes/{platform}-{architecture}/lib/net10.0"), |
| 117 | + CrossPlatform(implPath) |
| 118 | + ); |
| 119 | + } |
| 120 | + |
44 | 121 | [Fact] |
45 | 122 | public void GetSharedFrameworkConfiguration_NoGlobalNet5ReferenceAssemblies_UsesNuGetInstallation() |
46 | 123 | { |
|
0 commit comments