Skip to content

Commit

Permalink
Merge pull request #2 from BretJohnson/template-fixes
Browse files Browse the repository at this point in the history
Fixup project template
  • Loading branch information
BretJohnson authored Feb 8, 2024
2 parents 284fa04 + 1dab953 commit ebdded9
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/MauiAspire.Hosting.SettingsGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void WriteSettings(IDictionary environmentVariables, string settingsPath)
using (StreamWriter file = new StreamWriter(settingsPath))
{
file.Write("""
// This file is generated from the Aspire AppHost project. Re-run the Aspre AppHost
// This file is generated from the Aspire AppHost project. Rerun the Aspire AppHost
// to regenerate it.
public static class AspireAppSettings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Adapted from https://github.com/dotnet/aspire/blob/07b13d47cd052c271d4ed73072668c774f8dd63c/src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj -->

<Project Sdk="Microsoft.NET.Sdk" InitialTargets="AddTemplatesToPackageAsContent">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -13,15 +13,17 @@
<NoWarn>$(NoWarn);NU5128</NoWarn>
<EnableDefaultItems>false</EnableDefaultItems>
<Description>.NET MAUI Aspire Template Pack for Microsoft Template Engine</Description>
<AspireVersion>8.0.0-preview.2.23619.3</AspireVersion>
</PropertyGroup>

<ItemGroup>
<None Include="templates\**\*" />
</ItemGroup>

<!-- When building a package, this target will run to copy all the templates into the intermediate directory,
<!-- When building a package, this target will run to copy all the templates into the intermediate directory,
replaces the package versions, and adds them to the package.-->
<Target Name="AddTemplatesToPackageAsContent" DependsOnTargets="ReplacePackageVersionOnTemplates">
<!-- MauiAspire update: Use BeforeTargets="BeforeBuild" instead of Project InitialTargets to workaround https://github.com/dotnet/msbuild/issues/5178 -->
<Target Name="AddTemplatesToPackageAsContent" DependsOnTargets="ReplacePackageVersionOnTemplates" BeforeTargets="BeforeBuild">

<!-- Creating a temporary item instead of defining content items directly in order to avoid MSBuild MSB4120
message shown when an item within a target references itself which may cuase unintended expansion. -->
Expand All @@ -34,16 +36,16 @@
</Target>

<!-- Replaces the versions referenced by the templates projects to use the version of the packages being live-built -->
<Target Name="ReplacePackageVersionOnTemplates" DependsOnTargets="CopyTemplatesToIntermediateOutputPath">
<Target Name="ReplacePackageVersionOnTemplates" DependsOnTargets="CopyTemplatesToIntermediateOutputPath;GetBuildVersion">

<ItemGroup>
<TemplateProjectFiles Include="templates\**\*.csproj" />
<TemplateProjectFiles>
<DestinationFile>$(IntermediateOutputPath)\content\templates\%(RecursiveDir)%(Filename)%(Extension)</DestinationFile>
</TemplateProjectFiles>
</ItemGroup>

<WriteLinesToFile File="%(TemplateProjectFiles.DestinationFile)" Lines="$([System.IO.File]::ReadAllText('%(TemplateProjectFiles.FullPath)')&#xD;&#xA; .Replace('!!REPLACE_WITH_LATEST_VERSION!!', '$(PackageVersion)')&#xD;&#xA; .Replace('!!REPLACE_WITH_EXTENSIONS_VERSION!!', '$(MicrosoftExtensionsHttpResiliencePackageVersion)'))" Overwrite="true" />
<WriteLinesToFile File="%(TemplateProjectFiles.DestinationFile)" Lines="$([System.IO.File]::ReadAllText('%(TemplateProjectFiles.FullPath)')&#xD;&#xA; .Replace('!!REPLACE_WITH_LATEST_VERSION!!', '$(PackageVersion)')&#xD;&#xA; .Replace('!!REPLACE_WITH_ASPIRE_VERSION!!', '$(AspireVersion)')&#xD;&#xA; .Replace('!!REPLACE_WITH_EXTENSIONS_VERSION!!', '$(MicrosoftExtensionsHttpResiliencePackageVersion)'))" Overwrite="true" />
</Target>

<!-- Grabs the contents of the templates folder and copies them to IntermediateOutputPath directory -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"DB7A3AC1-6E4F-4805-B710-2FCD1084E96E",
"9FEB877E-015D-4E20-AE63-06C596E242E4",
"AC2DB38C-F5AD-4CEF-BC4C-04AE6EE86C9F",
"8757E021-D0C4-4DAD-836D-4C5F3F8350BA",
"EB6E56D3-85C9-43D0-A65C-775F4C780950"
],
"sources": [
Expand Down Expand Up @@ -266,6 +267,37 @@
"datatype": "bool",
"defaultValue": "true",
"description": "Whether to turn off HTTPS."
},

"applicationId": {
"type": "parameter",
"description": "Overrides the $(ApplicationId) in the project",
"datatype": "string"
},
"defaultAppId": {
"type": "generated",
"generator": "join",
"parameters": {
"symbols": [
{
"type": "const",
"value": "com.companyname."
},
{
"type": "ref",
"value": "nameToAppId"
}
]
}
},
"finalAppId": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "applicationId",
"fallbackVariableName": "defaultAppId"
},
"replaces": "com.companyname.mauiapp"
}
},
"primaryOutputs": [
Expand All @@ -284,6 +316,9 @@
},
{
"path": "AspireStarterApplication.1.Web\\AspireStarterApplication.1.Web.csproj"
},
{
"path": "AspireStarterApplication.1.MauiApp\\AspireStarterApplication.1.MauiApp.csproj"
}
],
"postActions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="!!REPLACE_WITH_LATEST_VERSION!!" />
<PackageReference Include="Aspire.Hosting" Version="!!REPLACE_WITH_ASPIRE_VERSION!!" />
<PackageReference Include="MauiAspire.Hosting" Version="!!REPLACE_WITH_LATEST_VERSION!!" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public static class AspireAppSettings
["services:apiservice:0"] = "http://_http.localhost:5303",
["services:apiservice:1"] = "http://localhost:5303",
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@

<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<OutputType>Exe</OutputType>
<RootNamespace>ClientAppsIntegration.MAUI</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>ClientAppsIntegration.MAUI</ApplicationTitle>
<ApplicationTitle>MauiApp.1</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.clientappsintegration.maui</ApplicationId>
<ApplicationId>com.companyname.mauiapp</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
Expand Down Expand Up @@ -74,11 +73,10 @@
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>
<PackageReference Include="MauiAspire.App" Version="!!REPLACE_WITH_LATEST_VERSION!!" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AspireAppClientIntegration.MAUI\AspireAppClientIntegration.MAUI.csproj" />
<ProjectReference Include="..\ClientAppsIntegration.AppDefaults\ClientAppsIntegration.AppDefaults.csproj" />
<ItemGroup>
<ProjectReference Include="..\AspireStarterApplication.1.ServiceDefaults\AspireStarterApplication.1.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="!!REPLACE_WITH_EXTENSIONS_VERSION!!" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="!!REPLACE_WITH_LATEST_VERSION!!" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.1.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="!!REPLACE_WITH_ASPIRE_VERSION!!" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0-alpha.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.6.0-beta.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<!--#if (UseRedisCache) -->
<ItemGroup>
<PackageReference Include="Aspire.StackExchange.Redis.OutputCaching" Version="!!REPLACE_WITH_LATEST_VERSION!!" />
<PackageReference Include="Aspire.StackExchange.Redis.OutputCaching" Version="!!REPLACE_WITH_ASPIRE_VERSION!!" />
</ItemGroup>

<!--#endif -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspireStarterApplication.1.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspireStarterApplication.1.Web", "AspireStarterApplication.1.Web\AspireStarterApplication.1.Web.csproj", "{AC2DB38C-F5AD-4CEF-BC4C-04AE6EE86C9F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspireStarterApplication.1.MauiApp", "AspireStarterApplication.1.Web\AspireStarterApplication.1.Web.csproj", "{8757E021-D0C4-4DAD-836D-4C5F3F8350BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -32,6 +34,10 @@ Global
{AC2DB38C-F5AD-4CEF-BC4C-04AE6EE86C9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC2DB38C-F5AD-4CEF-BC4C-04AE6EE86C9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC2DB38C-F5AD-4CEF-BC4C-04AE6EE86C9F}.Release|Any CPU.Build.0 = Release|Any CPU
{8757E021-D0C4-4DAD-836D-4C5F3F8350BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8757E021-D0C4-4DAD-836D-4C5F3F8350BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8757E021-D0C4-4DAD-836D-4C5F3F8350BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8757E021-D0C4-4DAD-836D-4C5F3F8350BA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit ebdded9

Please sign in to comment.