Skip to content

Commit f36c2ec

Browse files
authored
Merge branch 'main' into darc-main-835cd6c5-a3a2-4816-bd44-a1a27df4212f
2 parents 56e452c + 836489f commit f36c2ec

Some content is hidden

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

41 files changed

+2183
-378
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<PackageVersion Include="Microsoft.Build.NuGetSdkResolver" Version="$(MicrosoftBuildNuGetSdkResolverPackageVersion)" />
1919
<PackageVersion Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
2020
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
21+
<PackageVersion Include="Microsoft.CodeAnalysis.BuildClient" Version="$(MicrosoftCodeAnalysisBuildClientVersion)" />
2122
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
2223
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
2324
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />

eng/Version.Details.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
<Uri>https://github.com/dotnet/dotnet</Uri>
9797
<Sha>1add0c55b8beeb1b1de4d81e362fad8978c4c8c8</Sha>
9898
</Dependency>
99+
<Dependency Name="Microsoft.CodeAnalysis.BuildClient" Version="5.0.0-2.25373.106">
100+
<Uri>https://github.com/dotnet/dotnet</Uri>
101+
<Sha>1add0c55b8beeb1b1de4d81e362fad8978c4c8c8</Sha>
102+
</Dependency>
99103
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="5.0.0-2.25373.106">
100104
<Uri>https://github.com/dotnet/dotnet</Uri>
101105
<Sha>1add0c55b8beeb1b1de4d81e362fad8978c4c8c8</Sha>

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
<MicrosoftNetCompilersToolsetVersion>5.0.0-2.25373.106</MicrosoftNetCompilersToolsetVersion>
219219
<MicrosoftNetCompilersToolsetFrameworkPackageVersion>5.0.0-2.25373.106</MicrosoftNetCompilersToolsetFrameworkPackageVersion>
220220
<MicrosoftCodeAnalysisPackageVersion>5.0.0-2.25373.106</MicrosoftCodeAnalysisPackageVersion>
221+
<MicrosoftCodeAnalysisBuildClientVersion>5.0.0-2.25373.106</MicrosoftCodeAnalysisBuildClientVersion>
221222
<MicrosoftCodeAnalysisCSharpPackageVersion>5.0.0-2.25373.106</MicrosoftCodeAnalysisCSharpPackageVersion>
222223
<MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>5.0.0-2.25373.106</MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>
223224
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>5.0.0-2.25373.106</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>

src/BuiltInTools/dotnet-watch/Browser/BrowserConnector.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,8 @@ public bool IsServerSupported(ProjectGraphNode projectNode, HotReloadAppModel ap
299299

300300
private LaunchSettingsProfile GetLaunchProfile(ProjectOptions projectOptions)
301301
{
302-
var projectDirectory = Path.GetDirectoryName(projectOptions.ProjectPath);
303-
Debug.Assert(projectDirectory != null);
304-
305302
return (projectOptions.NoLaunchProfile == true
306-
? null : LaunchSettingsProfile.ReadLaunchProfile(projectDirectory, projectOptions.LaunchProfileName, context.Reporter)) ?? new();
303+
? null : LaunchSettingsProfile.ReadLaunchProfile(projectOptions.ProjectPath, projectOptions.LaunchProfileName, context.Reporter)) ?? new();
307304
}
308305
}
309306
}

src/BuiltInTools/dotnet-watch/Process/LaunchSettingsProfile.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44

5+
using System.Diagnostics;
56
using System.Text.Json;
67
using System.Text.Json.Serialization;
8+
using Microsoft.DotNet.Cli.Commands;
9+
using Microsoft.DotNet.Cli.Commands.Run;
710

