Skip to content

Commit 069d370

Browse files
committed
Merge branch 'main' into darc-main-7628065e-94f2-4f11-a6d5-3ab587167c53
2 parents 803ba88 + 99c8904 commit 069d370

File tree

8 files changed

+176
-14
lines changed

8 files changed

+176
-14
lines changed

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,13 @@
553553
<Uri>https://github.com/dotnet/arcade-services</Uri>
554554
<Sha>448a29d2d2e4e27303f728202602708ed45838f5</Sha>
555555
</Dependency>
556-
<Dependency Name="Microsoft.Testing.Platform" Version="1.8.0-preview.25372.9">
556+
<Dependency Name="Microsoft.Testing.Platform" Version="1.8.0-preview.25373.2">
557557
<Uri>https://github.com/microsoft/testfx</Uri>
558-
<Sha>171ae1e9b5fb101f8c47ab2e8dff0fbb250d3bf9</Sha>
558+
<Sha>7d305158d16bc674ed85e897b3e5b842867877d8</Sha>
559559
</Dependency>
560-
<Dependency Name="MSTest" Version="3.10.0-preview.25372.9">
560+
<Dependency Name="MSTest" Version="3.10.0-preview.25373.2">
561561
<Uri>https://github.com/microsoft/testfx</Uri>
562-
<Sha>171ae1e9b5fb101f8c47ab2e8dff0fbb250d3bf9</Sha>
562+
<Sha>7d305158d16bc674ed85e897b3e5b842867877d8</Sha>
563563
</Dependency>
564564
<Dependency Name="Microsoft.Extensions.Configuration.Ini" Version="10.0.0-preview.7.25367.101">
565565
<Uri>https://github.com/dotnet/dotnet</Uri>

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<UsingToolVSSDK>true</UsingToolVSSDK>
3131
<FlagNetStandard1XDependencies Condition="'$(DotNetBuildSourceOnly)' == 'true'">true</FlagNetStandard1XDependencies>
3232
<!-- This property is only used in the dotnet test integration tests. -->
33-
<MicrosoftTestingPlatformVersion>1.8.0-preview.25372.9</MicrosoftTestingPlatformVersion>
33+
<MicrosoftTestingPlatformVersion>1.8.0-preview.25373.2</MicrosoftTestingPlatformVersion>
3434
</PropertyGroup>
3535
<PropertyGroup Label="Servicing version information">
3636
<VersionFeature21>30</VersionFeature21>
@@ -316,7 +316,7 @@
316316
<AwesomeAssertionsVersion>8.0.2</AwesomeAssertionsVersion>
317317
<AwesomeAssertionsJsonVersion>8.0.0</AwesomeAssertionsJsonVersion>
318318
<MoqPackageVersion>4.18.4</MoqPackageVersion>
319-
<MSTestVersion>3.10.0-preview.25372.9</MSTestVersion>
319+
<MSTestVersion>3.10.0-preview.25373.2</MSTestVersion>
320320
<XunitCombinatorialVersion>1.3.2</XunitCombinatorialVersion>
321321
<MicrosoftDotNetInstallerWindowsSecurityTestDataPackageVersion>8.0.0-beta.23607.1</MicrosoftDotNetInstallerWindowsSecurityTestDataPackageVersion>
322322
<BenchmarkDotNetPackageVersion>0.14.0</BenchmarkDotNetPackageVersion>

