Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/dependabot/Packages.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>

<!-- Packages in this file have versions updated periodically by Dependabot. Versions managed by Darc/Maestro should be in ..\Packages.props. -->

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"Microsoft.Build.NoTargets": "3.7.134",
"Microsoft.Build.Traversal": "4.1.82",
"Microsoft.WixToolset.Sdk": "6.0.3-dotnet.4",
"MSTest.Sdk": "4.3.0-preview.26307.5"
"MSTest.Sdk": "4.3.0-preview.26311.10"
}
}
1 change: 1 addition & 0 deletions sdk.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
<Project Path="test/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj" />
<Project Path="test/Microsoft.DotNet.PackageInstall.Tests/Microsoft.DotNet.PackageInstall.Tests.csproj" />
<Project Path="test/Microsoft.DotNet.TemplateLocator.Tests/Microsoft.DotNet.TemplateLocator.Tests.csproj" />
<Project Path="test/Microsoft.DotNet.Test.MSTest.Utilities/Microsoft.DotNet.Test.MSTest.Utilities.csproj" />
<Project Path="test/Microsoft.DotNet.Tools.Tests.ComponentMocks/Microsoft.DotNet.Tools.Tests.ComponentMocks.csproj" />
<Project Path="test/Microsoft.Extensions.DotNetDeltaApplier.Tests/Microsoft.Extensions.DotNetDeltaApplier.Tests.csproj" />
<Project Path="test/Microsoft.NET.Build.Containers.IntegrationTests/Microsoft.NET.Build.Containers.IntegrationTests.csproj" />
Expand Down
1 change: 1 addition & 0 deletions src/Dotnet.Watch/Watch.Aspire/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Microsoft.DotNet.HotReload.Watch.Aspire.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-watch.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
1 change: 1 addition & 0 deletions src/Dotnet.Watch/dotnet-watch.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"test\\dotnet-watch-test-browser\\dotnet-watch-test-browser.csproj",
"test\\Microsoft.DotNet.HotReload.Test.Utilities\\Microsoft.DotNet.HotReload.Test.Utilities.csproj",
"test\\Microsoft.DotNet.HotReload.Watch.Aspire.Tests\\Microsoft.DotNet.HotReload.Watch.Aspire.Tests.csproj",
"test\\Microsoft.DotNet.Test.MSTest.Utilities\\Microsoft.DotNet.Test.MSTest.Utilities.csproj",
"test\\Microsoft.Extensions.DotNetDeltaApplier.Tests\\Microsoft.Extensions.DotNetDeltaApplier.Tests.csproj",
"test\\dotnet-watch.Tests\\dotnet-watch.Tests.csproj"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Test.MSTest.Utilities\Microsoft.DotNet.Test.MSTest.Utilities.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.DotNet.Watch.UnitTests;
using Microsoft.DotNet.Test.MSTest.Utilities;
using Microsoft.Extensions.Logging.Abstractions;

namespace Microsoft.DotNet.HotReload.UnitTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,145 +1,146 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Extensions.Logging;

namespace Microsoft.DotNet.Watch.UnitTests;