811
namespace Microsoft.DotNet.Watch
912
{
@@ -22,10 +25,30 @@ internal sealed class LaunchSettingsProfile
2225
public bool LaunchBrowser { get; init; }
2326
public string? LaunchUrl { get; init; }
2427

25-
internal static LaunchSettingsProfile? ReadLaunchProfile(string projectDirectory, string? launchProfileName, IReporter reporter)
28+
internal static LaunchSettingsProfile? ReadLaunchProfile(string projectPath, string? launchProfileName, IReporter reporter)
2629
{
27-
var launchSettingsPath = Path.Combine(projectDirectory, "Properties", "launchSettings.json");
28-
if (!File.Exists(launchSettingsPath))
30+
var projectDirectory = Path.GetDirectoryName(projectPath);
31+
Debug.Assert(projectDirectory != null);
32+
33+
var launchSettingsPath = CommonRunHelpers.GetPropertiesLaunchSettingsPath(projectDirectory, "Properties");
34+
bool hasLaunchSettings = File.Exists(launchSettingsPath);
35+
36+
var projectNameWithoutExtension = Path.GetFileNameWithoutExtension(projectPath);
37+
var runJsonPath = CommonRunHelpers.GetFlatLaunchSettingsPath(projectDirectory, projectNameWithoutExtension);
38+
bool hasRunJson = File.Exists(runJsonPath);
39+
40+
if (hasLaunchSettings)
41+
{
42+
if (hasRunJson)
43+
{
44+
reporter.Warn(string.Format(CliCommandStrings.RunCommandWarningRunJsonNotUsed, runJsonPath, launchSettingsPath));
45+
}
46+
}
47+
else if (hasRunJson)
48+
{
49+
launchSettingsPath = runJsonPath;
50+
}
51+
else
2952
{
3053
return null;
3154
}
@@ -39,7 +62,7 @@ internal sealed class LaunchSettingsProfile
3962
}
4063
catch (Exception ex)
4164
{
42-
reporter.Verbose($"Error reading launchSettings.json: {ex}.");
65+
reporter.Verbose($"Error reading '{launchSettingsPath}': {ex}.");
4366
return null;
4467
}
4568

src/Cli/Microsoft.DotNet.Cli.Utils/ArgumentEscaper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ private static IEnumerable<string> EscapeArgArrayForCmd(IEnumerable<string> argu
8686
return escapedArgs;
8787
}
8888

89-
public static string EscapeSingleArg(string arg)
89+
public static string EscapeSingleArg(string arg, Func<string, bool>? additionalShouldSurroundWithQuotes = null)
9090
{
9191
var sb = new StringBuilder();
9292

9393
var length = arg.Length;
94-
var needsQuotes = length == 0 || ShouldSurroundWithQuotes(arg);
94+
var needsQuotes = length == 0 || ShouldSurroundWithQuotes(arg) || additionalShouldSurroundWithQuotes?.Invoke(arg) == true;
9595
var isQuoted = needsQuotes || IsSurroundedWithQuotes(arg);
9696

9797
if (needsQuotes) sb.Append("\"");

src/Cli/Microsoft.DotNet.Cli.Utils/Product.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,32 @@
55

66
namespace Microsoft.DotNet.Cli.Utils;
77

8-
public class Product
8+
public static class Product
99
{
1010
public static string LongName => LocalizableStrings.DotNetSdkInfo;
11-
public static readonly string Version = GetProductVersion();
11+
public static readonly string Version;
12+
public static readonly string TargetFrameworkVersion;
1213

13-
private static string GetProductVersion()
14+
static Product()
1415
{
1516
DotnetVersionFile versionFile = DotnetFiles.VersionFileObject;
16-
return versionFile.BuildNumber ??
17+
Version = versionFile.BuildNumber ??
1718
System.Diagnostics.FileVersionInfo.GetVersionInfo(
1819
typeof(Product).GetTypeInfo().Assembly.Location)
1920
.ProductVersion ??
2021
string.Empty;
22+
23+
int firstDotIndex = Version.IndexOf('.');
24+
if (firstDotIndex >= 0)
25+
{
26+
int secondDotIndex = Version.IndexOf('.', firstDotIndex + 1);
27+
TargetFrameworkVersion = secondDotIndex >= 0
28+
? Version.Substring(0, secondDotIndex)
29+
: Version;
30+
}
31+
else
32+
{
33+
TargetFrameworkVersion = string.Empty;
34+
}
2135
}
2236
}

src/Cli/dotnet/Commands/CliCommandStrings.resx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ dotnet.config is a name don't translate.</comment>
692692
<value>Do not use arguments specified in launch profile to run the application.</value>
693693
</data>
694694
<data name="CommandOptionNoLaunchProfileDescription" xml:space="preserve">
695-
<value>Do not attempt to use launchSettings.json to configure the application.</value>
695+
<value>Do not attempt to use launchSettings.json or [app].run.json to configure the application.</value>
696+
<comment>{Locked="launchSettings.json"}{Locked=".run.json"}</comment>
696697
</data>
697698
<data name="CommandOptionProjectDescription" xml:space="preserve">
698699
<value>The path to the project file to run (defaults to the current directory if there is only one project).</value>
@@ -766,8 +767,8 @@ dotnet.config is a name don't translate.</comment>
766767
<value>Description</value>
767768
</data>
768769
<data name="DeserializationExceptionMessage" xml:space="preserve">
769-
<value>An error was encountered when reading launchSettings.json.
770-
{0}</value>
770+
<value>An error was encountered when reading '{0}': {1}</value>
771+
<comment>{0} is file path. {1} is exception message.</comment>
771772
</data>
772773
<data name="DetailDescription" xml:space="preserve">
773774
<value>Show detail result of the query.</value>
@@ -1610,9 +1611,13 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man
16101611
<comment>{0} is an option name like '--source'.</comment>
16111612
</data>
16121613
<data name="NoBinaryLogBecauseUpToDate" xml:space="preserve">
1613-
<value>Warning: Binary log option was specified but build will be skipped because output is up to date, specify '--no-cache' to force build.</value>
1614+
<value>Warning: Binary log option was specified but build will be skipped because output is up to date. Specify '--no-cache' to force build.</value>
16141615
<comment>{Locked="--no-cache"}</comment>
16151616
</data>
1617+
<data name="NoBinaryLogBecauseRunningJustCsc" xml:space="preserve">
1618+
<value>Warning: Binary log option was specified but MSBuild will be skipped because running just csc is enough. Specify '--no-cache' to force full build.</value>
1619+
<comment>{Locked="--no-cache"}{Locked="MSBuild"}{Locked="csc"}</comment>
1620+
</data>
16161621
<data name="PublishAppDescription" xml:space="preserve">
16171622
<value>Publisher for the .NET Platform</value>
16181623
</data>
@@ -1743,7 +1748,12 @@ The default is to publish a framework-dependent application.</value>
17431748
{1}</value>
17441749
</data>
17451750
<data name="RunCommandExceptionCouldNotLocateALaunchSettingsFile" xml:space="preserve">
1746-
<value>The specified launch profile '{0}' could not be located.</value>
1751+
<value>Cannot use launch profile '{0}' because the launch settings file could not be located. Locations tried:
1752+
{1}</value>
1753+
</data>
1754+
<data name="RunCommandWarningRunJsonNotUsed" xml:space="preserve">
1755+
<value>Warning: Settings from '{0}' are not used because '{1}' has precedence.</value>
1756+
<comment>{0} is an app.run.json file path. {1} is a launchSettings.json file path.</comment>
17471757
</data>
17481758
<data name="RunCommandExceptionMultipleProjects" xml:space="preserve">
17491759
<value>Specify which project file to use because {0} contains more than one project file.</value>

src/Cli/dotnet/Commands/Package/Add/PackageAddCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ private static void GetProjectDependencyGraph(string projectFilePath, string dgF
8989
$"-property:RestoreDotnetCliToolReferences=false",
9090

9191
// Output should not include MSBuild version header
92-
"-nologo"
92+
"-nologo",
93+
94+
// Set verbosity to quiet to avoid cluttering the output for this 'inner' build
95+
"-v:quiet"
9396
];
9497

9598
var result = new MSBuildForwardingApp(args).Execute();

0 commit comments

Comments
 (0)