diff --git a/src/Aspire.Hosting.Sdk/Aspire.Hosting.Sdk.csproj b/src/Aspire.Hosting.Sdk/Aspire.Hosting.Sdk.csproj index ee8eaa6c1fb..f785b101c2d 100644 --- a/src/Aspire.Hosting.Sdk/Aspire.Hosting.Sdk.csproj +++ b/src/Aspire.Hosting.Sdk/Aspire.Hosting.Sdk.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/Aspire.Hosting.Sdk/SDK/Sdk.targets b/src/Aspire.Hosting.Sdk/SDK/Sdk.in.targets similarity index 87% rename from src/Aspire.Hosting.Sdk/SDK/Sdk.targets rename to src/Aspire.Hosting.Sdk/SDK/Sdk.in.targets index c508b67ab3e..3987bf67320 100644 --- a/src/Aspire.Hosting.Sdk/SDK/Sdk.targets +++ b/src/Aspire.Hosting.Sdk/SDK/Sdk.in.targets @@ -71,13 +71,17 @@ <_AppHostVersion>%(_AppHostPackageReference.Version) - - <__CurrentAppHostVersionMessage> You are using version $(_AppHostVersion). + + + <_AppHostVersion>@VERSION@ - + diff --git a/tests/Aspire.Hosting.Testing.Tests/Directory.Build.targets b/tests/Aspire.Hosting.Testing.Tests/Directory.Build.targets index bf347a727b0..dac9790b14d 100644 --- a/tests/Aspire.Hosting.Testing.Tests/Directory.Build.targets +++ b/tests/Aspire.Hosting.Testing.Tests/Directory.Build.targets @@ -4,7 +4,7 @@ - + diff --git a/tests/Aspire.Hosting.Tests/MSBuildTests.cs b/tests/Aspire.Hosting.Tests/MSBuildTests.cs index fd902967644..024e96ad69a 100644 --- a/tests/Aspire.Hosting.Tests/MSBuildTests.cs +++ b/tests/Aspire.Hosting.Tests/MSBuildTests.cs @@ -87,7 +87,7 @@ the Aspire.Hosting.SDK targets that will automatically add these references to p File.WriteAllText(Path.Combine(appHostDirectory, "Directory.Build.targets"), $""" - + """); diff --git a/tests/Aspire.Workload.Tests/AppHostTemplateTests.cs b/tests/Aspire.Workload.Tests/AppHostTemplateTests.cs new file mode 100644 index 00000000000..e25efa56b09 --- /dev/null +++ b/tests/Aspire.Workload.Tests/AppHostTemplateTests.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit; +using Xunit.Abstractions; +using System.Text.RegularExpressions; + +namespace Aspire.Workload.Tests; + +public partial class AppHostTemplateTests : WorkloadTestsBase +{ + public AppHostTemplateTests(ITestOutputHelper testOutput) + : base(testOutput) + { + } + + [Fact] + public async Task EnsureProjectsReferencing8_1_0AppHostWithNewerWorkloadCanBuild() + { + string projectId = "aspire-can-reference-8.1.0"; + await using var project = await AspireProject.CreateNewTemplateProjectAsync( + projectId, + "aspire-apphost", + _testOutput, + BuildEnvironment.ForDefaultFramework, + string.Empty, + false); + + var projectPath = Path.Combine(project.RootDir, $"{projectId}.csproj"); + + // Replace the reference to Aspire.Hosting.AppHost with version 8.1.0 + var newContents = AppHostPackageReferenceRegex().Replace(File.ReadAllText(projectPath), @"$1""8.1.0"""); + + File.WriteAllText(projectPath, newContents); + + // Ensure project builds successfully + await project.BuildAsync(workingDirectory: project.RootDir); + } + + [GeneratedRegex(@"(PackageReference\s.*""Aspire\.Hosting\.AppHost.*Version=)""[^""]+""")] + private static partial Regex AppHostPackageReferenceRegex(); +} diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets index 14b270a8593..b0650e8931c 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets @@ -140,7 +140,7 @@ - + diff --git a/tests/Shared/WorkloadTesting/AspireProject.cs b/tests/Shared/WorkloadTesting/AspireProject.cs index 602ea38762f..af4f4dcc737 100644 --- a/tests/Shared/WorkloadTesting/AspireProject.cs +++ b/tests/Shared/WorkloadTesting/AspireProject.cs @@ -261,10 +261,12 @@ public async Task StartAppHostAsync(string[]? extraArgs = default, Action