Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
16 changes: 15 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.5" />
<PackageVersion Include="Microsoft.ApplicationInsights.WorkerService" Version="2.23.0" />
<!-- playground apps dependencies for javascript -->
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.20" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.1" />
<!-- Pinned versions for Component Governance - Remove when root dependencies are updated -->
<PackageVersion Include="Azure.Core" Version="1.47.3" />
Expand Down Expand Up @@ -242,5 +241,20 @@
<PackageVersion Update="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpVersion)" />
<PackageVersion Update="System.Formats.Asn1" Version="$(SystemFormatsAsn1Version)" />
<PackageVersion Update="System.Text.Json" Version="$(SystemTextJsonVersion)" />
<PackageVersion Update="System.Threading.Channels" Version="$(SystemThreadingChannelsVersion)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net10.0'">
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.20" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="$(MicrosoftAspNetCorePackageVersionForNet10)" />
</ItemGroup>

<!-- These are 9.x versions which are STS so should ONLY be referenced by netfx projects -->
<ItemGroup Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472' OR '$(TargetFramework)' == 'netstandard2.0' ">
<PackageVersion Include="Microsoft.Bcl.Memory" Version="$(MicrosoftBclMemoryVersion)" />
<PackageVersion Include="Microsoft.Bcl.TimeProvider" Version="$(MicrosoftBclTimeProviderVersion)" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion playground/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup Condition="'$(IsAspireHost)' == 'true' and '$(RepoRoot)' != '' and '$(SkipAspireHostingAnalyzersReference)' != 'true'">
<ProjectReference Include="..\..\..\src\Aspire.Hosting.Analyzers\Aspire.Hosting.Analyzers.csproj" IsAspireProjectResource="false"
<ProjectReference Include="$(MSBuildThisFileDirectory)..\src\Aspire.Hosting.Analyzers\Aspire.Hosting.Analyzers.csproj" IsAspireProjectResource="false"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
Expand Down
9 changes: 9 additions & 0 deletions playground/FileBasedApps/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<NoWarn>$(NoWarn);ASPIRECSHARPAPPS001</NoWarn>
</PropertyGroup>

</Project>
13 changes: 13 additions & 0 deletions playground/FileBasedApps/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>

<ItemGroup Condition="'$(IsAspireHost)' == 'true'">
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\KnownResourceNames.cs" Link="KnownResourceNames.cs" />
</ItemGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />

</Project>
38 changes: 38 additions & 0 deletions playground/FileBasedApps/api.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env dotnet

#:sdk Microsoft.NET.Sdk.Web
#:package Microsoft.AspNetCore.OpenApi
#:project ../Playground.ServiceDefaults

using System.Text.Json.Serialization;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});

builder.Services.AddOpenApi();

var app = builder.Build();

app.MapGet("/", () => new HelloResponse { Message = "Hello, World!" })
.WithName("HelloWorld");

app.MapDefaultEndpoints();

app.Run();

sealed class HelloResponse
{
public string Message { get; set; } = "Hello, World!";
}

[JsonSerializable(typeof(HelloResponse))]
sealed partial class AppJsonSerializerContext : JsonSerializerContext
{

}
23 changes: 23 additions & 0 deletions playground/FileBasedApps/api.run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5202",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7276;http://localhost:5202",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
9 changes: 9 additions & 0 deletions playground/FileBasedApps/api.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
18 changes: 18 additions & 0 deletions playground/FileBasedApps/apphost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#:property IsAspireHost=true
#:property PublishAot=false

var builder = DistributedApplication.CreateBuilder(args);

builder.AddCSharpApp("api", "api.cs");

#if !SKIP_DASHBOARD_REFERENCE
// This project is only added in playground projects to support development/debugging
// of the dashboard. It is not required in end developer code. Comment out this code
// or build with `/p:SkipDashboardReference=true`, to test end developer
// dashboard launch experience, Refer to Directory.Build.props for the path to
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
// artifacts dir).
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
#endif

