Skip to content

Commit 050ac05

Browse files
authored
[automated] Merge branch 'release/10.0.1xx' => 'main' (#50730)
2 parents 626e7bc + af12112 commit 050ac05

File tree

200 files changed

+2003
-1489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+2003
-1489
lines changed

Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@
9696
<!-- Include SourcePackage.editorconfig in all source packages. -->
9797
<Target Name="_AddEditorConfigToSourcePackage">
9898
<ItemGroup>
99-
<TfmSpecificPackageFile Include="$(MSBuildThisFileDirectory)eng\SourcePackage.editorconfig" PackagePath="contentFiles/cs/$(TargetFramework)/.editorconfig" Condition="'$(TargetFrameworkIdentifier)' != '.NETStandard'" />
99+
<TfmSpecificPackageFile Include="$(MSBuildThisFileDirectory)eng\SourcePackage.editorconfig" PackagePath="contentFiles/cs/$(TargetFramework)/.editorconfig" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
100100
<TfmSpecificPackageFile Include="$(MSBuildThisFileDirectory)eng\SourcePackage.netstandard.editorconfig" PackagePath="contentFiles/cs/$(TargetFramework)/.editorconfig" Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'" />
101+
<TfmSpecificPackageFile Include="$(MSBuildThisFileDirectory)eng\SourcePackage.netframework.editorconfig" PackagePath="contentFiles/cs/$(TargetFramework)/.editorconfig" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
101102
</ItemGroup>
102103
</Target>
103104

Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsVersion)" />
6060
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsoleVersion)" />
6161
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="$(MicrosoftExtensionsObjectPoolPackageVersion)" />
62-
<PackageVersion Include="Microsoft.Extensions.Configuration.Ini" Version="$(MicrosoftExtensionsConfigurationIniVersion)" />
6362
<PackageVersion Include="Microsoft.FSharp.Compiler" Version="$(MicrosoftFSharpCompilerPackageVersion)" />
6463
<PackageVersion Include="Microsoft.Net.Compilers.Toolset.Framework" Version="$(MicrosoftNetCompilersToolsetFrameworkPackageVersion)" />
6564
<PackageVersion Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Remove the line below if you want to inherit .editorconfig settings from higher directories
2+
root = true
3+
4+
# C# files
5+
[*.cs]
6+
7+
# We don't want any analyzer diagnostics to be reported for people consuming this as a source package.
8+
dotnet_analyzer_diagnostic.severity = none
9+
10+
generated_code = true
11+
12+
# The above configurations don't apply to compiler warnings. Requiring all params to be documented
13+
# is not something we require for this project, so suppressing it directly here.
14+
dotnet_diagnostic.CS1573.severity = none
15+
16+
# As above, we need to specifically disable compiler warnings that we don't want to break downstream
17+
# builds
18+
dotnet_diagnostic.IDE0005.severity = none
19+
20+
# Disable nullability checks when targeting .NET Framework
21+
dotnet_diagnostic.CS8604.severity = none

src/BuiltInTools/dotnet-watch/HotReload/AppModels/HotReloadAppModel.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ protected static string GetInjectedAssemblyPath(string targetFramework, string a
1616

1717
public static string GetStartupHookPath(ProjectGraphNode project)
1818
{
19-
var hookTargetFramework = project.GetTargetFramework() switch
20-
{
21-
// Note: Hot Reload is only supported on net6.0+
22-
"net6.0" or "net7.0" or "net8.0" or "net9.0" => "net6.0",
23-
_ => "net10.0",
24-
};
25-
19+
var hookTargetFramework = project.GetTargetFrameworkVersion() is { Major: >= 10 } ? "net10.0" : "net6.0";
2620
return GetInjectedAssemblyPath(hookTargetFramework, "Microsoft.Extensions.DotNetDeltaApplier");
2721
}
2822

src/Cli/Microsoft.TemplateEngine.Cli/Components.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public static class Components
1515
(typeof(IPostActionProcessor), new InstructionDisplayPostActionProcessor()),
1616
(typeof(IPostActionProcessor), new ProcessStartPostActionProcessor()),
1717
(typeof(IPostActionProcessor), new AddJsonPropertyPostActionProcessor()),
18-
(typeof(IPostActionProcessor), new CreateOrUpdateDotnetConfigPostActionProcessor()),
1918
};
2019
}
2120
}

src/Cli/Microsoft.TemplateEngine.Cli/LocalizableStrings.Designer.cs

