|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
4 | 4 | using Microsoft.DotNet.Tools.Test.Utilities;
|
| 5 | +using System.Runtime.InteropServices; |
5 | 6 |
|
6 | 7 | namespace Microsoft.DotNet.Restore.Test
|
7 | 8 | {
|
@@ -167,6 +168,44 @@ public void ItAcceptsArgumentsAfterProperties()
|
167 | 168 | .Should()
|
168 | 169 | .Pass();
|
169 | 170 | }
|
| 171 | + |
| 172 | + /// <summary> |
| 173 | + /// Tests for RID-specific restore options: -r/--runtime, --os, and -a/--arch |
| 174 | + /// </summary> |
| 175 | + [Theory] |
| 176 | + [InlineData("-r", "linux-x64")] |
| 177 | + [InlineData("--runtime", "win-x64")] |
| 178 | + [InlineData("--os", "linux")] |
| 179 | + [InlineData("-a", "arm64")] |
| 180 | + [InlineData("--arch", "x64")] |
| 181 | + [InlineData("--os", "linux", "-a", "arm64")] |
| 182 | + public void ItRestoresWithRidSpecificOptions(params string[] ridOptions) |
| 183 | + { |
| 184 | + // Skip test for #24251 |
| 185 | + var testProject = new TestProject() |
| 186 | + { |
| 187 | + Name = "RestoreWithRidOptions", |
| 188 | + TargetFrameworks = ToolsetInfo.CurrentTargetFramework, |
| 189 | + }; |
| 190 | + |
| 191 | + testProject.PackageReferences.Add(new TestPackageReference("Newtonsoft.Json", ToolsetInfo.GetNewtonsoftJsonPackageVersion())); |
| 192 | + |
| 193 | + var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: string.Join("_", ridOptions)); |
| 194 | + |
| 195 | + var rootPath = Path.Combine(testAsset.TestRoot, testProject.Name); |
| 196 | + |
| 197 | + // Create the command with the RID-specific options |
| 198 | + var restoreCommand = new DotnetRestoreCommand(Log) |
| 199 | + .WithWorkingDirectory(rootPath) |
| 200 | + .Execute(ridOptions); |
| 201 | + |
| 202 | + // Verify that the command runs successfully |
| 203 | + restoreCommand.Should().Pass(); |
| 204 | + |
| 205 | + // Verify that assets file was created |
| 206 | + var assetsFilePath = Path.Combine(rootPath, "obj", "project.assets.json"); |
| 207 | + File.Exists(assetsFilePath).Should().BeTrue(); |
| 208 | + } |
170 | 209 |
|
171 | 210 | private static string[] HandleStaticGraphEvaluation(bool useStaticGraphEvaluation, string[] args) =>
|
172 | 211 | useStaticGraphEvaluation ?
|
|
0 commit comments