Skip to content

Commit fddbb6a

Browse files
committed
2
1 parent 870e0cd commit fddbb6a

33 files changed

+446
-66
lines changed

Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<ItemGroup Condition="$(MicrosoftAspNetCoreAppRefPackageVersion.StartsWith('$(_TargetFrameworkVersionWithoutV)'))">
7373
<KnownFrameworkReference Update="Microsoft.AspNetCore.App">
7474
<LatestRuntimeFrameworkVersion>$(MicrosoftAspNetCoreAppRefPackageVersion)</LatestRuntimeFrameworkVersion>
75-
<RuntimePackRuntimeIdentifiers>${SupportedRuntimeIdentifiers}</RuntimePackRuntimeIdentifiers>
75+
<RuntimePackRuntimeIdentifiers>$(SupportedRuntimeIdentifiers)</RuntimePackRuntimeIdentifiers>
7676
<TargetingPackVersion>$(MicrosoftAspNetCoreAppRefPackageVersion)</TargetingPackVersion>
7777
<DefaultRuntimeFrameworkVersion>$(MicrosoftAspNetCoreAppRefPackageVersion)</DefaultRuntimeFrameworkVersion>
7878
</KnownFrameworkReference>

NuGet.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
3535
<!-- mstest dependencies -->
3636
<add key="test-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json" />
37+
<add key="R1" value="C:\R1\artifacts\packages\Debug\Shipping"/>
3738
</packageSources>
3839
<disabledPackageSources>
3940
<clear />

eng/Version.Details.props

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ This file should be imported by eng/Versions.props
3535
<MicrosoftBuildLocalizationPackageVersion>18.0.0-preview-25479-108</MicrosoftBuildLocalizationPackageVersion>
3636
<MicrosoftBuildNuGetSdkResolverPackageVersion>7.0.0-preview.1.48008</MicrosoftBuildNuGetSdkResolverPackageVersion>
3737
<MicrosoftBuildTasksGitPackageVersion>10.0.0-beta.25479.108</MicrosoftBuildTasksGitPackageVersion>
38-
<MicrosoftCodeAnalysisPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisPackageVersion>
39-
<MicrosoftCodeAnalysisBuildClientPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisBuildClientPackageVersion>
40-
<MicrosoftCodeAnalysisCSharpPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisCSharpPackageVersion>
41-
<MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>
42-
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
43-
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
44-
<MicrosoftCodeAnalysisPublicApiAnalyzersPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisPublicApiAnalyzersPackageVersion>
38+
<MicrosoftCodeAnalysisPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisPackageVersion>
39+
<MicrosoftCodeAnalysisBuildClientPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisBuildClientPackageVersion>
40+
<MicrosoftCodeAnalysisCSharpPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisCSharpPackageVersion>
41+
<MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>5.1.0-dev</MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>
42+
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
43+
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
44+
<MicrosoftCodeAnalysisPublicApiAnalyzersPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisPublicApiAnalyzersPackageVersion>
4545
<MicrosoftCodeAnalysisRazorToolingInternalPackageVersion>10.0.0-preview.25479.108</MicrosoftCodeAnalysisRazorToolingInternalPackageVersion>
46-
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
47-
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>5.0.0-2.25479.108</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
46+
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
47+
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
48+
<MicrosoftCodeAnalysisExternalAccessHotReloadPackageVersion>5.1.0-dev</MicrosoftCodeAnalysisExternalAccessHotReloadPackageVersion>
4849
<MicrosoftDeploymentDotNetReleasesPackageVersion>2.0.0-preview.1.25479.108</MicrosoftDeploymentDotNetReleasesPackageVersion>
4950
<MicrosoftDiaSymReaderPackageVersion>2.2.0-beta.25479.108</MicrosoftDiaSymReaderPackageVersion>
5051
<MicrosoftDotNetArcadeSdkPackageVersion>11.0.0-beta.25479.108</MicrosoftDotNetArcadeSdkPackageVersion>
@@ -68,8 +69,8 @@ This file should be imported by eng/Versions.props
6869
<MicrosoftExtensionsObjectPoolPackageVersion>10.0.0-rc.1.25479.108</MicrosoftExtensionsObjectPoolPackageVersion>
6970
<MicrosoftFSharpCompilerPackageVersion>14.0.100-rc2.25479.108</MicrosoftFSharpCompilerPackageVersion>
7071
<MicrosoftJSInteropPackageVersion>10.0.0-rc.1.25479.108</MicrosoftJSInteropPackageVersion>
71-
<MicrosoftNetCompilersToolsetPackageVersion>5.0.0-2.25479.108</MicrosoftNetCompilersToolsetPackageVersion>
72-
<MicrosoftNetCompilersToolsetFrameworkPackageVersion>5.0.0-2.25479.108</MicrosoftNetCompilersToolsetFrameworkPackageVersion>
72+
<MicrosoftNetCompilersToolsetPackageVersion>5.1.0-dev</MicrosoftNetCompilersToolsetPackageVersion>
73+
<MicrosoftNetCompilersToolsetFrameworkPackageVersion>5.1.0-dev</MicrosoftNetCompilersToolsetFrameworkPackageVersion>
7374
<MicrosoftNETHostModelPackageVersion>10.0.0-rc.1.25479.108</MicrosoftNETHostModelPackageVersion>
7475
<MicrosoftNETILLinkTasksPackageVersion>10.0.0-rc.1.25479.108</MicrosoftNETILLinkTasksPackageVersion>
7576
<MicrosoftNETRuntimeEmscripten3156Cachewinx64PackageVersion>10.0.0-rc.1.25479.108</MicrosoftNETRuntimeEmscripten3156Cachewinx64PackageVersion>