Lines changed: 0 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/Microsoft.TemplateEngine.Cli/LocalizableStrings.resx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -953,23 +953,4 @@ The header is followed by the list of parameters and their errors (might be seve
953953
<data name="PostAction_ModifyJson_Verbose_AttemptingToFindJsonFile" xml:space="preserve">
954954
<value>Attempting to find json file '{0}' in '{1}'</value>
955955
</data>
956-
<data name="PostAction_DotnetConfig_Error_ArgumentNotConfigured" xml:space="preserve">
957-
<value>Post action argument '{0}' is mandatory, but not configured.</value>
958-
</data>
959-
<data name="PostAction_CreateDotnetConfig_Succeeded" xml:space="preserve">
960-
<value>Successfully created 'dotnet.config' file.</value>
961-
<comment>{Locked="dotnet.config"}</comment>
962-
</data>
963-
<data name="PostAction_CreateDotnetConfig_CreatedNewSection" xml:space="preserve">
964-
<value>Created new section in 'dotnet.config' file</value>
965-
<comment>{Locked="dotnet.config"}</comment>
966-
</data>
967-
<data name="PostAction_CreateDotnetConfig_ValueAlreadyExist" xml:space="preserve">
968-
<value>The required value in 'dotnet.config' is already set.</value>
969-
<comment>{Locked="dotnet.config"}</comment>
970-
</data>
971-
<data name="PostAction_CreateDotnetConfig_ManuallyUpdate" xml:space="preserve">
972-
<value>Updating existing values in 'dotnet.config' is not yet supported. Please, manually update 'dotnet.config' to have '{0}' under section '{1}'.</value>
973-
<comment>{Locked="dotnet.config"}</comment>
974-
</data>
975-
</root>
956+
</root>

src/Cli/Microsoft.TemplateEngine.Cli/Microsoft.TemplateEngine.Cli.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<PackageReference Include="Microsoft.TemplateEngine.Edge" />
1717
<PackageReference Include="Microsoft.TemplateSearch.Common" />
1818
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" />
2019
<PackageReference Include="Wcwidth.Sources" ExcludeAssets="all" GeneratePathProperty="true" />
2120
<PackageReference Include="System.CommandLine" />
2221
</ItemGroup>

src/Cli/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddJsonPropertyPostActionProcessor.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ internal class AddJsonPropertyPostActionProcessor : PostActionProcessorBase
1919
private const string ParentPropertyPathArgument = "parentPropertyPath";
2020
private const string NewJsonPropertyNameArgument = "newJsonPropertyName";
2121
private const string NewJsonPropertyValueArgument = "newJsonPropertyValue";
22+
private const string DetectRepoRootForFileCreation = "detectRepositoryRootForFileCreation";
2223

2324
private static readonly JsonSerializerOptions SerializerOptions = new()
2425
{
@@ -36,6 +37,43 @@ internal class AddJsonPropertyPostActionProcessor : PostActionProcessorBase
3637

3738
internal static Guid ActionProcessorId { get; } = new Guid("695A3659-EB40-4FF5-A6A6-C9C4E629FCB0");
3839

40+
internal static string GetRootDirectory(IPhysicalFileSystem fileSystem, string outputBasePath)
41+
{
42+
string? currentDirectory = outputBasePath;
43+
string? directoryWithSln = null;
44+
while (currentDirectory is not null)
45+
{
46+
if (fileSystem.FileExists(Path.Combine(currentDirectory, "global.json")) ||
47+
fileSystem.FileExists(Path.Combine(currentDirectory, ".git")) ||
48+
fileSystem.DirectoryExists(Path.Combine(currentDirectory, ".git")))
49+
{
50+
// If we found global.json or .git, we immediately return the directory as the repo root.
51+
// We won't go up any further.
52+
return currentDirectory;
53+
}
54+
55+
// DirectoryExists here should always be true in practice, but for the way tests are mocking the file system, it's not.
56+
// The check was added to prevent test failures similar to:
57+
// System.IO.DirectoryNotFoundException : Could not find a part of the path '/Users/runner/work/1/s/artifacts/bin/Microsoft.TemplateEngine.Cli.UnitTests/Release/sandbox'.
58+
// We get to this exception when doing `EnumerateFiles` on a directory that was virtually created in memory (not really available on disk).
59+
// EnumerateFiles tries to access the physical file system, which then fails.
60+
if (fileSystem.DirectoryExists(currentDirectory) &&
61+
(fileSystem.EnumerateFiles(currentDirectory, "*.sln", SearchOption.TopDirectoryOnly).Any() ||
62+
fileSystem.EnumerateFiles(currentDirectory, "*.slnx", SearchOption.TopDirectoryOnly).Any()))
63+
{
64+
directoryWithSln = currentDirectory;
65+
}
66+
67+
currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
68+
}
69+
70+
// If we reach here, that means we didn't find .git or global.json.
71+
// So, we return the directory where we found a .sln/.slnx file, if any.
72+
// Note that when we keep track of directoryWithSln, we keep updating it from sln/slnx from parent directories, if found.
73+
// This means that if there are multiple .sln/.slnx files in the parent directories, we will return the top-most one.
74+
return directoryWithSln ?? outputBasePath;
75+
}
76+
3977
protected override bool ProcessInternal(
4078
IEngineEnvironmentSettings environment,
4179
IPostAction action,
@@ -65,7 +103,13 @@ protected override bool ProcessInternal(
65103
return false;
66104
}
67105

68-
string newJsonFilePath = Path.Combine(outputBasePath, jsonFileName);
106+
if (!bool.TryParse(action.Args.GetValueOrDefault(DetectRepoRootForFileCreation, "false"), out bool detectRepoRoot))
107+
{
108+
Reporter.Error.WriteLine(string.Format(LocalizableStrings.PostAction_ModifyJson_Error_ArgumentNotBoolean, DetectRepoRootForFileCreation));
109+
return false;
110+
}
111+
112+
string newJsonFilePath = Path.Combine(detectRepoRoot ? GetRootDirectory(environment.Host.FileSystem, outputBasePath) : outputBasePath, jsonFileName);
69113
environment.Host.FileSystem.WriteAllText(newJsonFilePath, "{}");
70114
jsonFiles = new List<string> { newJsonFilePath };
71115
}

src/Cli/Microsoft.TemplateEngine.Cli/PostActionProcessors/CreateOrUpdateDotnetConfigPostActionProcessor.cs

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)