src/Cli/dotnet/Commands/New/PostActions/DotnetSlnPostActionProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ internal class DotnetSlnPostActionProcessor(Func<string, IReadOnlyList<string>,
2020

2121
internal static IReadOnlyList<string> FindSolutionFilesAtOrAbovePath(IPhysicalFileSystem fileSystem, string outputBasePath)
2222
{
23-
return FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.sln")
24-
?? FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.slnx");
23+
var slnFiles = FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.sln");
24+
return slnFiles.Count > 0 ? slnFiles : FileFindHelpers.FindFilesAtOrAbovePath(fileSystem, outputBasePath, "*.slnx");
2525
}
2626

2727
// The project files to add are a subset of the primary outputs, specifically the primary outputs indicated by the primaryOutputIndexes post action argument (semicolon separated)

src/Cli/dotnet/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ internal static int ProcessArgs(string[] args, TimeSpan startupTime)
286286
{
287287
// If we didn't match any built-in commands, and a C# file path is the first argument,
288288
// parse as `dotnet run --file file.cs ..rest_of_args` instead.
289-
if (parseResult.CommandResult.Command is RootCommand
290-
&& parseResult.GetValue(Parser.DotnetSubCommand) is { } unmatchedCommandOrFile
289+
if (parseResult.GetValue(Parser.DotnetSubCommand) is { } unmatchedCommandOrFile
291290
&& VirtualProjectBuildingCommand.IsValidEntryPointPath(unmatchedCommandOrFile))
292291
{
293292
List<string> otherTokens = new(parseResult.Tokens.Count - 1);

src/WebSdk/Web/Targets/Sdk.Server.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,10 @@ Copyright (c) .NET Foundation. All rights reserved.
5454
Trim="true" />
5555
</ItemGroup>
5656

57+
<Target Name="WarnOnDeprecatedAssets"
58+
BeforeTargets="CoreCompile"
59+
Condition="'$(IncludeOpenAPIAnalyzers)' == 'true'">
60+
<Warning Code="ASPDEPR007" Text="The IncludeOpenAPIAnalyzers property and its associated MVC API analyzers are deprecated and will be removed in a future release." HelpLink="https://aka.ms/aspnet/deprecate/007" />
61+
</Target>
62+
5763
</Project>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
#nullable disable
5+
6+
namespace Microsoft.NET.Sdk.Web.Tests;
7+
8+
public class DeprecationTests(ITestOutputHelper log) : SdkTest(log)
9+
{
10+
[Fact]
11+
public void It_does_not_show_deprecation_warning_when_IncludeOpenAPIAnalyzers_is_not_set()
12+
{
13+
var testProject = new TestProject()
14+
{
15+
Name = "WebAppWithoutOpenAPIAnalyzers",
16+
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
17+
ProjectSdk = "Microsoft.NET.Sdk.Web"
18+
};
19+
20+
var testAsset = _testAssetsManager.CreateTestProject(testProject);
21+
22+
var buildCommand = new BuildCommand(testAsset);
23+
buildCommand
24+
.Execute()
25+
.Should()
26+
.Pass()
27+
.And
28+
.NotHaveStdOutContaining("ASPDEPR007")
29+
.And
30+
.NotHaveStdOutContaining("IncludeOpenAPIAnalyzers");
31+
}
32+
33+
[Fact]
34+
public void It_does_not_show_deprecation_warning_when_IncludeOpenAPIAnalyzers_is_false()
35+
{
36+
var testProject = new TestProject()
37+
{
38+
Name = "WebAppWithOpenAPIAnalyzersFalse",
39+
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
40+
ProjectSdk = "Microsoft.NET.Sdk.Web"
41+
};
42+
43+
testProject.AdditionalProperties["IncludeOpenAPIAnalyzers"] = "false";
44+
45+
var testAsset = _testAssetsManager.CreateTestProject(testProject);
46+
47+
var buildCommand = new BuildCommand(testAsset);
48+
buildCommand
49+
.Execute()
50+
.Should()
51+
.Pass()
52+
.And
53+
.NotHaveStdOutContaining("ASPDEPR007");
54+
}
55+
56+
[Theory]
57+
[InlineData(ToolsetInfo.CurrentTargetFramework)]
58+
[InlineData("net8.0")]
59+
[InlineData("net9.0")]
60+
public void It_shows_deprecation_warning_across_target_frameworks(string targetFramework)
61+
{
62+
var testProject = new TestProject()
63+
{
64+
Name = $"WebApp_{targetFramework.Replace(".", "_")}",
65+
TargetFrameworks = targetFramework,
66+
ProjectSdk = "Microsoft.NET.Sdk.Web"
67+
};
68+
69+
testProject.AdditionalProperties["IncludeOpenAPIAnalyzers"] = "true";
70+
71+
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
72+
73+
var buildCommand = new BuildCommand(testAsset);
74+
buildCommand
75+
.Execute()
76+
.Should()
77+
.Pass()
78+
.And
79+
.HaveStdOutContaining("ASPDEPR007");
80+
}
81+
}

test/dotnet.Tests/CommandTests/New/DotnetSlnPostActionTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,38 @@ public void AddProjectToSolutionPostActionFindSolutionFileAtOutputPath()
2929
Assert.Equal(solutionFileFullPath, solutionFiles[0]);
3030
}
3131

32+
[PlatformSpecificFact(TestPlatforms.Any & ~TestPlatforms.Linux)] // https://github.com/dotnet/sdk/issues/49923
33+
public void AddProjectToSolutionPostActionFindSlnxFileAtOutputPath()
34+
{
35+
string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
36+
_engineEnvironmentSettings.Host.VirtualizeDirectory(targetBasePath);
37+
EnsureParentDirectoriesExist(targetBasePath);
38+
39+
string solutionFileFullPath = Path.Combine(targetBasePath, "MySln.slnx");
40+
_engineEnvironmentSettings.Host.FileSystem.WriteAllText(solutionFileFullPath, string.Empty);
41+
42+
IReadOnlyList<string> solutionFiles = DotnetSlnPostActionProcessor.FindSolutionFilesAtOrAbovePath(_engineEnvironmentSettings.Host.FileSystem, targetBasePath);
43+
Assert.Single(solutionFiles);
44+
Assert.Equal(solutionFileFullPath, solutionFiles[0]);
45+
}
46+
47+
[Fact(DisplayName = nameof(AddProjectToSolutionPostActionPrefersSlnOverSlnx))]
48+
public void AddProjectToSolutionPostActionPrefersSlnOverSlnx()
49+
{
50+
string targetBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath();
51+
_engineEnvironmentSettings.Host.VirtualizeDirectory(targetBasePath);
52+
EnsureParentDirectoriesExist(targetBasePath);
53+
54+
string slnFileFullPath = Path.Combine(targetBasePath, "MySln.sln");
55+
string slnxFileFullPath = Path.Combine(targetBasePath, "MySln.slnx");
56+
_engineEnvironmentSettings.Host.FileSystem.WriteAllText(slnFileFullPath, string.Empty);
57+
_engineEnvironmentSettings.Host.FileSystem.WriteAllText(slnxFileFullPath, string.Empty);
58+
59+
IReadOnlyList<string> solutionFiles = DotnetSlnPostActionProcessor.FindSolutionFilesAtOrAbovePath(_engineEnvironmentSettings.Host.FileSystem, targetBasePath);
60+
Assert.Single(solutionFiles);
61+
Assert.Equal(slnFileFullPath, solutionFiles[0]);
62+
}
63+
3264
[Fact(DisplayName = nameof(AddProjectToSolutionPostActionFindsOneProjectToAdd))]
3365
public void AddProjectToSolutionPostActionFindsOneProjectToAdd()
3466
{
@@ -312,6 +344,20 @@ public void AddProjectToSolutionFailsWhenSolutionFolderAndInRootSpecified()
312344
Assert.False(result);
313345
}
314346

347+
private void EnsureParentDirectoriesExist(string targetBasePath)
348+
{
349+
// Ensure parent directories exist to avoid DirectoryNotFoundException during traversal
350+
string? currentPath = targetBasePath;
351+
while (!string.IsNullOrEmpty(currentPath) && currentPath != Path.GetPathRoot(currentPath))
352+
{
353+
if (!_engineEnvironmentSettings.Host.FileSystem.DirectoryExists(currentPath))
354+
{
355+
_engineEnvironmentSettings.Host.FileSystem.CreateDirectory(currentPath);
356+
}
357+
currentPath = Path.GetDirectoryName(currentPath);
358+
}
359+
}
360+
315361
private class MockAddProjectToSolutionCallback
316362
{
317363
public string? Solution { get; private set; }

test/dotnet.Tests/CommandTests/Run/RunFileTests.cs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,34 @@ Hello from Program
142142
{s_program}
143143
""");
144144

145+
string expectedOutput = """
146+
Hello from Program
147+
Release config
148+
""";
149+
145150
new DotnetCommand(Log, "Program.cs")
146151
.WithWorkingDirectory(testInstance.Path)
147152
.Execute()
148153
.Should().Pass()
149-
.And.HaveStdOut("""
150-
Hello from Program
151-
Release config
152-
""");
154+
.And.HaveStdOut(expectedOutput);
155+
156+
new DotnetCommand(Log, "./Program.cs")
157+
.WithWorkingDirectory(testInstance.Path)
158+
.Execute()
159+
.Should().Pass()
160+
.And.HaveStdOut(expectedOutput);
161+
162+
new DotnetCommand(Log, $".{Path.DirectorySeparatorChar}Program.cs")
163+
.WithWorkingDirectory(testInstance.Path)
164+
.Execute()
165+
.Should().Pass()
166+
.And.HaveStdOut(expectedOutput);
167+
168+
new DotnetCommand(Log, Path.Join(testInstance.Path, "Program.cs"))
169+
.WithWorkingDirectory(testInstance.Path)
170+
.Execute()
171+
.Should().Pass()
172+
.And.HaveStdOut(expectedOutput);
153173

154174
new DotnetCommand(Log, "Program.cs", "-c", "Debug")
155175
.WithWorkingDirectory(testInstance.Path)
@@ -168,6 +188,16 @@ Hello from Program
168188
Hello from Program
169189
Release config
170190
""");
191+
192+
new DotnetCommand(Log, "Program.cs", "build")
193+
.WithWorkingDirectory(testInstance.Path)
194+
.Execute()
195+
.Should().Pass()
196+
.And.HaveStdOut("""
197+
echo args:build
198+
Hello from Program
199+
Release config
200+
""");
171201
}
172202

173203
/// <summary>

0 commit comments

Comments
 (0)