sdk.slnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@
321321
<Project Path="test/Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/Microsoft.AspNetCore.Watch.BrowserRefresh.Tests.csproj" />
322322
<Project Path="test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj" />
323323
<Project Path="test/Microsoft.DotNet.HotReload.Client.Tests/Microsoft.DotNet.HotReload.Client.Tests.csproj" />
324+
<Project Path="test/Microsoft.DotNet.HotReload.Test.Utilities/Microsoft.DotNet.HotReload.Test.Utilities.csproj" />
325+
<Project Path="test/Microsoft.DotNet.HotReload.Watch.Aspire.Tests/Microsoft.DotNet.HotReload.Watch.Aspire.Tests.csproj" />
324326
<Project Path="test/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj" />
325327
<Project Path="test/Microsoft.DotNet.PackageInstall.Tests/Microsoft.DotNet.PackageInstall.Tests.csproj" />
326328
<Project Path="test/Microsoft.DotNet.TemplateLocator.Tests/Microsoft.DotNet.TemplateLocator.Tests.csproj" />

src/BuiltInTools/Watch.Aspire/DotNetWatchLauncher.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Collections.Immutable;
54
using Microsoft.Extensions.Logging;
65

76
namespace Microsoft.DotNet.Watch;
87

9-
internal sealed class DotNetWatchOptions
10-
{
11-
public bool IsVerbose { get; init; }
12-
public bool IsQuiet { get; init; }
13-
public bool NoLaunchProfile { get; init; }
14-
public ImmutableArray<string> ApplicationArguments { get; init; }
15-
}
16-
178
internal static class DotNetWatchLauncher
189
{
19-
public static async Task<bool> RunAsync(
20-
string projectPath,
21-
string workingDirectory,
22-
DotNetWatchOptions options)
10+
public static async Task<bool> RunAsync(string workingDirectory, DotNetWatchOptions options)
2311
{
2412
var globalOptions = new GlobalOptions()
2513
{
@@ -40,7 +28,7 @@ public static async Task<bool> RunAsync(
4028
var rootProjectOptions = new ProjectOptions()
4129
{
4230
IsRootProject = true,
43-
ProjectPath = projectPath,
31+
ProjectPath = options.ProjectPath,
4432
WorkingDirectory = workingDirectory,
4533
TargetFramework = null,
4634
BuildArguments = [],
@@ -51,9 +39,11 @@ public static async Task<bool> RunAsync(
5139
LaunchEnvironmentVariables = [],
5240
};
5341

42+
var muxerPath = Path.GetFullPath(Path.Combine(options.SdkDirectory, "..", "..", "dotnet" + PathUtilities.ExecutableExtension));
43+
5444
var console = new PhysicalConsole(TestFlags.None);
5545
var reporter = new ConsoleReporter(console, globalOptions.Verbose, globalOptions.Quiet, suppressEmojis: false);
56-
var environmentOptions = EnvironmentOptions.FromEnvironment();
46+
var environmentOptions = EnvironmentOptions.FromEnvironment(muxerPath);
5747
var processRunner = new ProcessRunner(environmentOptions.GetProcessCleanupTimeout(isHotReloadEnabled: true));
5848
var loggerFactory = new LoggerFactory(reporter);
5949
var logger = loggerFactory.CreateLogger(DotNetWatchContext.DefaultLogComponentName);
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
using System.Collections.Immutable;
5+
using System.CommandLine;
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
namespace Microsoft.DotNet.Watch;
9+
10+
internal sealed class DotNetWatchOptions
11+
{
12+
/// <summary>
13+
/// The .NET SDK directory to load msbuild from (e.g. C:\Program Files\dotnet\sdk\10.0.100).
14+
/// Also used to locate `dotnet` executable.
15+
/// </summary>
16+
public required string SdkDirectory { get; init; }
17+
18+
public required string ProjectPath { get; init; }
19+
public required ImmutableArray<string> ApplicationArguments { get; init; }
20+
public bool IsVerbose { get; init; }
21+
public bool IsQuiet { get; init; }
22+
public bool NoLaunchProfile { get; init; }
23+
24+
public static bool TryParse(string[] args, [NotNullWhen(true)] out DotNetWatchOptions? options)
25+
{
26+
var sdkOption = new Option<string>("--sdk") { Arity = ArgumentArity.ExactlyOne, Required = true, AllowMultipleArgumentsPerToken = false };
27+
var projectOption = new Option<string>("--project") { Arity = ArgumentArity.ExactlyOne, Required = true, AllowMultipleArgumentsPerToken = false };
28+
var quietOption = new Option<bool>("--quiet") { Arity = ArgumentArity.Zero };
29+
var verboseOption = new Option<bool>("--verbose") { Arity = ArgumentArity.Zero };
30+
var noLaunchProfileOption = new Option<bool>("--no-launch-profile") { Arity = ArgumentArity.Zero };
31+
var applicationArguments = new Argument<string[]>("arguments") { Arity = ArgumentArity.ZeroOrMore };
32+
33+
verboseOption.Validators.Add(v =>
34+
{
35+
if (v.GetValue(quietOption) && v.GetValue(verboseOption))
36+
{
37+
v.AddError("Cannot specify both '--quiet' and '--verbose' options.");
38+
}
39+
});
40+
41+
var rootCommand = new RootCommand()
42+
{
43+
Directives = { new EnvironmentVariablesDirective() },
44+
Options =
45+
{
46+
sdkOption,
47+
projectOption,
48+
quietOption,
49+
verboseOption,
50+
noLaunchProfileOption
51+
},
52+
Arguments =
53+
{
54+
applicationArguments
55+
}
56+
};
57+
58+
var parseResult = rootCommand.Parse(args);
59+
if (parseResult.Errors.Count > 0)
60+
{
61+
foreach (var error in parseResult.Errors)
62+
{
63+
Console.Error.WriteLine(error);
64+
}
65+
66+
options = null;
67+
return false;
68+
}
69+
70+
options = new DotNetWatchOptions()
71+
{
72+
SdkDirectory = parseResult.GetRequiredValue(sdkOption),
73+
ProjectPath = parseResult.GetRequiredValue(projectOption),
74+
IsQuiet = parseResult.GetValue(quietOption),
75+
IsVerbose = parseResult.GetValue(verboseOption),
76+
ApplicationArguments = [.. parseResult.GetValue(applicationArguments) ?? []],
77+
NoLaunchProfile = parseResult.GetValue(noLaunchProfileOption),
78+
};
79+
80+
return true;
81+
}
82+
}

src/BuiltInTools/Watch.Aspire/Microsoft.DotNet.HotReload.Watch.Aspire.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@
44
<PropertyGroup>
55
<TargetFramework>$(SdkTargetFramework)</TargetFramework>
66
<StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
7+
<OutputType>Exe</OutputType>
78
<RootNamespace>Microsoft.DotNet.Watch</RootNamespace>
9+
<IsShipping>true</IsShipping>
810

911
<!-- NuGet -->
1012
<IsPackable>true</IsPackable>
13+
<IsShippingPackage>true</IsShippingPackage>
14+
<PackAsTool>true</PackAsTool>
1115
<PackageId>Microsoft.DotNet.HotReload.Watch.Aspire</PackageId>
1216
<PackageDescription>
1317
A supporting package for Aspire CLI:
1418
https://github.com/dotnet/aspire
1519
</PackageDescription>
1620
</PropertyGroup>
1721

22+
<ItemGroup>
23+
<PackageReference Include="System.CommandLine" />
24+
<PackageReference Include="Microsoft.Build.Locator" />
25+
</ItemGroup>
26+
1827
<ItemGroup>
1928
<ProjectReference Include="..\Watch\Microsoft.DotNet.HotReload.Watch.csproj" />
2029
</ItemGroup>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.Build.Locator;
2+
using Microsoft.DotNet.Watch;
3+
4+
if (!DotNetWatchOptions.TryParse(args, out var options))
5+
{
6+
return -1;
7+
}
8+
9+
MSBuildLocator.RegisterMSBuildPath(options.SdkDirectory);
10+
11+
var workingDirectory = Directory.GetCurrentDirectory();
12+
return await DotNetWatchLauncher.RunAsync(workingDirectory, options) ? 0 : 1;

src/BuiltInTools/Watch.Aspire/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
using System.Runtime.CompilerServices;
55

6-
// ⚠ ONLY ASSEMBLIES BUILT FROM dotnet/aspire MAY BE ADDED HERE ⚠
7-
[assembly: InternalsVisibleTo("Aspire.Cli, PublicKey = 00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
6+
[assembly: InternalsVisibleTo("Microsoft.DotNet.HotReload.Watch.Aspire.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
7+
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

src/BuiltInTools/Watch/Context/EnvironmentOptions.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ internal sealed record EnvironmentOptions(
4141
TestFlags TestFlags = TestFlags.None,
4242
string TestOutput = "")
4343
{
44-
public static EnvironmentOptions FromEnvironment() => new
44+
public static EnvironmentOptions FromEnvironment(string muxerPath) => new
4545
(
4646
WorkingDirectory: Directory.GetCurrentDirectory(),
47-
MuxerPath: GetMuxerPathFromEnvironment(),
47+
MuxerPath: ValidateMuxerPath(muxerPath),
4848
ProcessCleanupTimeout: EnvironmentVariables.ProcessCleanupTimeout,
4949
IsPollingEnabled: EnvironmentVariables.IsPollingEnabled,
5050
SuppressHandlingStaticContentFiles: EnvironmentVariables.SuppressHandlingStaticContentFiles,
@@ -69,12 +69,10 @@ public TimeSpan GetProcessCleanupTimeout(bool isHotReloadEnabled)
6969

7070
public bool RunningAsTest { get => (TestFlags & TestFlags.RunningAsTest) != TestFlags.None; }
7171

72-
private static string GetMuxerPathFromEnvironment()
72+
private static string ValidateMuxerPath(string path)
7373
{
74-
var muxerPath = Environment.ProcessPath;
75-
Debug.Assert(muxerPath != null);
76-
Debug.Assert(Path.GetFileNameWithoutExtension(muxerPath) == "dotnet", $"Invalid muxer path {muxerPath}");
77-
return muxerPath;
74+
Debug.Assert(Path.GetFileNameWithoutExtension(path) == "dotnet");
75+
return path;
7876
}
7977

8078
public string? GetBinLogPath(string projectPath, string operationName, GlobalOptions options)

0 commit comments

Comments
 (0)