[TestClass]
public class AspireHostLauncherCliTests
{
[Fact]
[TestMethod]
public void RequiredSdkOption()
{
// --sdk option is missing
var args = new[] { "host", "--entrypoint", "proj", "a", "b" };
var launcher = AspireLauncher.TryCreate(args);
Assert.Null(launcher);
Assert.IsNull(launcher);
}

[Fact]
[TestMethod]
public void RequiredEntryPointOption()
{
// --entrypoint option is missing
var args = new[] { "host", "--sdk", "sdk", "--verbose" };
var launcher = AspireLauncher.TryCreate(args);
Assert.Null(launcher);
Assert.IsNull(launcher);
}

[Fact]
[TestMethod]
public void ProjectAndSdkPaths()
{
var args = new[] { "host", "--sdk", "sdk", "--entrypoint", "myproject.csproj" };
var launcher = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.Equal("sdk", launcher.EnvironmentOptions.SdkDirectory);
Assert.True(launcher.EntryPoint.IsProjectFile);
Assert.Equal("myproject.csproj", launcher.EntryPoint.PhysicalPath);
Assert.Empty(launcher.ApplicationArguments);
Assert.Equal(LogLevel.Information, launcher.GlobalOptions.LogLevel);
var launcher = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.AreEqual("sdk", launcher.EnvironmentOptions.SdkDirectory);
Assert.IsTrue(launcher.EntryPoint.IsProjectFile);
Assert.AreEqual("myproject.csproj", launcher.EntryPoint.PhysicalPath);
Assert.IsEmpty(launcher.ApplicationArguments);
Assert.AreEqual(LogLevel.Information, launcher.GlobalOptions.LogLevel);
}

[Fact]
[TestMethod]
public void FilePath()
{
var args = new[] { "host", "--sdk", "sdk", "--entrypoint", "file.cs" };
var launcher = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.Equal("sdk", launcher.EnvironmentOptions.SdkDirectory);
Assert.False(launcher.EntryPoint.IsProjectFile);
Assert.Equal("file.cs", launcher.EntryPoint.EntryPointFilePath);
Assert.Empty(launcher.ApplicationArguments);
Assert.Equal(LogLevel.Information, launcher.GlobalOptions.LogLevel);
var launcher = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.AreEqual("sdk", launcher.EnvironmentOptions.SdkDirectory);
Assert.IsFalse(launcher.EntryPoint.IsProjectFile);
Assert.AreEqual("file.cs", launcher.EntryPoint.EntryPointFilePath);
Assert.IsEmpty(launcher.ApplicationArguments);
Assert.AreEqual(LogLevel.Information, launcher.GlobalOptions.LogLevel);
}

[Fact]
[TestMethod]
public void ApplicationArguments()
{
var args = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj", "--verbose", "a", "b" };
var launcher = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
AssertEx.SequenceEqual(["a", "b"], launcher.ApplicationArguments);
Assert.Equal(LogLevel.Debug, launcher.GlobalOptions.LogLevel);
var launcher = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.AreSequenceEqual(["a", "b"], launcher.ApplicationArguments);
Assert.AreEqual(LogLevel.Debug, launcher.GlobalOptions.LogLevel);
}

[Fact]
[TestMethod]
public void VerboseOption()
{
// With verbose flag
var argsVerbose = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj", "--verbose" };
var launcherVerbose = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(argsVerbose));
Assert.Equal(LogLevel.Debug, launcherVerbose.GlobalOptions.LogLevel);
var launcherVerbose = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(argsVerbose));
Assert.AreEqual(LogLevel.Debug, launcherVerbose.GlobalOptions.LogLevel);

// Without verbose flag
var argsNotVerbose = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj" };
var launcherNotVerbose = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(argsNotVerbose));
Assert.Equal(LogLevel.Information, launcherNotVerbose.GlobalOptions.LogLevel);
var launcherNotVerbose = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(argsNotVerbose));
Assert.AreEqual(LogLevel.Information, launcherNotVerbose.GlobalOptions.LogLevel);
}

[Fact]
[TestMethod]
public void QuietOption()
{
// With quiet flag
var argsQuiet = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj", "--quiet" };
var launcherQuiet = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(argsQuiet));
Assert.Equal(LogLevel.Warning, launcherQuiet.GlobalOptions.LogLevel);
var launcherQuiet = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(argsQuiet));
Assert.AreEqual(LogLevel.Warning, launcherQuiet.GlobalOptions.LogLevel);

// Without quiet flag
var argsNotQuiet = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj" };
var launcherNotQuiet = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(argsNotQuiet));
Assert.Equal(LogLevel.Information, launcherNotQuiet.GlobalOptions.LogLevel);
var launcherNotQuiet = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(argsNotQuiet));
Assert.AreEqual(LogLevel.Information, launcherNotQuiet.GlobalOptions.LogLevel);
}

