diff --git a/playground/ParameterEndToEnd/ParameterEndToEnd.AppHost/AppHost.cs b/playground/ParameterEndToEnd/ParameterEndToEnd.AppHost/AppHost.cs
index b2e191eef1b..0773be7a1cd 100644
--- a/playground/ParameterEndToEnd/ParameterEndToEnd.AppHost/AppHost.cs
+++ b/playground/ParameterEndToEnd/ParameterEndToEnd.AppHost/AppHost.cs
@@ -15,9 +15,11 @@
// The expression below is a bit more complex than the average developer app would
// probably have, but in our repo we'll probably want to experiment with seperately
// deployed resources a little bit.
-var db = builder.AddSqlServer("sql")
- .PublishAsConnectionString()
- .AddDatabase("db");
+var sql = builder.AddSqlServer("sql");
+#pragma warning disable CS0618 // This playground intentionally exercises obsolete manifest-only PublishAsConnectionString behavior.
+sql.PublishAsConnectionString();
+#pragma warning restore CS0618
+var db = sql.AddDatabase("db");
var insertionrows = builder.AddParameter("insertionrows")
.WithDescription("The number of rows to insert into the database.");
diff --git a/src/Aspire.Hosting.Azure/AzureResourceExtensions.cs b/src/Aspire.Hosting.Azure/AzureResourceExtensions.cs
index 3c7db938cb7..d5f2f422ef8 100644
--- a/src/Aspire.Hosting.Azure/AzureResourceExtensions.cs
+++ b/src/Aspire.Hosting.Azure/AzureResourceExtensions.cs
@@ -18,7 +18,11 @@ public static class AzureResourceExtensions
/// The resource type.
/// The resource builder.
/// The configured .
+ ///
+ /// This API only changes the manifest representation; it does not change the resource model used by other publishers.
+ ///
/// The resource builder.
+ [Obsolete("PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.")]
[AspireExport]
public static IResourceBuilder PublishAsConnectionString(this IResourceBuilder builder)
where T : IAzureResource, IResourceWithConnectionString
diff --git a/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs b/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs
index c121e583172..d0ffcf7de32 100644
--- a/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs
+++ b/src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs
@@ -363,7 +363,11 @@ internal static IResourceBuilder AddConnectionStr
/// The resource type.
/// The resource builder.
/// The configured .
+ ///
+ /// This API only changes the manifest representation; it does not change the resource model used by other publishers.
+ ///
/// The resource builder.
+ [Obsolete("PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.")]
[AspireExport]
public static IResourceBuilder PublishAsConnectionString(this IResourceBuilder builder)
where T : ContainerResource, IResourceWithConnectionString
diff --git a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts
index 8532ccdbd8c..bb75379ad07 100644
--- a/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts
+++ b/tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts
@@ -14067,7 +14067,10 @@ export interface ContainerResource {
withOtlpExporter(options?: WithOtlpExporterOptions): ContainerResourcePromise;
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): ContainerResourcePromise;
/**
@@ -14808,7 +14811,10 @@ export interface ContainerResourcePromise extends PromiseLike
withOtlpExporter(options?: WithOtlpExporterOptions): ContainerResourcePromise;
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): ContainerResourcePromise;
/**
@@ -15909,7 +15915,10 @@ class ContainerResourceImpl extends ResourceBuilderBase
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): ContainerResourcePromise {
return new ContainerResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client);
@@ -37423,7 +37432,10 @@ export interface TestDatabaseResource {
withOtlpExporter(options?: WithOtlpExporterOptions): TestDatabaseResourcePromise;
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): TestDatabaseResourcePromise;
/**
@@ -38164,7 +38176,10 @@ export interface TestDatabaseResourcePromise extends PromiseLike
withOtlpExporter(options?: WithOtlpExporterOptions): TestRedisResourcePromise;
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): TestRedisResourcePromise;
/**
@@ -43893,7 +43917,10 @@ class TestRedisResourceImpl extends ResourceBuilderBase
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): TestRedisResourcePromise {
return new TestRedisResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client);
@@ -46860,7 +46887,10 @@ export interface TestVaultResource {
withOtlpExporter(options?: WithOtlpExporterOptions): TestVaultResourcePromise;
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): TestVaultResourcePromise;
/**
@@ -47603,7 +47633,10 @@ export interface TestVaultResourcePromise extends PromiseLike
withOtlpExporter(options?: WithOtlpExporterOptions): TestVaultResourcePromise;
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): TestVaultResourcePromise;
/**
@@ -48705,7 +48738,10 @@ class TestVaultResourceImpl extends ResourceBuilderBase
/**
* Changes the resource to be published as a connection string reference in the manifest.
+ *
+ * This API only changes the manifest representation; it does not change the resource model used by other publishers.
* @returns The resource builder.
+ * @deprecated PublishAsConnectionString only works with the manifest publisher and is obsolete. Use AddConnectionString in publish-mode app model code instead.
*/
publishAsConnectionString(): TestVaultResourcePromise {
return new TestVaultResourcePromiseImpl(this._publishAsConnectionStringInternal(), this._client);
diff --git a/tests/Aspire.Hosting.Tests/PublishAsConnectionStringTests.cs b/tests/Aspire.Hosting.Tests/PublishAsConnectionStringTests.cs
index 68dc2fe1c99..6b2d05764a2 100644
--- a/tests/Aspire.Hosting.Tests/PublishAsConnectionStringTests.cs
+++ b/tests/Aspire.Hosting.Tests/PublishAsConnectionStringTests.cs
@@ -14,7 +14,10 @@ public async Task PublishAsConnectionStringConfiguresManifestAsParameter()
{
var builder = DistributedApplication.CreateBuilder();
- var redis = builder.AddRedis("redis").PublishAsConnectionString();
+#pragma warning disable CS0618 // Test intentionally covers obsolete PublishAsConnectionString manifest behavior.
+ var redis = builder.AddRedis("redis")
+ .PublishAsConnectionString();
+#pragma warning restore CS0618
Assert.True(redis.Resource.TryGetLastAnnotation(out _));