builder.Build().Run();
29 changes: 29 additions & 0 deletions playground/FileBasedApps/apphost.run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17123;http://localhost:15234",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21456",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22678"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15234",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19456",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20678"
}
}
}
}
8 changes: 8 additions & 0 deletions playground/FileBasedApps/apphost.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
11 changes: 6 additions & 5 deletions src/Aspire.AppHost.Sdk/SDK/Sdk.in.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
<!-- Do not import the workload targets as this project is instead using the Aspire.AppHost.Sdk -->
<SkipAspireWorkloadManifest>true</SkipAspireWorkloadManifest>
<IsAspireHost>true</IsAspireHost>
<!-- Auto-import the Microsoft.NET.Sdk if not already imported -->
<_ImportMicrosoftNETSdkFromAspireSdk Condition=" '$(UsingMicrosoftNETSdk)' == '' ">true</_ImportMicrosoftNETSdkFromAspireSdk>
</PropertyGroup>

<PropertyGroup Condition=" '$(FileBasedProgram)' == 'true' ">
<!-- Disable AOT and Trimming for file-based apps -->
<PublishAot>false</PublishAot>
<PublishTrimmed>false</PublishTrimmed>
<!-- <PublishTrimmed>false</PublishTrimmed>
<EnableAotAnalyzer>false</EnableAotAnalyzer>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer>
<_ImportMicrosoftNETSdkFromAspireSdk Condition=" '$(UsingMicrosoftNETSdk)' == '' ">true</_ImportMicrosoftNETSdkFromAspireSdk>
<_ForceAspireFileBasedAppHostDefaults Condition=" '$(IsAspireHost)' == 'true' ">true</_ForceAspireFileBasedAppHostDefaults>
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer> -->
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition=" '$(_ImportMicrosoftNETSdkFromAspireSdk)' == 'true' " />
</Project>
</Project>
22 changes: 3 additions & 19 deletions src/Aspire.AppHost.Sdk/SDK/Sdk.in.targets
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,10 @@
<AspireRidToolExecutable>$(AspireRidToolDirectory)Aspire.RuntimeIdentifier.Tool.dll</AspireRidToolExecutable>
</PropertyGroup>

<!-- If the AppHost is a file-based app, then force disable AOT and Trimming.
This can be removed once https://github.com/dotnet/sdk/pull/50885 is merged and flows through to .NET 10 SDK as the values set in Sdk.props will be sufficient. -->
<Target Name="DisablePublishAotForAspireHost" BeforeTargets="_ComputeToolPackInputsToProcessFrameworkReferences;_CollectTargetFrameworkForTelemetry;ProcessFrameworkReferences;Restore;CollectPackageReferences"
Condition="'$(_ForceAspireFileBasedAppHostDefaults)' == 'true'">
<PropertyGroup>
<PublishAot>false</PublishAot>
<PublishTrimmed>false</PublishTrimmed>
<EnableAotAnalyzer>false</EnableAotAnalyzer>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Remove="NativeAOT;PublishAot;PublishTrimmed" />
</ItemGroup>
</Target>

<!-- If the AppHost is a file-based app, add an implicit reference to the Aspire.Hosting.AppHost package if not already referenced.
This is done here so that file-based apps only need to set the single #sdk: directive line to make them an Aspire AppHost.
<!-- Add an implicit reference to the Aspire.Hosting.AppHost package if not already referenced.
This is done here so that AppHost projects and file-based apps only need to set the SDK to make them an Aspire AppHost.
This mechanism can be disabled by setting `SkipAddAspireDefaultReferences` to `true` -->
<Target Name="AddImplicitAspireAppHostPackage" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(_ForceAspireFileBasedAppHostDefaults)' == 'true' and '$(SkipAddAspireDefaultReferences)' != 'true'">
<Target Name="AddImplicitAspireAppHostPackage" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(SkipAddAspireDefaultReferences)' != 'true'">
<PropertyGroup>
<_ImplicitAppHostVersion>@VERSION@</_ImplicitAppHostVersion>
</PropertyGroup>
Expand Down
Loading
Loading