[Fact]
[TestMethod]
public void NoLaunchProfileOption()
{
// With no-launch-profile flag
var argsNoProfile = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj", "--no-launch-profile" };
var launcherNoProfile = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(argsNoProfile));
Assert.False(launcherNoProfile.LaunchProfileName.HasValue);
var launcherNoProfile = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(argsNoProfile));
Assert.IsFalse(launcherNoProfile.LaunchProfileName.HasValue);

// Without no-launch-profile flag
var argsDefault = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj" };
var launcherDefault = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(argsDefault));
Assert.True(launcherDefault.LaunchProfileName.HasValue);
Assert.Null(launcherDefault.LaunchProfileName.Value);
var launcherDefault = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(argsDefault));
Assert.IsTrue(launcherDefault.LaunchProfileName.HasValue);
Assert.IsNull(launcherDefault.LaunchProfileName.Value);
}

[Fact]
[TestMethod]
public void LaunchProfileOption()
{
var args = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj", "--launch-profile", "MyProfile" };
var launcher = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.True(launcher.LaunchProfileName.HasValue);
Assert.Equal("MyProfile", launcher.LaunchProfileName.Value);
var launcher = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.IsTrue(launcher.LaunchProfileName.HasValue);
Assert.AreEqual("MyProfile", launcher.LaunchProfileName.Value);
}

[Fact]
[TestMethod]
public void ConflictingOptions()
{
// Cannot specify both --quiet and --verbose
var args = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj", "--quiet", "--verbose" };
var launcher = AspireLauncher.TryCreate(args);
Assert.Null(launcher);
Assert.IsNull(launcher);
}

[Fact]
[TestMethod]
public void EntryPoint_MultipleValues()
{
// EntryPoint option should only accept one value; extra values become application arguments
var args = new[] { "host", "--sdk", "sdk", "--entrypoint", "proj1", "proj2" };
var launcher = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.Equal("proj1", launcher.EntryPoint.ProjectOrEntryPointFilePath);
AssertEx.SequenceEqual(["proj2"], launcher.ApplicationArguments);
var launcher = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(args));
Assert.AreEqual("proj1", launcher.EntryPoint.ProjectOrEntryPointFilePath);
Assert.AreSequenceEqual(["proj2"], launcher.ApplicationArguments);
}

[Fact]
[TestMethod]
public void AllOptionsSet()
{
var args = new[] { "host", "--sdk", "sdk", "--entrypoint", "myapp.csproj", "--verbose", "--no-launch-profile", "arg1", "arg2", "arg3" };
var launcher = Assert.IsType<AspireHostLauncher>(AspireLauncher.TryCreate(args));

Assert.True(launcher.EntryPoint.IsProjectFile);
Assert.Equal("myapp.csproj", launcher.EntryPoint.PhysicalPath);
Assert.Equal("sdk", launcher.EnvironmentOptions.SdkDirectory);
Assert.Equal(LogLevel.Debug, launcher.GlobalOptions.LogLevel);
Assert.False(launcher.LaunchProfileName.HasValue);
AssertEx.SequenceEqual(["arg1", "arg2", "arg3"], launcher.ApplicationArguments);
var launcher = Assert.IsExactInstanceOfType<AspireHostLauncher>(AspireLauncher.TryCreate(args));

Assert.IsTrue(launcher.EntryPoint.IsProjectFile);
Assert.AreEqual("myapp.csproj", launcher.EntryPoint.PhysicalPath);
Assert.AreEqual("sdk", launcher.EnvironmentOptions.SdkDirectory);
Assert.AreEqual(LogLevel.Debug, launcher.GlobalOptions.LogLevel);
Assert.IsFalse(launcher.LaunchProfileName.HasValue);
Assert.AreSequenceEqual(["arg1", "arg2", "arg3"], launcher.ApplicationArguments);
}
}
}
Loading
Loading