Adds per-platform release artifacts and release image validation

This commit is contained in:
BinaryAlley committed 2026-11-30 21:20:42 +02:00
1 parent 92ab62011e
commit 68143dff25
19 files changed
+603 -115

No files matched your search

+10 -13
View File
@@ -45,7 +45,16 @@ jobs:
env: env:
SixLaborsLicenseKey: ${{ secrets.SIXLABORS_LICENSE_KEY }} SixLaborsLicenseKey: ${{ secrets.SIXLABORS_LICENSE_KEY }}
RELEASE_BRANCH: ${{ github.ref_name }} RELEASE_BRANCH: ${{ github.ref_name }}
run: dotnet msbuild build/build.proj -t:RecordBundledPlugins -p:Configuration=Release -p:OfficialReleaseBuild=true -p:AllowBundledPluginsRecording=true -p:ReleaseBranch="$RELEASE_BRANCH" run: |
release_version="${RELEASE_BRANCH#release/}"
dotnet msbuild build/build.proj -t:RecordBundledPlugins -p:Configuration=Release -p:OfficialReleaseBuild=true -p:AllowBundledPluginsRecording=true -p:ReleaseBranch="$RELEASE_BRANCH" -p:Version="$release_version"
# Upload the verified archives before the image step, so a Docker failure does not discard successfully built archives.
- name: Upload release archives
uses: actions/upload-artifact@v4
with:
name: release-archives
path: bin/release/*
if-no-files-found: error
# Reuse the verified publish output, so the images contain exactly the plugin binaries whose hashes were recorded. # Reuse the verified publish output, so the images contain exactly the plugin binaries whose hashes were recorded.
- name: Build release images - name: Build release images
env: env:
@@ -53,18 +62,6 @@ jobs:
run: | run: |
release_version="${RELEASE_BRANCH#release/}" release_version="${RELEASE_BRANCH#release/}"
dotnet msbuild build/build.proj -t:Docker -p:Configuration=Release -p:OfficialReleaseBuild=true -p:ReusePublishedBundledPlugins=true -p:Version="$release_version" dotnet msbuild build/build.proj -t:Docker -p:Configuration=Release -p:OfficialReleaseBuild=true -p:ReusePublishedBundledPlugins=true -p:Version="$release_version"
- name: Upload release server files
uses: actions/upload-artifact@v4
with:
name: release-api
path: bin/api/publish
if-no-files-found: error
- name: Upload release web files
uses: actions/upload-artifact@v4
with:
name: release-web
path: bin/web/publish
if-no-files-found: error
- name: Upload bundled plugin manifest - name: Upload bundled plugin manifest
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
+51
View File
@@ -0,0 +1,51 @@
<Project>
<!-- The runtime identifiers the release supports and the archive name for each one. The PDF plugin native validation, the publish loop, verification and archive naming all read this single item list. -->
<ItemGroup>
<BundledPluginRuntime Include="win-x64">
<ReleaseArchiveStem>windows-x64</ReleaseArchiveStem>
<ReleaseArchiveExtension>.zip</ReleaseArchiveExtension>
</BundledPluginRuntime>
<BundledPluginRuntime Include="win-x86">
<ReleaseArchiveStem>windows-x86</ReleaseArchiveStem>
<ReleaseArchiveExtension>.zip</ReleaseArchiveExtension>
</BundledPluginRuntime>
<BundledPluginRuntime Include="win-arm64">
<ReleaseArchiveStem>windows-arm64</ReleaseArchiveStem>
<ReleaseArchiveExtension>.zip</ReleaseArchiveExtension>
</BundledPluginRuntime>
<BundledPluginRuntime Include="linux-x64">
<ReleaseArchiveStem>linux-x64</ReleaseArchiveStem>
<ReleaseArchiveExtension>.tar.gz</ReleaseArchiveExtension>
</BundledPluginRuntime>
<BundledPluginRuntime Include="linux-arm64">
<ReleaseArchiveStem>linux-arm64</ReleaseArchiveStem>
<ReleaseArchiveExtension>.tar.gz</ReleaseArchiveExtension>
</BundledPluginRuntime>
<BundledPluginRuntime Include="linux-musl-x64">
<ReleaseArchiveStem>linux-musl-x64</ReleaseArchiveStem>
<ReleaseArchiveExtension>.tar.gz</ReleaseArchiveExtension>
</BundledPluginRuntime>
<BundledPluginRuntime Include="osx-x64">
<ReleaseArchiveStem>macos-x64</ReleaseArchiveStem>
<ReleaseArchiveExtension>.tar.gz</ReleaseArchiveExtension>
</BundledPluginRuntime>
<BundledPluginRuntime Include="osx-arm64">
<ReleaseArchiveStem>macos-arm64</ReleaseArchiveStem>
<ReleaseArchiveExtension>.tar.gz</ReleaseArchiveExtension>
</BundledPluginRuntime>
</ItemGroup>
<!-- The native runtime folders each release must contain. A shared family fallback is listed once per runtime that uses it. The list must match the folders the bundled plugins deploy: verification fails when a declared folder is missing from the staging folder or when the staging folder contains an undeclared folder. -->
<ItemGroup>
<BundledPluginRuntimeDirectory Include="win-x64" RuntimeIdentifier="win-x64" />
<BundledPluginRuntimeDirectory Include="win-x86" RuntimeIdentifier="win-x86" />
<BundledPluginRuntimeDirectory Include="win-arm64" RuntimeIdentifier="win-arm64" />
<BundledPluginRuntimeDirectory Include="linux-x64" RuntimeIdentifier="linux-x64" />
<BundledPluginRuntimeDirectory Include="linux-arm64" RuntimeIdentifier="linux-arm64" />
<BundledPluginRuntimeDirectory Include="linux-musl-x64" RuntimeIdentifier="linux-musl-x64" />
<BundledPluginRuntimeDirectory Include="osx-x64" RuntimeIdentifier="osx-x64" />
<BundledPluginRuntimeDirectory Include="osx" RuntimeIdentifier="osx-x64" />
<BundledPluginRuntimeDirectory Include="osx-arm64" RuntimeIdentifier="osx-arm64" />
<BundledPluginRuntimeDirectory Include="osx" RuntimeIdentifier="osx-arm64" />
</ItemGroup>
</Project>
+343 -29
View File
@@ -1,5 +1,6 @@
<Project DefaultTargets="CI"> <Project DefaultTargets="CI">
<Import Project="$(MSBuildThisFileDirectory)BundledPlugins.props" /> <Import Project="$(MSBuildThisFileDirectory)BundledPlugins.props" />
<Import Project="$(MSBuildThisFileDirectory)RuntimeIdentifiers.props" />
<PropertyGroup> <PropertyGroup>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..'))</RepoRoot> <RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..'))</RepoRoot>
@@ -7,14 +8,41 @@
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration> <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<ApiPublishDirectory>$(RepoRoot)/bin/api/publish</ApiPublishDirectory> <ApiPublishDirectory>$(RepoRoot)/bin/api/publish</ApiPublishDirectory>
<WebPublishDirectory>$(RepoRoot)/bin/web/publish</WebPublishDirectory> <WebPublishDirectory>$(RepoRoot)/bin/web/publish</WebPublishDirectory>
<!-- The per-runtime archives that are attached to a GitHub release. -->
<ReleaseArchivesDirectory>$(RepoRoot)/bin/release</ReleaseArchivesDirectory>
<!-- Archive verification extracts into its own folder, outside the uploaded release root, so an interrupted verification cannot leak scratch files into the release archives artifact. -->
<ReleaseArchiveVerificationDirectory>$(RepoRoot)/bin/release-verify</ReleaseArchiveVerificationDirectory>
<ReleaseVersion Condition="'$(ReleaseVersion)' == ''">$(Version)</ReleaseVersion>
<ReleaseVersion Condition="'$(ReleaseVersion)' == ''">0.0.0-dev</ReleaseVersion>
<!-- The version is embedded in archive names and tar commands, so only a three-part version or the development default is accepted. -->
<_ReleaseVersionPattern>^([0-9]+\.[0-9]+\.[0-9]+|0\.0\.0-dev)$</_ReleaseVersionPattern>
<!-- The Docker image tag, which defaults to latest for local images. -->
<_ImageVersion Condition="'$(Version)' != ''">$(Version)</_ImageVersion>
<_ImageVersion Condition="'$(Version)' == ''">latest</_ImageVersion>
<!-- The shared plugin staging folder is outside the release root, so it is never uploaded with the release. -->
<BundledPluginsPublishDirectory>$(RepoRoot)/bin/api/bundled-plugins</BundledPluginsPublishDirectory>
<!-- The runtime used for the Docker images and for the published manifest verification. -->
<ApiReleaseRuntimeIdentifier Condition="'$(ApiReleaseRuntimeIdentifier)' == ''">linux-x64</ApiReleaseRuntimeIdentifier>
<!-- Official images copy a published folder into a base image of the same architecture, so each glibc Linux runtime maps to its Docker platform. -->
<_DockerPlatform Condition="'$(ApiReleaseRuntimeIdentifier)' == 'linux-x64'">linux/amd64</_DockerPlatform>
<_DockerPlatform Condition="'$(ApiReleaseRuntimeIdentifier)' == 'linux-arm64'">linux/arm64</_DockerPlatform>
<BundledPluginsCurrentManifest Condition="'$(BundledPluginsCurrentManifest)' == ''">$(RepoRoot)/bin/api/BundledPlugins.current.manifest</BundledPluginsCurrentManifest> <BundledPluginsCurrentManifest Condition="'$(BundledPluginsCurrentManifest)' == ''">$(RepoRoot)/bin/api/BundledPlugins.current.manifest</BundledPluginsCurrentManifest>
<BundledPluginsSolution Condition="'$(BundledPluginsSolution)' == ''">$(MSBuildThisFileDirectory)obj/BundledPlugins.slnx</BundledPluginsSolution> <BundledPluginsSolution Condition="'$(BundledPluginsSolution)' == ''">$(MSBuildThisFileDirectory)obj/BundledPlugins.slnx</BundledPluginsSolution>
<_OfficialReleaseBuild Condition="'$(OfficialReleaseBuild)' == ''">false</_OfficialReleaseBuild> <_OfficialReleaseBuild Condition="'$(OfficialReleaseBuild)' == ''">false</_OfficialReleaseBuild>
<_OfficialReleaseBuild Condition="'$(OfficialReleaseBuild)' != ''">$(OfficialReleaseBuild)</_OfficialReleaseBuild> <_OfficialReleaseBuild Condition="'$(OfficialReleaseBuild)' != ''">$(OfficialReleaseBuild)</_OfficialReleaseBuild>
<_DockerDependsOn>Build</_DockerDependsOn> <_DockerDependsOn>Build</_DockerDependsOn>
<_DockerDependsOn Condition="'$(_OfficialReleaseBuild)' == 'true'">ValidateDockerRelease;VerifyPublishedBundledPlugins</_DockerDependsOn> <_DockerDependsOn Condition="'$(_OfficialReleaseBuild)' == 'true'">ValidateDockerRelease;VerifyPublishedBundledPlugins</_DockerDependsOn>
<!-- A reused publish output was verified by the preceding publish step, so verifying it again only repeats the work. -->
<_DockerDependsOn Condition="'$(_OfficialReleaseBuild)' == 'true' And '$(ReusePublishedBundledPlugins)' == 'true'">ValidateDockerRelease</_DockerDependsOn>
<!-- Local images build for the host so docker compose keeps working; only release images pin the platform of the published folder they copy. -->
<_DockerPlatformOption Condition="'$(_OfficialReleaseBuild)' == 'true'">--platform &quot;$(_DockerPlatform)&quot; </_DockerPlatformOption>
</PropertyGroup> </PropertyGroup>
<!-- Defined once because Publish and the verification targets run in the same project instance during RecordBundledPlugins. -->
<ItemGroup>
<_ReleaseRuntime Include="@(BundledPluginRuntime)" />
</ItemGroup>
<Target Name="Restore"> <Target Name="Restore">
<Exec Command="dotnet restore &quot;$(Solution)&quot;" /> <Exec Command="dotnet restore &quot;$(Solution)&quot;" />
<PropertyGroup> <PropertyGroup>
@@ -50,7 +78,7 @@
</Target> </Target>
<Target Name="BuildBundledPlugins" DependsOnTargets="PrepareBundledPluginsSolution;RestoreBundledPlugins"> <Target Name="BuildBundledPlugins" DependsOnTargets="PrepareBundledPluginsSolution;RestoreBundledPlugins">
<Exec Command="dotnet build &quot;$(BundledPluginsSolution)&quot; -c $(Configuration) --no-restore -p:NemeraPluginsOutputDirectory=&quot;$(NemeraPluginsOutputDirectory)&quot;" WorkingDirectory="$(RepoRoot)" /> <Exec Command="dotnet build &quot;$(BundledPluginsSolution)&quot; -c $(Configuration) --no-restore -p:NemeraPluginsOutputDirectory=&quot;$(NemeraPluginsOutputDirectory)&quot; -p:OfficialReleaseBuild=$(_OfficialReleaseBuild)" WorkingDirectory="$(RepoRoot)" />
</Target> </Target>
<!-- The first official build needs a current manifest file to embed. The real manifest is generated from the deployed plugins after the solution build. --> <!-- The first official build needs a current manifest file to embed. The real manifest is generated from the deployed plugins after the solution build. -->
@@ -93,61 +121,347 @@
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="Publish" Condition="'$(ReusePublishedBundledPlugins)' != 'true' And '$(_PublishedBundledPlugins)' != 'true'" /> <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="Publish" Condition="'$(ReusePublishedBundledPlugins)' != 'true' And '$(_PublishedBundledPlugins)' != 'true'" />
</Target> </Target>
<!-- Verifies the manifest embedded in the published API assembly against the plugin binaries that were actually published. --> <!-- The catalog is the source of truth, so the staging folder must contain exactly the native runtime folders it declares. This fails the build when a dependency starts or stops deploying a folder. -->
<Target Name="VerifyPublishedBundledPlugins" DependsOnTargets="EnsurePublishedBundledPlugins"> <Target Name="VerifyStagingNativeRuntimeDirectories" DependsOnTargets="EnsurePublishedBundledPlugins">
<Error Condition="!Exists('$(ApiPublishDirectory)/Nemera.Presentation.Api.dll')" Text="The published API assembly is missing from '$(ApiPublishDirectory)'." /> <ItemGroup>
<Error Condition="!Exists('$(ApiPublishDirectory)/plugins')" Text="The published bundled plugins are missing from '$(ApiPublishDirectory)/plugins'." /> <_StagingNativeRuntimeDirectory Include="$([System.IO.Directory]::GetDirectories('$(BundledPluginsPublishDirectory)/runtimes'))" Condition="Exists('$(BundledPluginsPublishDirectory)/runtimes')" />
<Exec Command="dotnet test &quot;$(Solution)&quot; -c $(Configuration) --no-build --filter &quot;FullyQualifiedName~PublishedBundledPluginManifest&quot;" EnvironmentVariables="NEMERA_API_PUBLISH_DIRECTORY=$(ApiPublishDirectory)" /> <_DeclaredStagingNativeRuntimeDirectory Include="@(BundledPluginRuntimeDirectory->'$(BundledPluginsPublishDirectory)/runtimes/%(Identity)')" />
</ItemGroup>
<!-- A shared fallback folder is declared once per runtime that uses it, so deduplicate the expected list before it is reported. -->
<RemoveDuplicates Inputs="@(_DeclaredStagingNativeRuntimeDirectory)">
<Output TaskParameter="Filtered" ItemName="_ExpectedStagingNativeRuntimeDirectory" />
</RemoveDuplicates>
<ItemGroup>
<_MissingStagingNativeRuntimeDirectory Include="@(_ExpectedStagingNativeRuntimeDirectory)" Condition="!Exists('%(FullPath)')" />
<_UnexpectedStagingNativeRuntimeDirectory Include="@(_StagingNativeRuntimeDirectory)" Exclude="@(_ExpectedStagingNativeRuntimeDirectory)" />
</ItemGroup>
<Error Condition="'@(_MissingStagingNativeRuntimeDirectory)' != ''" Text="The bundled plugin staging folder is missing native runtime folders that build/RuntimeIdentifiers.props declares: @(_MissingStagingNativeRuntimeDirectory)" />
<Error Condition="'@(_UnexpectedStagingNativeRuntimeDirectory)' != ''" Text="The bundled plugin staging folder contains native runtime folders that build/RuntimeIdentifiers.props does not declare: @(_UnexpectedStagingNativeRuntimeDirectory)" />
</Target>
<!-- Verifies every published runtime folder: assemblies, apphosts, plugins, native folders and files, the embedded plugin manifest, and the plugin binaries that the trust list records. Archive checks live in VerifyReleaseArchives. -->
<Target Name="VerifyPublishedBundledPlugins" DependsOnTargets="EnsurePublishedBundledPlugins;VerifyStagingNativeRuntimeDirectories">
<PropertyGroup>
<_ApiReleaseDirectory>$(ApiPublishDirectory)/$(ApiReleaseRuntimeIdentifier)</_ApiReleaseDirectory>
</PropertyGroup>
<Error Condition="!Exists('$(_ApiReleaseDirectory)/Nemera.Presentation.Api.dll')" Text="The published API assembly is missing from '$(_ApiReleaseDirectory)'." />
<Error Condition="!Exists('$(_ApiReleaseDirectory)/plugins')" Text="The published bundled plugins are missing from '$(_ApiReleaseDirectory)/plugins'." />
<ItemGroup>
<_WindowsReleaseRuntime Include="@(_ReleaseRuntime)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('win-'))" />
<_UnixReleaseRuntime Include="@(_ReleaseRuntime)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('win-')) == false" />
<_ReleaseApiPath Include="@(_ReleaseRuntime->'$(ApiPublishDirectory)/%(Identity)/Nemera.Presentation.Api.dll')" />
<_ReleaseWebPath Include="@(_ReleaseRuntime->'$(WebPublishDirectory)/%(Identity)/Nemera.Presentation.Web.dll')" />
<_ReleaseApiAppHostPath Include="@(_WindowsReleaseRuntime->'$(ApiPublishDirectory)/%(Identity)/Nemera.Presentation.Api.exe')" />
<_ReleaseApiAppHostPath Include="@(_UnixReleaseRuntime->'$(ApiPublishDirectory)/%(Identity)/Nemera.Presentation.Api')" />
<_ReleaseWebAppHostPath Include="@(_WindowsReleaseRuntime->'$(WebPublishDirectory)/%(Identity)/Nemera.Presentation.Web.exe')" />
<_ReleaseWebAppHostPath Include="@(_UnixReleaseRuntime->'$(WebPublishDirectory)/%(Identity)/Nemera.Presentation.Web')" />
<_MissingReleaseApi Include="@(_ReleaseApiPath)" Condition="!Exists('%(FullPath)')" />
<_MissingReleaseWeb Include="@(_ReleaseWebPath)" Condition="!Exists('%(FullPath)')" />
<_MissingReleaseApiAppHost Include="@(_ReleaseApiAppHostPath)" Condition="!Exists('%(FullPath)')" />
<_MissingReleaseWebAppHost Include="@(_ReleaseWebAppHostPath)" Condition="!Exists('%(FullPath)')" />
<_ReleaseNativeRuntimeMapping Include="@(BundledPluginRuntimeDirectory)" />
<_ReleasePdb Include="$(ApiPublishDirectory)/**/*.pdb;$(WebPublishDirectory)/**/*.pdb" />
</ItemGroup>
<Error Condition="'@(_MissingReleaseApi)' != ''" Text="The release is missing the API assembly for these runtimes: @(_MissingReleaseApi)" />
<Error Condition="'@(_MissingReleaseWeb)' != ''" Text="The release is missing the web assembly for these runtimes: @(_MissingReleaseWeb)" />
<Error Condition="'@(_MissingReleaseApiAppHost)' != ''" Text="The release is missing the API executable for these runtimes: @(_MissingReleaseApiAppHost)" />
<Error Condition="'@(_MissingReleaseWebAppHost)' != ''" Text="The release is missing the web executable for these runtimes: @(_MissingReleaseWebAppHost)" />
<Error Condition="'@(_ReleasePdb)' != ''" Text="The release still contains PDB files: @(_ReleasePdb)" />
<!-- Verify that every bundled plugin project has an assembly in every published runtime folder. -->
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="VerifyReleasePluginAssemblies" Properties="ApiPublishDirectory=$(ApiPublishDirectory);BundledPluginReleaseRuntimeIdentifier=%(_ReleaseRuntime.Identity)" />
<!-- Verify the exact native runtime folders for every release, so a foreign OS or a foreign architecture of the same OS cannot pass. -->
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="VerifyReleaseRuntimeDirectories" Properties="ApiPublishDirectory=$(ApiPublishDirectory);BundledPluginsPublishDirectory=$(BundledPluginsPublishDirectory);BundledPluginReleaseRuntimeIdentifier=%(_ReleaseRuntime.Identity)" />
<!-- Verify every declared native folder file by file, including the destination architecture and its fallback folders. -->
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="VerifyReleaseRuntimeNativeFiles" Properties="ApiPublishDirectory=$(ApiPublishDirectory);BundledPluginsPublishDirectory=$(BundledPluginsPublishDirectory);BundledPluginReleaseRuntimeIdentifier=%(_ReleaseNativeRuntimeMapping.RuntimeIdentifier);BundledPluginRuntimeDirectoryName=%(_ReleaseNativeRuntimeMapping.Identity)" />
<!-- Verify the embedded manifest against every published API folder, not only the folder used by the Docker images. -->
<Exec Command="dotnet test &quot;$(RepoRoot)/tests/IntegrationTests/Nemera.Presentation.Api.IntegrationTests/Nemera.Presentation.Api.IntegrationTests.csproj&quot; -c $(Configuration) --no-build --filter &quot;FullyQualifiedName~PublishedBundledPluginManifest&quot;" EnvironmentVariables="NEMERA_API_PUBLISH_DIRECTORY=$(ApiPublishDirectory)/%(_ReleaseRuntime.Identity)" />
<!-- Every runtime folder must ship the same plugin binaries as the reference folder that the trust list records. -->
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="VerifyReleasePluginFiles" Properties="BundledPluginReleaseRuntimeIdentifier=%(_ReleaseRuntime.Identity);ReferencePluginsDirectory=$(ApiPublishDirectory)/$(ApiReleaseRuntimeIdentifier)/plugins;ReleasePluginsDirectory=$(ApiPublishDirectory)/%(_ReleaseRuntime.Identity)/plugins" />
</Target>
<!-- The Linux and macOS archives keep their executable bit, so they must be created and verified on Linux or macOS. -->
<Target Name="ValidateReleaseArchivesPlatform">
<Error Condition="'$(OS)' == 'Windows_NT'" Text="Linux and macOS archives must be created and verified on Linux or macOS, because Windows cannot store the executable bit. Run this target on a non-Windows host." />
</Target>
<!-- Verifies every platform archive, independently of the publish-folder checks, so Docker reuse does not require bin/release to exist. -->
<Target Name="VerifyReleaseArchives" DependsOnTargets="ValidateReleaseArchivesPlatform;EnsurePublishedBundledPlugins;CreateReleaseArchives">
<ItemGroup>
<_ReleaseApiArchive Include="@(_ReleaseRuntime->'$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(ReleaseArchiveStem)-api%(ReleaseArchiveExtension)')" />
<_ReleaseWebArchive Include="@(_ReleaseRuntime->'$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(ReleaseArchiveStem)-web%(ReleaseArchiveExtension)')" />
<_MissingReleaseApiArchive Include="@(_ReleaseApiArchive)" Condition="!Exists('%(FullPath)')" />
<_MissingReleaseWebArchive Include="@(_ReleaseWebArchive)" Condition="!Exists('%(FullPath)')" />
</ItemGroup>
<Error Condition="'@(_MissingReleaseApiArchive)' != ''" Text="The release is missing these API archives: @(_MissingReleaseApiArchive)" />
<Error Condition="'@(_MissingReleaseWebArchive)' != ''" Text="The release is missing these web archives: @(_MissingReleaseWebArchive)" />
<!-- Extract every archive and compare its files and hashes with the publish folder it was built from. -->
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="VerifyReleaseArchive" Properties="ReleaseArchivePath=$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(_ReleaseRuntime.ReleaseArchiveStem)-api%(_ReleaseRuntime.ReleaseArchiveExtension);ReleaseArchiveSourceDirectory=$(ApiPublishDirectory)/%(_ReleaseRuntime.Identity);ReleaseArchiveExtension=%(_ReleaseRuntime.ReleaseArchiveExtension);ReleaseArchiveAppHostFileName=Nemera.Presentation.Api;ReleaseArchiveVerificationDirectory=$(ReleaseArchiveVerificationDirectory)/%(_ReleaseRuntime.Identity)-api" />
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="VerifyReleaseArchive" Properties="ReleaseArchivePath=$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(_ReleaseRuntime.ReleaseArchiveStem)-web%(_ReleaseRuntime.ReleaseArchiveExtension);ReleaseArchiveSourceDirectory=$(WebPublishDirectory)/%(_ReleaseRuntime.Identity);ReleaseArchiveExtension=%(_ReleaseRuntime.ReleaseArchiveExtension);ReleaseArchiveAppHostFileName=Nemera.Presentation.Web;ReleaseArchiveVerificationDirectory=$(ReleaseArchiveVerificationDirectory)/%(_ReleaseRuntime.Identity)-web" />
</Target>
<!-- Verifies that one release contains exactly the native runtime folders that the catalog declares for it, so a folder that never reached the release cannot pass. -->
<Target Name="VerifyReleaseRuntimeDirectories">
<PropertyGroup>
<_ReleaseRuntimeDirectoryPath>$(ApiPublishDirectory)/$(BundledPluginReleaseRuntimeIdentifier)/plugins/runtimes</_ReleaseRuntimeDirectoryPath>
</PropertyGroup>
<Error Condition="!Exists('$(_ReleaseRuntimeDirectoryPath)')" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) is missing the native runtime folder '$(_ReleaseRuntimeDirectoryPath)'." />
<ItemGroup>
<_DeclaredRuntimeDirectory Include="@(BundledPluginRuntimeDirectory)" Condition="'%(BundledPluginRuntimeDirectory.RuntimeIdentifier)' == '$(BundledPluginReleaseRuntimeIdentifier)'" />
<_ExpectedRuntimeDirectory Include="@(_DeclaredRuntimeDirectory->'$(_ReleaseRuntimeDirectoryPath)/%(Identity)')" />
<_ActualRuntimeDirectory Include="$([System.IO.Directory]::GetDirectories('$(_ReleaseRuntimeDirectoryPath)'))" />
<_MissingRuntimeDirectory Include="@(_ExpectedRuntimeDirectory)" Condition="!Exists('%(FullPath)')" />
<_UnexpectedRuntimeDirectory Include="@(_ActualRuntimeDirectory)" Exclude="@(_ExpectedRuntimeDirectory)" />
</ItemGroup>
<Error Condition="'@(_DeclaredRuntimeDirectory)' == ''" Text="The runtime catalog declares no native runtime folders for $(BundledPluginReleaseRuntimeIdentifier)." />
<Error Condition="'@(_MissingRuntimeDirectory)' != ''" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) is missing native runtime folders: @(_MissingRuntimeDirectory)" />
<Error Condition="'@(_UnexpectedRuntimeDirectory)' != ''" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) contains unexpected native runtime folders: @(_UnexpectedRuntimeDirectory)" />
</Target>
<!-- Verifies that one declared native runtime folder in a release contains exactly the files from the bundled plugin staging folder, with identical hashes. -->
<Target Name="VerifyReleaseRuntimeNativeFiles">
<PropertyGroup>
<_NativeSourceDirectory>$(BundledPluginsPublishDirectory)/runtimes/$(BundledPluginRuntimeDirectoryName)</_NativeSourceDirectory>
<_NativeReleaseDirectory>$(ApiPublishDirectory)/$(BundledPluginReleaseRuntimeIdentifier)/plugins/runtimes/$(BundledPluginRuntimeDirectoryName)</_NativeReleaseDirectory>
</PropertyGroup>
<Error Condition="!Exists('$(_NativeSourceDirectory)')" Text="The bundled plugin staging folder is missing the native runtime directory '$(BundledPluginRuntimeDirectoryName)'." />
<ItemGroup>
<_NativeSourceFile Include="$(_NativeSourceDirectory)/**/*" />
<_NativeReleaseFile Include="@(_NativeSourceFile->'$(_NativeReleaseDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />
<_ActualNativeReleaseFile Include="$(_NativeReleaseDirectory)/**/*" />
<_MissingNativeReleaseFile Include="@(_NativeReleaseFile)" Condition="!Exists('%(FullPath)')" />
</ItemGroup>
<Error Condition="'@(_MissingNativeReleaseFile)' != ''" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) is missing native files: @(_MissingNativeReleaseFile)" />
<GetFileHash Files="@(_NativeSourceFile)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_NativeSourceFileHash" />
</GetFileHash>
<GetFileHash Files="@(_NativeReleaseFile)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_NativeReleaseFileHash" />
</GetFileHash>
<PropertyGroup>
<_NativeSourceHashList>@(_NativeSourceFileHash->'%(FileHash)')</_NativeSourceHashList>
<_NativeReleaseHashList>@(_NativeReleaseFileHash->'%(FileHash)')</_NativeReleaseHashList>
<_NativeSourceFileCount>@(_NativeSourceFile->Count())</_NativeSourceFileCount>
<_ActualNativeFileCount>@(_ActualNativeReleaseFile->Count())</_ActualNativeFileCount>
</PropertyGroup>
<Error Condition="'$(_NativeSourceHashList)' != '$(_NativeReleaseHashList)'" Text="The native files in the release for $(BundledPluginReleaseRuntimeIdentifier) do not match the bundled plugin staging folder." />
<Error Condition="'$(_NativeSourceFileCount)' != '$(_ActualNativeFileCount)'" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) contains an unexpected number of native files." />
</Target>
<!-- Verifies that every runtime folder contains an assembly for every bundled plugin project in the release catalog, so a plugin that never reached a published folder cannot pass. -->
<Target Name="VerifyReleasePluginAssemblies">
<ItemGroup>
<_ExpectedBundledPluginAssembly Include="@(BundledPluginProject->'$(ApiPublishDirectory)/$(BundledPluginReleaseRuntimeIdentifier)/plugins/%(Filename).dll')" />
<_MissingBundledPluginAssembly Include="@(_ExpectedBundledPluginAssembly)" Condition="!Exists('%(FullPath)')" />
</ItemGroup>
<Error Condition="'@(BundledPluginProject)' == ''" Text="The bundled plugin catalog is empty." />
<Error Condition="'@(_MissingBundledPluginAssembly)' != ''" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) is missing bundled plugin assemblies: @(_MissingBundledPluginAssembly)" />
</Target>
<!-- Verifies that one release folder contains exactly the same plugin binaries as the reference published folder that the trust list records. -->
<Target Name="VerifyReleasePluginFiles">
<ItemGroup>
<_ReferencePluginAssembly Include="$(ReferencePluginsDirectory)/Nemera.Plugins.*.dll" />
<_ReleasePluginAssembly Include="@(_ReferencePluginAssembly->'$(ReleasePluginsDirectory)/%(Filename)%(Extension)')" />
<_ActualReleasePluginAssembly Include="$(ReleasePluginsDirectory)/Nemera.Plugins.*.dll" />
<_MissingReleasePluginAssembly Include="@(_ReleasePluginAssembly)" Condition="!Exists('%(FullPath)')" />
<_UnexpectedReleasePluginAssembly Include="@(_ActualReleasePluginAssembly)" Exclude="@(_ReleasePluginAssembly)" />
</ItemGroup>
<Error Condition="'@(_ReferencePluginAssembly)' == ''" Text="No plugin binaries were found in the reference published folder '$(ReferencePluginsDirectory)'." />
<Error Condition="'@(_MissingReleasePluginAssembly)' != ''" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) is missing plugin binaries: @(_MissingReleasePluginAssembly)" />
<Error Condition="'@(_UnexpectedReleasePluginAssembly)' != ''" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) contains unexpected plugin binaries: @(_UnexpectedReleasePluginAssembly)" />
<GetFileHash Files="@(_ReferencePluginAssembly)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_ReferencePluginAssemblyHash" />
</GetFileHash>
<GetFileHash Files="@(_ReleasePluginAssembly)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_ReleasePluginAssemblyHash" />
</GetFileHash>
<PropertyGroup>
<_ReferencePluginAssemblyCount>@(_ReferencePluginAssembly->Count())</_ReferencePluginAssemblyCount>
<_ActualReleasePluginAssemblyCount>@(_ActualReleasePluginAssembly->Count())</_ActualReleasePluginAssemblyCount>
<_ReferencePluginAssemblyHashList>@(_ReferencePluginAssemblyHash->'%(FileHash)')</_ReferencePluginAssemblyHashList>
<_ReleasePluginAssemblyHashList>@(_ReleasePluginAssemblyHash->'%(FileHash)')</_ReleasePluginAssemblyHashList>
</PropertyGroup>
<Error Condition="'$(_ReferencePluginAssemblyCount)' != '$(_ActualReleasePluginAssemblyCount)'" Text="The release for $(BundledPluginReleaseRuntimeIdentifier) contains an unexpected number of plugin binaries." />
<Error Condition="'$(_ReferencePluginAssemblyHashList)' != '$(_ReleasePluginAssemblyHashList)'" Text="The plugin binaries in the release for $(BundledPluginReleaseRuntimeIdentifier) do not match the reference published folder." />
</Target>
<!-- Extracts one release archive and verifies that it contains exactly the files from its publish folder, including their hashes. -->
<Target Name="VerifyReleaseArchive">
<RemoveDir Directories="$(ReleaseArchiveVerificationDirectory)" Condition="Exists('$(ReleaseArchiveVerificationDirectory)')" />
<MakeDir Directories="$(ReleaseArchiveVerificationDirectory)" />
<Exec Condition="'$(ReleaseArchiveExtension)' == '.zip' And '$(OS)' == 'Windows_NT'" Command="tar -xf &quot;$(ReleaseArchivePath)&quot; -C &quot;$(ReleaseArchiveVerificationDirectory)&quot;" />
<Exec Condition="'$(ReleaseArchiveExtension)' == '.zip' And '$(OS)' != 'Windows_NT'" Command="unzip -q &quot;$(ReleaseArchivePath)&quot; -d &quot;$(ReleaseArchiveVerificationDirectory)&quot;" />
<Exec Condition="'$(ReleaseArchiveExtension)' == '.tar.gz'" Command="tar -xzf &quot;$(ReleaseArchivePath)&quot; -C &quot;$(ReleaseArchiveVerificationDirectory)&quot;" />
<!-- Linux and macOS archives must keep the app host executable, which Windows cannot store when it creates the archive. -->
<Exec Condition="'$(ReleaseArchiveExtension)' == '.tar.gz'" Command="tar -tvzf &quot;$(ReleaseArchivePath)&quot;" ConsoleToMSBuild="true" StandardOutputImportance="low">
<Output TaskParameter="ConsoleOutput" ItemName="_TarReleaseArchiveEntry" />
</Exec>
<ItemGroup>
<_ExecutableTarReleaseArchiveEntry Include="@(_TarReleaseArchiveEntry)" Condition="'$(ReleaseArchiveExtension)' == '.tar.gz' And $([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', '^-..x.*[ ./]$(ReleaseArchiveAppHostFileName)\s*$'))" />
</ItemGroup>
<Error Condition="'$(ReleaseArchiveExtension)' == '.tar.gz' And '$(ReleaseArchiveAppHostFileName)' == ''" Text="The release archive verification requires the app host file name of the archive." />
<Error Condition="'$(ReleaseArchiveExtension)' == '.tar.gz' And '$(ReleaseArchiveAppHostFileName)' != '' And '@(_ExecutableTarReleaseArchiveEntry)' == ''" Text="The release archive '$(ReleaseArchivePath)' does not store '$(ReleaseArchiveAppHostFileName)' with the executable bit, so it cannot be started after extraction. Create Linux and macOS archives on Linux or macOS." />
<ItemGroup>
<_ArchiveSourceFile Include="$(ReleaseArchiveSourceDirectory)/**/*" />
<_ArchiveExpectedFile Include="@(_ArchiveSourceFile->'$(ReleaseArchiveVerificationDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />
<_ArchiveExtractedFile Include="$(ReleaseArchiveVerificationDirectory)/**/*" />
<_MissingArchiveFile Include="@(_ArchiveExpectedFile)" Condition="!Exists('%(FullPath)')" />
</ItemGroup>
<Error Condition="'@(_MissingArchiveFile)' != ''" Text="The release archive '$(ReleaseArchivePath)' is missing files: @(_MissingArchiveFile)" />
<GetFileHash Files="@(_ArchiveSourceFile)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_ArchiveSourceFileHash" />
</GetFileHash>
<GetFileHash Files="@(_ArchiveExpectedFile)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_ArchiveVerificationFileHash" />
</GetFileHash>
<PropertyGroup>
<_ArchiveSourceHashList>@(_ArchiveSourceFileHash->'%(FileHash)')</_ArchiveSourceHashList>
<_ArchiveExtractedHashList>@(_ArchiveVerificationFileHash->'%(FileHash)')</_ArchiveExtractedHashList>
<_ArchiveSourceFileCount>@(_ArchiveSourceFile->Count())</_ArchiveSourceFileCount>
<_ArchiveExtractedFileCount>@(_ArchiveExtractedFile->Count())</_ArchiveExtractedFileCount>
</PropertyGroup>
<Error Condition="'$(_ArchiveSourceHashList)' != '$(_ArchiveExtractedHashList)'" Text="The release archive '$(ReleaseArchivePath)' does not match its publish folder." />
<Error Condition="'$(_ArchiveSourceFileCount)' != '$(_ArchiveExtractedFileCount)'" Text="The release archive '$(ReleaseArchivePath)' contains an unexpected number of files." />
<RemoveDir Directories="$(ReleaseArchiveVerificationDirectory)" Condition="Exists('$(ReleaseArchiveVerificationDirectory)')" />
</Target>
<!-- ApiReleaseRuntimeIdentifier selects the reference publish folder, the recorded hashes and the Docker context, so it must be one of the release catalog runtimes. -->
<Target Name="ValidateReleaseRuntimeIdentifier">
<ItemGroup>
<_UnknownReleaseRuntime Include="$(ApiReleaseRuntimeIdentifier)" Exclude="@(BundledPluginRuntime)" />
</ItemGroup>
<Error Condition="'@(_UnknownReleaseRuntime)' != ''" Text="ApiReleaseRuntimeIdentifier '$(ApiReleaseRuntimeIdentifier)' is not in the release runtime catalog. Use one of: @(BundledPluginRuntime)." />
</Target> </Target>
<!-- Official release configuration must be validated before any build or test work starts. --> <!-- Official release configuration must be validated before any build or test work starts. -->
<Target Name="ValidateOfficialRelease"> <Target Name="ValidateOfficialRelease" DependsOnTargets="ValidateReleaseRuntimeIdentifier">
<Error Condition="'$(OfficialReleaseBuild)' != 'true'" Text="The Publish target is reserved for official release builds. Pass -p:OfficialReleaseBuild=true." /> <Error Condition="'$(OfficialReleaseBuild)' != 'true'" Text="The Publish target is reserved for official release builds. Pass -p:OfficialReleaseBuild=true." />
<Error Condition="'$(Configuration)' != 'Release'" Text="Official releases must be published in the Release configuration." /> <Error Condition="'$(Configuration)' != 'Release'" Text="Official releases must be published in the Release configuration." />
</Target> </Target>
<Target Name="Publish" DependsOnTargets="ValidateOfficialRelease;VerifyBundledPlugins"> <!-- Publishes one framework-dependent folder per supported runtime, so every platform gets its native apphost and the bundled plugins, and then packages each folder into its own API and web archive. -->
<Target Name="Publish" DependsOnTargets="ValidateOfficialRelease;ValidateReleaseVersion;VerifyBundledPlugins">
<RemoveDir Directories="$(ApiPublishDirectory)" Condition="Exists('$(ApiPublishDirectory)')" /> <RemoveDir Directories="$(ApiPublishDirectory)" Condition="Exists('$(ApiPublishDirectory)')" />
<RemoveDir Directories="$(WebPublishDirectory)" Condition="Exists('$(WebPublishDirectory)')" /> <RemoveDir Directories="$(WebPublishDirectory)" Condition="Exists('$(WebPublishDirectory)')" />
<RemoveDir Directories="$(BundledPluginsPublishDirectory)" Condition="Exists('$(BundledPluginsPublishDirectory)')" />
<RemoveDir Directories="$(ReleaseArchivesDirectory)" Condition="Exists('$(ReleaseArchivesDirectory)')" />
<Error Condition="!Exists('$(BundledPluginsCurrentManifest)')" Text="The current bundled plugin manifest '$(BundledPluginsCurrentManifest)' is missing. Build the official plugins before publishing." /> <Error Condition="!Exists('$(BundledPluginsCurrentManifest)')" Text="The current bundled plugin manifest '$(BundledPluginsCurrentManifest)' is missing. Build the official plugins before publishing." />
<MakeDir Directories="$(ApiPublishDirectory)/plugins" /> <MakeDir Directories="$(BundledPluginsPublishDirectory)" />
<MSBuild Projects="@(BundledPluginProject)" Targets="Build" Properties="Configuration=$(Configuration);NemeraPluginsOutputDirectory=$(ApiPublishDirectory)/plugins/" /> <MSBuild Projects="@(BundledPluginProject)" Targets="Build" Properties="Configuration=$(Configuration);NemeraPluginsOutputDirectory=$(BundledPluginsPublishDirectory)/;OfficialReleaseBuild=$(_OfficialReleaseBuild)" />
<ItemGroup> <ItemGroup>
<_PublishedBundledPluginAssembly Include="$(ApiPublishDirectory)/plugins/Nemera.Plugins.*.dll" /> <_PublishedBundledPluginAssembly Include="$(BundledPluginsPublishDirectory)/Nemera.Plugins.*.dll" />
</ItemGroup> </ItemGroup>
<Error Condition="'@(_PublishedBundledPluginAssembly)' == ''" Text="No bundled plugin binaries were deployed to '$(ApiPublishDirectory)/plugins'." /> <Error Condition="'@(_PublishedBundledPluginAssembly)' == ''" Text="No bundled plugin binaries were deployed to '$(BundledPluginsPublishDirectory)'." />
<GetFileHash Files="@(_PublishedBundledPluginAssembly)" Algorithm="SHA256"> <GetFileHash Files="@(_PublishedBundledPluginAssembly)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_PublishedBundledPluginHash" /> <Output TaskParameter="Items" ItemName="_PublishedBundledPluginHash" />
</GetFileHash> </GetFileHash>
<WriteLinesToFile File="$(BundledPluginsCurrentManifest)" Lines="@(_PublishedBundledPluginHash->'%(Filename)%(Extension)|%(FileHash)')" Overwrite="true" WriteOnlyWhenDifferent="true" /> <WriteLinesToFile File="$(BundledPluginsCurrentManifest)" Lines="@(_PublishedBundledPluginHash->'%(Filename)%(Extension)|%(FileHash)')" Overwrite="true" WriteOnlyWhenDifferent="true" />
<Exec Command="dotnet publish &quot;$(RepoRoot)/src/Nemera.Presentation.Api/Nemera.Presentation.Api.csproj&quot; -c $(Configuration) -o &quot;$(ApiPublishDirectory)&quot; -p:OfficialReleaseBuild=true -p:BundledPluginsCurrentManifest=&quot;$(BundledPluginsCurrentManifest)&quot; -p:BundledPluginsPredeployed=true" /> <!-- Restore once for every runtime, so the publishes reuse a multi-RID assets file instead of leaving the last single-RID restore behind. The environment variable avoids passing semicolons as a global MSBuild property. -->
<Exec Command="dotnet publish &quot;$(RepoRoot)/src/Nemera.Presentation.Web/Nemera.Presentation.Web.csproj&quot; -c $(Configuration) -o &quot;$(WebPublishDirectory)&quot;" /> <Exec Condition="'$(OS)' == 'Windows_NT'" Command="set &quot;NEMERA_RELEASE_RUNTIME_IDENTIFIERS=@(_ReleaseRuntime)&quot; &amp;&amp; dotnet restore &quot;$(RepoRoot)/src/Nemera.Presentation.Api/Nemera.Presentation.Api.csproj&quot;" />
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="NEMERA_RELEASE_RUNTIME_IDENTIFIERS='@(_ReleaseRuntime)' dotnet restore &quot;$(RepoRoot)/src/Nemera.Presentation.Api/Nemera.Presentation.Api.csproj&quot;" />
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="set &quot;NEMERA_RELEASE_RUNTIME_IDENTIFIERS=@(_ReleaseRuntime)&quot; &amp;&amp; dotnet restore &quot;$(RepoRoot)/src/Nemera.Presentation.Web/Nemera.Presentation.Web.csproj&quot;" />
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="NEMERA_RELEASE_RUNTIME_IDENTIFIERS='@(_ReleaseRuntime)' dotnet restore &quot;$(RepoRoot)/src/Nemera.Presentation.Web/Nemera.Presentation.Web.csproj&quot;" />
<!-- Each publish produces the native launcher for that runtime: .exe on Windows, extensionless on Linux and macOS. -->
<Exec Command="dotnet publish &quot;$(RepoRoot)/src/Nemera.Presentation.Api/Nemera.Presentation.Api.csproj&quot; -c $(Configuration) --no-restore -r %(_ReleaseRuntime.Identity) --self-contained false -o &quot;$(ApiPublishDirectory)/%(_ReleaseRuntime.Identity)&quot; -p:OfficialReleaseBuild=true -p:BundledPluginsCurrentManifest=&quot;$(BundledPluginsCurrentManifest)&quot; -p:BundledPluginsPredeployed=true" />
<Exec Command="dotnet publish &quot;$(RepoRoot)/src/Nemera.Presentation.Web/Nemera.Presentation.Web.csproj&quot; -c $(Configuration) --no-restore -r %(_ReleaseRuntime.Identity) --self-contained false -o &quot;$(WebPublishDirectory)/%(_ReleaseRuntime.Identity)&quot;" />
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyBundledPluginsToReleaseRuntime" Properties="Configuration=$(Configuration);ApiPublishDirectory=$(ApiPublishDirectory);BundledPluginsPublishDirectory=$(BundledPluginsPublishDirectory);BundledPluginReleaseRuntimeIdentifier=%(_ReleaseRuntime.Identity)" />
<ItemGroup>
<!-- Release downloads do not need debug symbols. -->
<_PublishedPdb Include="$(ApiPublishDirectory)/**/*.pdb;$(WebPublishDirectory)/**/*.pdb" />
</ItemGroup>
<Delete Files="@(_PublishedPdb)" />
<PropertyGroup> <PropertyGroup>
<_PublishedBundledPlugins>true</_PublishedBundledPlugins> <_PublishedBundledPlugins>true</_PublishedBundledPlugins>
</PropertyGroup> </PropertyGroup>
</Target> </Target>
<!-- Official images must be Release builds, so they cannot bypass the release configuration or the manifest checks. --> <!-- Copies only the destination runtime and its declared native folders into one release folder, so a Windows release never contains Linux or macOS native libraries. -->
<Target Name="ValidateDockerRelease" Condition="'$(_OfficialReleaseBuild)' == 'true'"> <Target Name="CopyBundledPluginsToReleaseRuntime">
<Error Condition="'$(Configuration)' != 'Release'" Text="Official Docker images must be built in the Release configuration." /> <ItemGroup>
<!-- Everything outside runtimes is shared by all plugins and is always copied. -->
<_RuntimeBundledPluginSharedFile Include="$(BundledPluginsPublishDirectory)/**/*" Exclude="$(BundledPluginsPublishDirectory)/runtimes/**" />
<!-- The runtime catalog declares the native folders that belong to each release, including family fallbacks such as osx. -->
<_ReleaseNativeRuntimeDirectory Include="@(BundledPluginRuntimeDirectory)" Condition="'%(BundledPluginRuntimeDirectory.RuntimeIdentifier)' == '$(BundledPluginReleaseRuntimeIdentifier)'" />
</ItemGroup>
<Copy SourceFiles="@(_RuntimeBundledPluginSharedFile)" DestinationFiles="@(_RuntimeBundledPluginSharedFile->'$(ApiPublishDirectory)/$(BundledPluginReleaseRuntimeIdentifier)/plugins/%(RecursiveDir)%(Filename)%(Extension)')" />
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyBundledPluginRuntimeDirectory" Properties="Configuration=$(Configuration);ApiPublishDirectory=$(ApiPublishDirectory);BundledPluginsPublishDirectory=$(BundledPluginsPublishDirectory);BundledPluginReleaseRuntimeIdentifier=$(BundledPluginReleaseRuntimeIdentifier);BundledPluginRuntimeDirectoryName=%(_ReleaseNativeRuntimeDirectory.Identity)" />
</Target> </Target>
<!-- Official images ship the verified publish output. Local images build from source so docker compose keeps working without a prior publish. --> <!-- Copies one declared native runtime folder, for example osx, into the release folder of the runtime that needs it. -->
<Target Name="Docker" DependsOnTargets="$(_DockerDependsOn)"> <Target Name="CopyBundledPluginRuntimeDirectory">
<ItemGroup>
<_RuntimeBundledPluginNativeFile Include="$(BundledPluginsPublishDirectory)/runtimes/$(BundledPluginRuntimeDirectoryName)/**/*" />
</ItemGroup>
<Copy SourceFiles="@(_RuntimeBundledPluginNativeFile)" DestinationFiles="@(_RuntimeBundledPluginNativeFile->'$(ApiPublishDirectory)/$(BundledPluginReleaseRuntimeIdentifier)/plugins/runtimes/$(BundledPluginRuntimeDirectoryName)/%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
<!-- ReleaseVersion becomes the archive file name, so it is validated before any archive path or tar command uses it. -->
<Target Name="ValidateReleaseVersion">
<PropertyGroup>
<_ReleaseVersionIsValid>false</_ReleaseVersionIsValid>
<_ReleaseVersionIsValid Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(ReleaseVersion)', '$(_ReleaseVersionPattern)'))">true</_ReleaseVersionIsValid>
</PropertyGroup>
<Error Condition="'$(_ReleaseVersionIsValid)' != 'true'" Text="The release version '$(ReleaseVersion)' is invalid. Pass a three-part version such as 1.2.3, for example -p:Version=1.2.3." />
</Target>
<!-- Builds one API archive and one web archive per runtime from the publish output, so each download contains only that platform's files. It can run directly after a publish. -->
<Target Name="CreateReleaseArchives" AfterTargets="Publish" DependsOnTargets="ValidateReleaseVersion">
<ItemGroup>
<_ArchiveRuntime Include="@(BundledPluginRuntime)" />
<_ArchivePublishOutput Include="@(_ArchiveRuntime->'$(ApiPublishDirectory)/%(Identity)/Nemera.Presentation.Api.dll')" />
<_ArchivePublishOutput Include="@(_ArchiveRuntime->'$(WebPublishDirectory)/%(Identity)/Nemera.Presentation.Web.dll')" />
<_MissingArchivePublishOutput Include="@(_ArchivePublishOutput)" Condition="!Exists('%(FullPath)')" />
</ItemGroup>
<Error Condition="'@(_MissingArchivePublishOutput)' != ''" Text="The release archives cannot be created because the publish output is missing. Run the Publish target first, which also creates the archives: @(_MissingArchivePublishOutput)" />
<RemoveDir Directories="$(ReleaseArchivesDirectory)" Condition="Exists('$(ReleaseArchivesDirectory)')" />
<MakeDir Directories="$(ReleaseArchivesDirectory)" />
<!-- Windows cannot store the executable bit in a tar archive, so it must not create the Linux and macOS archives. -->
<Warning Condition="'$(OS)' == 'Windows_NT'" Text="Windows cannot store the executable bit in a tar archive, so the Linux and macOS archives are not created. Run the archive targets on Linux or macOS to create them." />
<!-- Windows archives are zip files. Linux and macOS archives are tar.gz so the executable permission survives the download. -->
<ZipDirectory SourceDirectory="$(ApiPublishDirectory)/%(_ArchiveRuntime.Identity)" DestinationFile="$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(_ArchiveRuntime.ReleaseArchiveStem)-api%(_ArchiveRuntime.ReleaseArchiveExtension)" Condition="'%(_ArchiveRuntime.ReleaseArchiveExtension)' == '.zip'" />
<ZipDirectory SourceDirectory="$(WebPublishDirectory)/%(_ArchiveRuntime.Identity)" DestinationFile="$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(_ArchiveRuntime.ReleaseArchiveStem)-web%(_ArchiveRuntime.ReleaseArchiveExtension)" Condition="'%(_ArchiveRuntime.ReleaseArchiveExtension)' == '.zip'" />
<Exec Command="tar -czf &quot;$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(_ArchiveRuntime.ReleaseArchiveStem)-api%(_ArchiveRuntime.ReleaseArchiveExtension)&quot; -C &quot;$(ApiPublishDirectory)/%(_ArchiveRuntime.Identity)&quot; ." Condition="'%(_ArchiveRuntime.ReleaseArchiveExtension)' == '.tar.gz' And '$(OS)' != 'Windows_NT'" />
<Exec Command="tar -czf &quot;$(ReleaseArchivesDirectory)/Nemera-$(ReleaseVersion)-%(_ArchiveRuntime.ReleaseArchiveStem)-web%(_ArchiveRuntime.ReleaseArchiveExtension)&quot; -C &quot;$(WebPublishDirectory)/%(_ArchiveRuntime.Identity)&quot; ." Condition="'%(_ArchiveRuntime.ReleaseArchiveExtension)' == '.tar.gz' And '$(OS)' != 'Windows_NT'" />
</Target>
<!-- Official images must be Release builds and must use a glibc Linux runtime, because the image base is a glibc distribution and copies the published folder of that architecture. -->
<Target Name="ValidateDockerRelease" Condition="'$(_OfficialReleaseBuild)' == 'true'" DependsOnTargets="ValidateReleaseRuntimeIdentifier">
<Error Condition="'$(Configuration)' != 'Release'" Text="Official Docker images must be built in the Release configuration." />
<ItemGroup>
<_DockerReleaseRuntime Include="linux-x64;linux-arm64" />
<_NonGlibcDockerReleaseRuntime Include="$(ApiReleaseRuntimeIdentifier)" Exclude="@(_DockerReleaseRuntime)" />
</ItemGroup>
<Error Condition="'@(_NonGlibcDockerReleaseRuntime)' != ''" Text="Official Docker images require a glibc Linux runtime identifier, because the image base is a glibc distribution. Use one of: @(_DockerReleaseRuntime). The linux-musl-x64 runtime cannot be used with these images." />
<Error Condition="'$(_DockerPlatform)' == ''" Text="No Docker platform is defined for ApiReleaseRuntimeIdentifier '$(ApiReleaseRuntimeIdentifier)'." />
<!-- A reused publish output skips the publish-folder verification, so at least require the folders the images are built from. -->
<Error Condition="'$(ReusePublishedBundledPlugins)' == 'true' And !Exists('$(ApiPublishDirectory)/$(ApiReleaseRuntimeIdentifier)/Nemera.Presentation.Api.dll')" Text="ReusePublishedBundledPlugins=true requires a published API folder at '$(ApiPublishDirectory)/$(ApiReleaseRuntimeIdentifier)'. Publish the release first." />
<Error Condition="'$(ReusePublishedBundledPlugins)' == 'true' And !Exists('$(WebPublishDirectory)/$(ApiReleaseRuntimeIdentifier)/Nemera.Presentation.Web.dll')" Text="ReusePublishedBundledPlugins=true requires a published web folder at '$(WebPublishDirectory)/$(ApiReleaseRuntimeIdentifier)'. Publish the release first." />
</Target>
<!-- The image tag comes from Version and is passed to docker build, so it must be a plain release version or the local latest default, never a shell fragment. -->
<Target Name="ValidateDockerImageVersion">
<PropertyGroup>
<_DockerImageVersionIsValid>false</_DockerImageVersionIsValid>
<_DockerImageVersionIsValid Condition="'$(_ImageVersion)' == 'latest'">true</_DockerImageVersionIsValid>
<_DockerImageVersionIsValid Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(_ImageVersion)', '$(_ReleaseVersionPattern)'))">true</_DockerImageVersionIsValid>
</PropertyGroup>
<Error Condition="'$(_DockerImageVersionIsValid)' != 'true'" Text="The Docker image version '$(Version)' is invalid. Pass a three-part version such as 1.2.3, for example -p:Version=1.2.3." />
</Target>
<!-- Official images build from a publish folder that the preceding step verified, and local images build from source so docker compose keeps working without a prior publish. -->
<Target Name="Docker" DependsOnTargets="ValidateDockerImageVersion;$(_DockerDependsOn)">
<PropertyGroup> <PropertyGroup>
<_ImageVersion Condition="'$(Version)' != ''">$(Version)</_ImageVersion>
<_ImageVersion Condition="'$(Version)' == ''">latest</_ImageVersion>
<_DockerApiDockerfile Condition="'$(_OfficialReleaseBuild)' == 'true'">$(RepoRoot)/src/Nemera.Presentation.Api/Dockerfile.release</_DockerApiDockerfile> <_DockerApiDockerfile Condition="'$(_OfficialReleaseBuild)' == 'true'">$(RepoRoot)/src/Nemera.Presentation.Api/Dockerfile.release</_DockerApiDockerfile>
<_DockerApiDockerfile Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)/src/Nemera.Presentation.Api/Dockerfile</_DockerApiDockerfile> <_DockerApiDockerfile Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)/src/Nemera.Presentation.Api/Dockerfile</_DockerApiDockerfile>
<_DockerApiContext Condition="'$(_OfficialReleaseBuild)' == 'true'">$(ApiPublishDirectory)</_DockerApiContext> <_DockerApiContext Condition="'$(_OfficialReleaseBuild)' == 'true'">$(ApiPublishDirectory)/$(ApiReleaseRuntimeIdentifier)</_DockerApiContext>
<_DockerApiContext Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)</_DockerApiContext> <_DockerApiContext Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)</_DockerApiContext>
<_DockerWebDockerfile Condition="'$(_OfficialReleaseBuild)' == 'true'">$(RepoRoot)/src/Nemera.Presentation.Web/Dockerfile.release</_DockerWebDockerfile> <_DockerWebDockerfile Condition="'$(_OfficialReleaseBuild)' == 'true'">$(RepoRoot)/src/Nemera.Presentation.Web/Dockerfile.release</_DockerWebDockerfile>
<_DockerWebDockerfile Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)/src/Nemera.Presentation.Web/Dockerfile</_DockerWebDockerfile> <_DockerWebDockerfile Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)/src/Nemera.Presentation.Web/Dockerfile</_DockerWebDockerfile>
<_DockerWebContext Condition="'$(_OfficialReleaseBuild)' == 'true'">$(WebPublishDirectory)</_DockerWebContext> <_DockerWebContext Condition="'$(_OfficialReleaseBuild)' == 'true'">$(WebPublishDirectory)/$(ApiReleaseRuntimeIdentifier)</_DockerWebContext>
<_DockerWebContext Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)</_DockerWebContext> <_DockerWebContext Condition="'$(_OfficialReleaseBuild)' != 'true'">$(RepoRoot)</_DockerWebContext>
</PropertyGroup> </PropertyGroup>
<Exec Command="docker build -t nemera-api:$(_ImageVersion) -f &quot;$(_DockerApiDockerfile)&quot; &quot;$(_DockerApiContext)&quot;" /> <Exec Command="docker build $(_DockerPlatformOption)-t &quot;nemera-api:$(_ImageVersion)&quot; -f &quot;$(_DockerApiDockerfile)&quot; &quot;$(_DockerApiContext)&quot;" />
<Exec Command="docker build -t nemera-web:$(_ImageVersion) -f &quot;$(_DockerWebDockerfile)&quot; &quot;$(_DockerWebContext)&quot;" /> <Exec Command="docker build $(_DockerPlatformOption)-t &quot;nemera-web:$(_ImageVersion)&quot; -f &quot;$(_DockerWebDockerfile)&quot; &quot;$(_DockerWebContext)&quot;" />
</Target> </Target>
<!-- Recording is only allowed from a clean GitHub Actions checkout whose commit is the current origin/master. --> <!-- Recording is only allowed from a clean GitHub Actions checkout whose commit is the current origin/master. -->
@@ -172,17 +486,17 @@
<Error Condition="'@(_BundledPluginsHead)' != '@(_BundledPluginsMasterHead)'" Text="Recording bundled plugin hashes requires the release branch to point at origin/master. Merge the previous trust-list pull request and recreate the release branch from master." /> <Error Condition="'@(_BundledPluginsHead)' != '@(_BundledPluginsMasterHead)'" Text="Recording bundled plugin hashes requires the release branch to point at origin/master. Merge the previous trust-list pull request and recreate the release branch from master." />
</Target> </Target>
<Target Name="RecordBundledPlugins" DependsOnTargets="ValidateBundledPluginsRecording;Publish;VerifyPublishedBundledPlugins;RecordBundledPluginsFromPublish" /> <Target Name="RecordBundledPlugins" DependsOnTargets="ValidateBundledPluginsRecording;Publish;VerifyPublishedBundledPlugins;VerifyReleaseArchives;RecordBundledPluginsFromPublish" />
<!-- VerifyPublishedBundledPlugins has already proved that the published plugin set exactly matches the embedded current manifest. --> <!-- VerifyPublishedBundledPlugins has already checked the embedded manifest against every published API folder and compared every runtime folder's plugin binaries with the reference folder, so the reference folder is representative of every shipped platform. -->
<Target Name="RecordBundledPluginsFromPublish" DependsOnTargets="ValidateOfficialRelease;ValidateBundledPluginsRecording;VerifyPublishedBundledPlugins"> <Target Name="RecordBundledPluginsFromPublish" DependsOnTargets="ValidateOfficialRelease;ValidateBundledPluginsRecording;VerifyPublishedBundledPlugins">
<ItemGroup> <ItemGroup>
<_BundledPluginPublishedAssembly Include="$(ApiPublishDirectory)/plugins/Nemera.Plugins.*.dll" /> <_BundledPluginPublishedAssembly Include="$(ApiPublishDirectory)/$(ApiReleaseRuntimeIdentifier)/plugins/Nemera.Plugins.*.dll" />
</ItemGroup> </ItemGroup>
<GetFileHash Files="@(_BundledPluginPublishedAssembly)" Algorithm="SHA256"> <GetFileHash Files="@(_BundledPluginPublishedAssembly)" Algorithm="SHA256">
<Output TaskParameter="Items" ItemName="_RecordedBundledPluginHash" /> <Output TaskParameter="Items" ItemName="_RecordedBundledPluginHash" />
</GetFileHash> </GetFileHash>
<Error Condition="'@(_RecordedBundledPluginHash)' == ''" Text="No bundled plugin binaries were found in '$(ApiPublishDirectory)/plugins'." /> <Error Condition="'@(_RecordedBundledPluginHash)' == ''" Text="No bundled plugin binaries were found in '$(ApiPublishDirectory)/$(ApiReleaseRuntimeIdentifier)/plugins'." />
<Error Condition="!Exists('$(BundledPluginsManifest)')" Text="The bundled plugin trust manifest '$(BundledPluginsManifest)' is missing." /> <Error Condition="!Exists('$(BundledPluginsManifest)')" Text="The bundled plugin trust manifest '$(BundledPluginsManifest)' is missing." />
<ReadLinesFromFile File="$(BundledPluginsManifest)"> <ReadLinesFromFile File="$(BundledPluginsManifest)">
<Output TaskParameter="Lines" ItemName="_ExistingBundledPluginManifestLine" /> <Output TaskParameter="Lines" ItemName="_ExistingBundledPluginManifestLine" />
+17 -4
View File
@@ -30,7 +30,7 @@ Everything from Configuration onward applies to whichever route you chose.
## Before you start ## Before you start
- **Docker**, if you want the container route. For a non-container install, you need the Nemera application files, from a release package or installer, or from your own build, plus the **.NET 10 runtime** unless that package is self-contained. The **.NET 10 SDK** is only needed if you build from source. - **Docker**, if you want the container route. For a non-container install, you need the Nemera application files, from a release package or installer, or from your own build, plus the **ASP.NET Core Runtime 10** unless that package is self-contained. The **.NET 10 SDK** is only needed if you build from source.
- **ffmpeg**, for any non-container install, however you obtained the application files. The API server uses it to remux or transcode audio that the browser cannot play as stored. The Docker API container image already includes it. - **ffmpeg**, for any non-container install, however you obtained the application files. The API server uses it to remux or transcode audio that the browser cannot play as stored. The Docker API container image already includes it.
- By default the **web client listens on port `5012`** and the **API on port `5214`**. You can change either, as long as the two agree on where the API is (see [Configuration](#configuration)). - By default the **web client listens on port `5012`** and the **API on port `5214`**. You can change either, as long as the two agree on where the API is (see [Configuration](#configuration)).
- For anything reachable beyond your own machine, put a **reverse proxy** in front to terminate TLS and forward to the web client. - For anything reachable beyond your own machine, put a **reverse proxy** in front to terminate TLS and forward to the web client.
@@ -86,12 +86,25 @@ Use a release package or installer when one is available, or, with the .NET 10 S
dotnet build Nemera.slnx dotnet build Nemera.slnx
``` ```
The official release artifacts include the PDF plugin's native libraries for Linux x64 and ARM64 (including Alpine x64), macOS Intel and Apple Silicon, and Windows x64 and ARM64. The single release download works on those platforms; the plugin loads the native libraries that match the host at runtime. The official release is split into one API archive and one web archive per platform and architecture. Download both archives for your platform:
Run the API and the web client from the installed release package or from the published build. In development, their addresses come from each project's `launchSettings.json` (`http://localhost:5214` and `http://localhost:5012`). When you run a published build directly on a host, set the addresses yourself, either with `ASPNETCORE_URLS` or with `ASPNETCORE_HTTP_PORTS`: | Platform | API archive | Web archive |
| --- | --- | --- |
| Linux x64 | `Nemera-<version>-linux-x64-api.tar.gz` | `Nemera-<version>-linux-x64-web.tar.gz` |
| Linux ARM64 | `Nemera-<version>-linux-arm64-api.tar.gz` | `Nemera-<version>-linux-arm64-web.tar.gz` |
| Linux x64 with musl, including Alpine | `Nemera-<version>-linux-musl-x64-api.tar.gz` | `Nemera-<version>-linux-musl-x64-web.tar.gz` |
| macOS Intel | `Nemera-<version>-macos-x64-api.tar.gz` | `Nemera-<version>-macos-x64-web.tar.gz` |
| macOS Apple Silicon | `Nemera-<version>-macos-arm64-api.tar.gz` | `Nemera-<version>-macos-arm64-web.tar.gz` |
| Windows x64 | `Nemera-<version>-windows-x64-api.zip` | `Nemera-<version>-windows-x64-web.zip` |
| Windows x86 | `Nemera-<version>-windows-x86-api.zip` | `Nemera-<version>-windows-x86-web.zip` |
| Windows ARM64 | `Nemera-<version>-windows-arm64-api.zip` | `Nemera-<version>-windows-arm64-web.zip` |
Each archive contains only the files for its platform and architecture. The API archive includes the bundled plugins and the PDF plugin's native libraries for that platform. Extract both archives into separate folders.
When using the release package, run the API and the web client from the folders you extracted. On Windows, start `Nemera.Presentation.Api.exe` and `Nemera.Presentation.Web.exe`. On Linux and macOS, start `./Nemera.Presentation.Api` and `./Nemera.Presentation.Web`. The API listens on `http://localhost:5214` and the web client on `http://localhost:5012` by default. Set `ASPNETCORE_URLS`, `ASPNETCORE_HTTP_PORTS` or `ASPNETCORE_HTTPS_PORTS` only when you need different addresses:
```bash ```bash
ASPNETCORE_HTTP_PORTS=5012 dotnet Nemera.Presentation.Web.dll ASPNETCORE_URLS=http://0.0.0.0:5012 ./Nemera.Presentation.Web
``` ```
The API creates its SQLite database (`Nemera.db`) next to its own binary and applies any pending migrations at startup, so the first launch sets up the schema on its own. The API creates its SQLite database (`Nemera.db`) next to its own binary and applies any pending migrations at startup, so the first launch sets up the schema on its own.
+23 -15
View File
@@ -19,15 +19,17 @@ Releases are cut only by the repository owner. There is one official build, and
1. The owner creates a `release/x.y.z` branch from `master`. 1. The owner creates a `release/x.y.z` branch from `master`.
2. The `Publish Release` workflow builds and publishes the official artifacts with `OfficialReleaseBuild=true`. 2. The `Publish Release` workflow builds and publishes the official artifacts with `OfficialReleaseBuild=true`.
3. The same workflow verifies the published API assembly against the published plugin binaries, records the release's plugin hashes in the append-only trust list, builds the release images from the verified publish output, and opens a pull request to `master`. 3. The same workflow verifies the embedded plugin manifest against every published API folder, records the release's plugin hashes in the append-only trust list, builds the release images from the verified publish output, and opens a pull request to `master`.
4. The owner downloads the official artifacts and creates the GitHub release and tag. 4. The owner downloads the release archives and creates the GitHub release and tag.
5. The owner merges the trust-list pull request. The current release already embeds its own official plugin manifest, so this pull request keeps the release's plugin binaries Official in future releases. 5. The owner merges the trust-list pull request. The current release already embeds its own official plugin manifest, so this pull request keeps the release's plugin binaries Official in future releases.
The full test suite runs on normal pull requests to `master`. The release build does not rerun the full suite. It runs the manifest verification tests for the official build, publishes, verifies the published API assembly against the published plugin binaries, records the hashes and builds the release images from the verified publish output. The full test suite runs on normal pull requests to `master`. The release build does not rerun the full suite. It runs the manifest verification tests for the official build, publishes, verifies the embedded plugin manifest against every published API folder, checks the native folders and files of every runtime, verifies every archive against its publish folder, records the hashes and builds the release images from the verified publish output.
The repository pins the .NET SDK in `global.json`. The workflows install that exact SDK, and the Docker build stage uses the matching `10.0.100` SDK image, so root-level and container builds use the same toolchain. The repository pins the .NET SDK in `global.json`. The workflows install that exact SDK, and the Docker build stage uses the matching `10.0.100` SDK image, so root-level and container builds use the same toolchain.
The `release-api` artifact is a single framework-dependent publish built on `ubuntu-latest`. The bundled plugin deployment keeps the PDF plugin's native libraries for the supported runtime identifiers: `win-x64`, `win-arm64`, `linux-x64`, `linux-arm64`, `linux-musl-x64`, `osx-x64` and `osx-arm64`. The macOS packages also keep their shared SkiaSharp library in the `osx` fallback folder, which the build retains automatically even though no device reports that identifier. The list is defined by `BundledPluginRuntimeIdentifiers` in `plugins/Directory.Build.props`, and the PDF plugin validates its required native libraries for every identifier in it, accepting a library from either the identifier's own folder or its OS family fallback. The plugin resolves the matching native library at runtime from its dependency manifest. The release Docker images copy that same publish output. The `Publish` target produces two archives for each supported runtime identifier: an API archive and a web archive. The names are `Nemera-<version>-<platform>-<architecture>-api.<extension>` and `Nemera-<version>-<platform>-<architecture>-web.<extension>`, for example `Nemera-1.2.3-linux-x64-web.tar.gz` and `Nemera-1.2.3-windows-x64-api.zip`. Windows archives are `.zip` files; Linux and macOS archives are `.tar.gz` files, so the executable permission survives the download. Each archive contains the application files, the native apphost and the native libraries for that runtime identifier only. The supported runtime identifiers are `linux-x64`, `linux-arm64`, `linux-musl-x64`, `osx-x64`, `osx-arm64`, `win-x64`, `win-x86` and `win-arm64`, and the workflow builds them all on `ubuntu-latest`. The API archive also contains the bundled plugins, so the API can run directly from the extracted folder. The plugin deployment copies only the native runtime folders the catalog declares for that runtime: the identifier's own folder and the shared `osx` folder for the macOS archives, so the PDF plugin's native libraries for the other operating systems are not shipped. The macOS archives keep their shared SkiaSharp library in the `osx` fallback folder, which the build retains automatically even though no device reports that identifier. The runtime list is defined by the `BundledPluginRuntime` items and the native folder mapping by `BundledPluginRuntimeDirectory` in `build/RuntimeIdentifiers.props`. The catalog must list exactly the folders the bundled plugins deploy: verification fails when the staging folder is missing a declared folder or contains an undeclared one, and each release must contain exactly the folders declared for its runtime identifier. The PDF plugin validates its required native libraries for every identifier in it, accepting a library from either the identifier's own folder or its OS family fallback. The plugin resolves the matching native library at runtime from its dependency manifest. Verification runs the embedded manifest test against every published API folder, requires exactly the declared native runtime folders and their files, and extracts every archive to compare its contents and hashes with the publish folder it was built from. The trust list records the published plugin hashes from the verified `linux-x64` folder; every other runtime folder is verified against the same embedded manifest and its plugin binaries are compared with that reference folder, so the recorded hashes describe every shipped platform. The publish output excludes `.pdb` files. The API listens on `http://localhost:5214` and the web client on `http://localhost:5012` by default. The `Publish Release` workflow builds the release images from the `linux-x64` publish folders to validate the image definitions, and does not upload them. The images you ship are built manually from the extracted `Nemera-<version>-linux-x64-api` and `Nemera-<version>-linux-x64-web` archives with `--platform linux/amd64`, or from the `linux-arm64` archives with `--platform linux/arm64`; the `linux-musl-x64` archives cannot be used with these images, because their base image is a glibc distribution. The Linux and macOS archives must be created on Linux or macOS, because Windows cannot store the executable bit in a tar archive: `Publish` on Windows creates only the Windows archives and warns that the others were skipped.
`Publish` restores the API and web projects once for all supported runtimes and publishes each runtime with `--no-restore`, so the projects keep a multi-RID assets file. The restore reads the runtime list from an environment variable set only for that command, so normal builds are unaffected.
The presentation host does not compile against the concrete plugin projects, and it does not own the bundled plugin catalog. The plugin projects are part of the solution and copy their outputs to the API plugin folder. `build.proj` owns the release catalog: it builds and hashes the plugin binaries, writes the current manifest, passes that manifest to the API publish, and copies the binaries into the published plugin folder. Adding or removing a bundled plugin changes the release catalog and the solution, not the host project. The presentation host does not compile against the concrete plugin projects, and it does not own the bundled plugin catalog. The plugin projects are part of the solution and copy their outputs to the API plugin folder. `build.proj` owns the release catalog: it builds and hashes the plugin binaries, writes the current manifest, passes that manifest to the API publish, and copies the binaries into the published plugin folder. Adding or removing a bundled plugin changes the release catalog and the solution, not the host project.
@@ -93,12 +95,12 @@ The token is used only by the `record-manifest` job. It is not available to the
## Workflows ## Workflows
- `Publish Release` runs when the owner creates a `release/x.y.z` branch. It has two jobs: - `Publish Release` runs when the owner creates a `release/x.y.z` branch. It has two jobs:
- `publish`: builds and publishes the official artifacts with `OfficialReleaseBuild=true`, runs the manifest verification tests, verifies the published API assembly against the published plugin binaries, records the released plugin hashes, builds the release images from the verified publish output, and uploads the `release-api`, `release-web` and `bundled-plugins-manifest` artifacts. It has the license secret and a read-only token. - `publish`: builds and publishes the official artifacts with `OfficialReleaseBuild=true`, runs the manifest verification tests, verifies the embedded plugin manifest against every published API folder, checks every runtime's native folders and files, verifies every archive against its publish folder, records the released plugin hashes, builds the release images from the verified publish output, and uploads the `release-archives` and `bundled-plugins-manifest` artifacts. The `release-archives` artifact contains the API and web archives for every supported runtime. It has the license secret and a read-only token.
- `record-manifest`: downloads the manifest artifact, appends only the release entries that are missing from master's current trust list, and opens the `other/record-release-x.y.z` pull request to `master` with the `RELEASE_PR_TOKEN`. It does not have the license secret. - `record-manifest`: downloads the manifest artifact, appends only the release entries that are missing from master's current trust list, and opens the `other/record-release-x.y.z` pull request to `master` with the `RELEASE_PR_TOKEN`. It does not have the license secret.
- `Run All Tests` runs on pull requests to `master` and uses the repository `SIXLABORS_LICENSE_KEY` secret. - `Run All Tests` runs on pull requests to `master` and uses the repository `SIXLABORS_LICENSE_KEY` secret.
- `Branch Push Naming Convention Check` and `Pull Request Source Branch Validation Check` allow `feature/`, `bugfix/`, `hotfix/`, `documentation/`, `refactor/`, `other/`, and `release/x.y.z`. - `Branch Push Naming Convention Check` and `Pull Request Source Branch Validation Check` allow `feature/`, `bugfix/`, `hotfix/`, `documentation/`, `refactor/`, `other/`, and `release/x.y.z`.
The release branch is built from `master` after the normal pull request checks have passed. The release build does not rerun the full test suite. It runs the manifest verification tests, because that is the only part of the build that changes when the official plugin manifest and the official release marker are embedded. It then verifies the published API assembly against the published plugin binaries before recording hashes or building images. The trust-list pull request runs the full suite before it can be merged. The release branch is built from `master` after the normal pull request checks have passed. The release build does not rerun the full test suite. It runs the manifest verification tests, because that is the only part of the build that changes when the official plugin manifest and the official release marker are embedded. It then verifies the embedded plugin manifest against every published API folder, the native folders and files of every runtime, and the contents of every archive before recording hashes or building images. The trust-list pull request runs the full suite before it can be merged.
Recording is CI-only. The publish job checks that the worktree is clean and that `HEAD` matches `origin/master` before it appends to the trust list. A local `RecordBundledPlugins` run is rejected by the guard. Recording is CI-only. The publish job checks that the worktree is clean and that `HEAD` matches `origin/master` before it appends to the trust list. A local `RecordBundledPlugins` run is rejected by the guard.
@@ -111,26 +113,29 @@ The trust list `build/BundledPlugins.manifest` is append-only. Never remove exis
3. Create the `release/x.y.z` branch from the current `master` as the owner. The publish job requires the branch to point at the current `origin/master`. The check is exact: if anything merges to `master` before the job runs, the job fails and the branch must be recreated from the new `master`. 3. Create the `release/x.y.z` branch from the current `master` as the owner. The publish job requires the branch to point at the current `origin/master`. The check is exact: if anything merges to `master` before the job runs, the job fails and the branch must be recreated from the new `master`.
4. Approve the `release` environment for the `publish` and `record-manifest` jobs. 4. Approve the `release` environment for the `publish` and `record-manifest` jobs.
5. Wait for `Publish Release` to publish and verify the official artifacts, record the trust list and build the release images. 5. Wait for `Publish Release` to publish and verify the official artifacts, record the trust list and build the release images.
6. Download the `release-api` and `release-web` artifacts. 6. Download the `release-archives` artifact. It contains one API archive and one web archive for each supported runtime identifier.
7. Create the GitHub release and tag manually from those artifacts. The workflow does not create the release. 7. Create the GitHub release and tag manually from those archives. The workflow does not create the release.
8. Wait for `Run All Tests` and both branch validators on the `other/record-release-1.2.3` pull request. Review the trust-list diff and merge it. 8. Wait for `Run All Tests` and both branch validators on the `other/record-release-1.2.3` pull request. Review the trust-list diff and merge it.
9. The workflow builds the release images from the verified publish output to validate the image definitions, but it does not upload them. Build the images you ship from the downloaded artifacts, so they contain exactly the plugin binaries whose hashes were recorded: 9. The workflow builds the release images from the verified publish output to validate the image definitions, but it does not upload them. Build the images you ship from the extracted archives, so they contain exactly the plugin binaries whose hashes were recorded:
```bash ```bash
docker build -t nemera-api:1.2.3 -f src/Nemera.Presentation.Api/Dockerfile.release <release-api-directory> docker build --platform linux/amd64 -t nemera-api:1.2.3 -f src/Nemera.Presentation.Api/Dockerfile.release <extracted-api-folder>
docker build -t nemera-web:1.2.3 -f src/Nemera.Presentation.Web/Dockerfile.release <release-web-directory> docker build --platform linux/amd64 -t nemera-web:1.2.3 -f src/Nemera.Presentation.Web/Dockerfile.release <extracted-web-folder>
``` ```
Extract `Nemera-1.2.3-linux-x64-api.tar.gz` and `Nemera-1.2.3-linux-x64-web.tar.gz` first. Each archive contains its publish files at the root, so the extracted folder is the Docker context. Use `--platform linux/arm64` with the `linux-arm64` archives. The `linux-musl-x64` archives cannot be used with these images, because their base image is a glibc distribution.
To publish, verify and build in one local step instead, run: To publish, verify and build in one local step instead, run:
```bash ```bash
dotnet msbuild build/build.proj -t:Docker -p:Configuration=Release -p:OfficialReleaseBuild=true -p:Version=1.2.3 dotnet msbuild build/build.proj -t:Docker -p:Configuration=Release -p:OfficialReleaseBuild=true -p:Version=1.2.3
``` ```
That target publishes from source, verifies the publish output and builds the images from it. Those images are not the exact released artifacts unless the build is byte-identical, so prefer the downloaded artifacts for the images you ship. That target publishes from source, verifies the publish output and builds the images from the `linux-x64` publish folder with the `linux/amd64` platform derived from `ApiReleaseRuntimeIdentifier`. Pass `-p:ApiReleaseRuntimeIdentifier=linux-arm64` to build from the arm64 publish folder instead. Those images are not the exact released artifacts unless the build is byte-identical, so prefer the downloaded archives for the images you ship.
The local equivalent of the official build is verification only. Recording is CI-only. The release workflow checks that the checkout is clean and that `HEAD` matches `origin/master` exactly before it appends to the trust list. The local equivalent of the official build is verification only. Recording is CI-only. The release workflow checks that the checkout is clean and that `HEAD` matches `origin/master` exactly before it appends to the trust list.
```bash ```bash
dotnet msbuild build/build.proj -t:VerifyPublishedBundledPlugins -p:Configuration=Release -p:OfficialReleaseBuild=true dotnet msbuild build/build.proj -t:VerifyPublishedBundledPlugins -p:Configuration=Release -p:OfficialReleaseBuild=true -p:Version=1.2.3
``` ```
`VerifyPublishedBundledPlugins` checks the publish folders and does not require `bin/release`. `CreateReleaseArchives` can run on its own after a publish, and `VerifyReleaseArchives` creates the archives if needed and verifies every archive against its publish folder; both must run on Linux or macOS, because Windows cannot create `.tar.gz` archives with the executable bit. The Docker target only needs the publish folders, so `-t:Docker -p:ReusePublishedBundledPlugins=true` works even when `bin/release` is absent. `ReusePublishedBundledPlugins=true` skips both the publish and its verification, so pass it only after the publish folders were just verified, as the release workflow does. The release Docker target derives `--platform` from `ApiReleaseRuntimeIdentifier`, which must be `linux-x64` (`linux/amd64`) or `linux-arm64` (`linux/arm64`); `linux-musl-x64` has no matching glibc image base.
For a local Release build, set `SixLaborsLicenseKey` to the content of `src/Nemera.Domain/sixlabors.lic` first. The file alone is only discovered by `Nemera.Domain`, and projects that reference ImageSharp through it fail license validation otherwise. For a local Release build, set `SixLaborsLicenseKey` to the content of `src/Nemera.Domain/sixlabors.lic` first. The file alone is only discovered by `Nemera.Domain`, and projects that reference ImageSharp through it fail license validation otherwise.
## Revoking a bundled plugin hash ## Revoking a bundled plugin hash
@@ -184,5 +189,8 @@ If the token is compromised, also review recent branches, pull requests and work
| `RecordBundledPlugins` fails because `master` moved | The release branch no longer matches the current `origin/master`. | Recreate the `release/x.y.z` branch from the new `master` and approve the new run. | | `RecordBundledPlugins` fails because `master` moved | The release branch no longer matches the current `origin/master`. | Recreate the `release/x.y.z` branch from the new `master` and approve the new run. |
| The record-list pull request removes trust-list lines | The merge step was skipped, or master's current manifest was replaced with an older artifact. | The record job only appends missing entries and fails if the staged diff removes a line. Rerun the workflow. | | The record-list pull request removes trust-list lines | The merge step was skipped, or master's current manifest was replaced with an older artifact. | The record job only appends missing entries and fails if the staged diff removes a line. Rerun the workflow. |
| A known good plugin is not Official | A deny-list entry matches its hash. | Remove the matching line from `build/BundledPlugins.deny.manifest`. | | A known good plugin is not Official | A deny-list entry matches its hash. | Remove the matching line from `build/BundledPlugins.deny.manifest`. |
| `VerifyPublishedBundledPlugins` fails | The manifest embedded in the published API assembly does not match the published plugin binaries. | Re-run the release build from the same commit. Do not mix artifacts from different builds. | | `VerifyPublishedBundledPlugins` fails | The bundled plugin staging folder is missing a native folder the catalog declares or contains an undeclared one, a published runtime folder is missing its assembly, apphost, plugin binary or native file, still contains a PDB or an undeclared native runtime folder or an unexpected number of plugin binaries, its embedded plugin manifest does not match its plugin binaries, or its plugin binaries differ from the reference `linux-x64` folder. | Re-run the release build from the same commit. Do not mix artifacts from different builds. If the staging folder and the catalog disagree, align `build/RuntimeIdentifiers.props` with the native folders the bundled plugins deploy. |
| The release image build fails with an official configuration error | `Docker` was called with `OfficialReleaseBuild=true` and a configuration other than `Release`. | Pass `-p:Configuration=Release`. | | `VerifyReleaseArchives` fails | A platform archive is missing, or its files or hashes differ from the publish folder it was built from, or the Linux or macOS app host is not executable inside the archive. | Re-run the release build from the same commit, so the archives and the publish folders come from the same build. Build Linux and macOS archives on Linux or macOS. |
| The Linux or macOS archives are missing after `Publish` | `Publish` ran on Windows, which cannot store the executable bit in a tar archive, so those archives are skipped with a warning. | Run `Publish` on Linux or macOS. The `Publish Release` workflow builds the released archives on `ubuntu-latest`. |
| The release build rejects the version | `Version` or `ReleaseVersion` is not three numeric parts. | Pass a version such as `-p:Version=1.2.3`. |
| The release image build fails with an official configuration error | `Docker` was called with `OfficialReleaseBuild=true` and a configuration other than `Release`, or with an `ApiReleaseRuntimeIdentifier` that is not a glibc runtime (`linux-x64` or `linux-arm64`; the musl runtime has no matching image base). | Pass `-p:Configuration=Release` and a glibc runtime identifier such as `linux-x64`. |
+1 -2
View File
@@ -1,11 +1,10 @@
<Project> <Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..'))" /> <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..'))" />
<Import Project="$(MSBuildThisFileDirectory)../build/RuntimeIdentifiers.props" />
<!-- Shared warning and documentation policy for every plugin project under plugins. --> <!-- Shared warning and documentation policy for every plugin project under plugins. -->
<PropertyGroup> <PropertyGroup>
<BaseOutputPath>$(RepoRoot)bin/plugins/</BaseOutputPath> <BaseOutputPath>$(RepoRoot)bin/plugins/</BaseOutputPath>
<!-- The real runtime identifiers the release artifact supports. Every bundled plugin with native dependencies must provide its libraries for each of them. The OS family fallback folders, such as osx, are kept automatically. -->
<BundledPluginRuntimeIdentifiers>win-x64;win-arm64;linux-x64;linux-arm64;linux-musl-x64;osx-x64;osx-arm64</BundledPluginRuntimeIdentifiers>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors><!--Public members must have XML documentation.--> <WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors><!--Public members must have XML documentation.-->
@@ -11,10 +11,11 @@
<Compile Include="..\..\src\AssemblyInfo_Shared.cs" Link="Properties\AssemblyInfo_Shared.cs" /> <Compile Include="..\..\src\AssemblyInfo_Shared.cs" Link="Properties\AssemblyInfo_Shared.cs" />
</ItemGroup> </ItemGroup>
<!-- The supported runtimes come from the shared bundled plugin property. Each runtime also uses an OS family fallback folder, where the native dependency packages keep the libraries shared by every architecture of that operating system. --> <!-- The supported runtimes come from the shared bundled plugin runtime list. Each runtime also uses an OS family fallback folder, where the native dependency packages keep the libraries shared by every architecture of that operating system. -->
<Target Name="DefinePdfRuntimeLibraries"> <Target Name="DefinePdfRuntimeLibraries">
<Error Condition="'@(BundledPluginRuntime)' == ''" Text="The bundled plugin runtime list is empty. Restore the BundledPluginRuntime items in build/RuntimeIdentifiers.props." />
<ItemGroup> <ItemGroup>
<_SupportedPdfRuntime Include="$(BundledPluginRuntimeIdentifiers)" /> <_SupportedPdfRuntime Include="@(BundledPluginRuntime)" />
<_WindowsPdfRuntime Include="@(_SupportedPdfRuntime)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('win-'))"> <_WindowsPdfRuntime Include="@(_SupportedPdfRuntime)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('win-'))">
<PdfFamily>win</PdfFamily> <PdfFamily>win</PdfFamily>
</_WindowsPdfRuntime> </_WindowsPdfRuntime>
+2 -3
View File
@@ -62,9 +62,8 @@ WORKDIR /app
# The app user must own the published files, because the plugin installer writes into /app/plugins. # The app user must own the published files, because the plugin installer writes into /app/plugins.
COPY --from=publish --chown=app:app /app/publish . COPY --from=publish --chown=app:app /app/publish .
# The HTTP port is controlled per run mode: launchSettings.json for local development, ASPNETCORE_HTTP_PORTS here for # The container branch in Program.cs binds the API to this port. Direct published runs default to the documented address
# Docker, and for a published DLL run directly on a host, ASPNETCORE_URLS (or ASPNETCORE_HTTP_PORTS) must be set. # and can override it with ASPNETCORE_URLS, ASPNETCORE_HTTP_PORTS or ASPNETCORE_HTTPS_PORTS.
ENV ASPNETCORE_HTTP_PORTS=5214
EXPOSE 5214 EXPOSE 5214
ENTRYPOINT ["dotnet", "Nemera.Presentation.Api.dll"] ENTRYPOINT ["dotnet", "Nemera.Presentation.Api.dll"]
@@ -1,6 +1,6 @@
# This image ships the published release artifacts, so the recorded plugin hashes and the image contents are the same files. # This image ships the published release artifacts, so the recorded plugin hashes and the image contents are the same files.
# Build it with the published API directory as the context: # Build it with the extracted Linux x64 API archive as the context.
# docker build -t nemera-api -f src/Nemera.Presentation.Api/Dockerfile.release bin/api/publish # docker build -t nemera-api -f src/Nemera.Presentation.Api/Dockerfile.release <extracted-Nemera-version-linux-x64-api>
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
# Curl is used by the container healthcheck to probe the /health endpoints. # Curl is used by the container healthcheck to probe the /health endpoints.
@@ -16,6 +16,6 @@ WORKDIR /app
# The app user must own the published files, because the plugin installer writes into /app/plugins. # The app user must own the published files, because the plugin installer writes into /app/plugins.
COPY --chown=app:app . . COPY --chown=app:app . .
ENV ASPNETCORE_HTTP_PORTS=5214 # The container branch in Program.cs binds the API to this port.
EXPOSE 5214 EXPOSE 5214
ENTRYPOINT ["dotnet", "Nemera.Presentation.Api.dll"] ENTRYPOINT ["dotnet", "Nemera.Presentation.Api.dll"]
@@ -9,6 +9,8 @@
<ContainerRepository>nemera-api</ContainerRepository> <ContainerRepository>nemera-api</ContainerRepository>
<DockerfileTag>nemera-api</DockerfileTag> <DockerfileTag>nemera-api</DockerfileTag>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<!-- The release restore sets this environment variable to restore every supported runtime in one pass. -->
<RuntimeIdentifiers Condition="'$(NEMERA_RELEASE_RUNTIME_IDENTIFIERS)' != ''">$(NEMERA_RELEASE_RUNTIME_IDENTIFIERS)</RuntimeIdentifiers>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(OfficialReleaseBuild)' == 'true'"> <PropertyGroup Condition="'$(OfficialReleaseBuild)' == 'true'">
<DefineConstants>$(DefineConstants);OFFICIAL_RELEASE_BUILD</DefineConstants> <DefineConstants>$(DefineConstants);OFFICIAL_RELEASE_BUILD</DefineConstants>
+9
View File
@@ -74,7 +74,16 @@ public class Program
}); });
} }
else else
{
logPath = Path.Combine(AppContext.BaseDirectory, "logs"); // Use local binary path. logPath = Path.Combine(AppContext.BaseDirectory, "logs"); // Use local binary path.
// A published build used to fall back to the framework's port 5000. Keep the documented default only when the host
// did not provide an address or a port through configuration, including ASPNETCORE_URLS, ASPNETCORE_HTTP_PORTS
// and ASPNETCORE_HTTPS_PORTS.
if (string.IsNullOrWhiteSpace(builder.Configuration["Urls"])
&& string.IsNullOrWhiteSpace(builder.Configuration["HTTP_PORTS"])
&& string.IsNullOrWhiteSpace(builder.Configuration["HTTPS_PORTS"]))
builder.WebHost.UseUrls("http://localhost:5214");
}
Directory.CreateDirectory(logPath); Directory.CreateDirectory(logPath);
if (!logPath.EndsWith(Path.DirectorySeparatorChar.ToString())) if (!logPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
logPath = logPath += Path.DirectorySeparatorChar; logPath = logPath += Path.DirectorySeparatorChar;
+2 -3
View File
@@ -47,9 +47,8 @@ FROM base AS final
WORKDIR /app WORKDIR /app
COPY --from=publish --chown=app:app /app/publish . COPY --from=publish --chown=app:app /app/publish .
# The HTTP port is controlled per run mode: launchSettings.json for local development, ASPNETCORE_HTTP_PORTS here for # The container branch in Program.cs binds the web client to this port. Direct published runs default to the documented
# Docker, and for a published DLL run directly on a host, ASPNETCORE_URLS (or ASPNETCORE_HTTP_PORTS) must be set. # address and can override it with ASPNETCORE_URLS, ASPNETCORE_HTTP_PORTS or ASPNETCORE_HTTPS_PORTS.
ENV ASPNETCORE_HTTP_PORTS=5012
EXPOSE 5012 EXPOSE 5012
ENTRYPOINT ["dotnet", "Nemera.Presentation.Web.dll"] ENTRYPOINT ["dotnet", "Nemera.Presentation.Web.dll"]
@@ -1,6 +1,6 @@
# This image ships the published release artifacts, so the image contents are the same files the release workflow exported. # This image ships the published release artifacts, so the image contents are the same files the release workflow exported.
# Build it with the published Web directory as the context: # Build it with the extracted Linux x64 Web archive as the context.
# docker build -t nemera-web -f src/Nemera.Presentation.Web/Dockerfile.release bin/web/publish # docker build -t nemera-web -f src/Nemera.Presentation.Web/Dockerfile.release <extracted-Nemera-version-linux-x64-web>
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
# Curl is used by the container healthcheck to probe the /health endpoints. # Curl is used by the container healthcheck to probe the /health endpoints.
@@ -14,6 +14,6 @@ WORKDIR /app
COPY --chown=app:app . . COPY --chown=app:app . .
ENV ASPNETCORE_HTTP_PORTS=5012 # The container branch in Program.cs binds the web client to this port.
EXPOSE 5012 EXPOSE 5012
ENTRYPOINT ["dotnet", "Nemera.Presentation.Web.dll"] ENTRYPOINT ["dotnet", "Nemera.Presentation.Web.dll"]
@@ -11,6 +11,8 @@
<ContainerRepository>nemera-web</ContainerRepository> <ContainerRepository>nemera-web</ContainerRepository>
<DockerfileTag>nemera-web</DockerfileTag> <DockerfileTag>nemera-web</DockerfileTag>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<!-- The release restore sets this environment variable to restore every supported runtime in one pass. -->
<RuntimeIdentifiers Condition="'$(NEMERA_RELEASE_RUNTIME_IDENTIFIERS)' != ''">$(NEMERA_RELEASE_RUNTIME_IDENTIFIERS)</RuntimeIdentifiers>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+12 -3
View File
@@ -1,8 +1,5 @@
#region ========================================================================= USING ===================================================================================== #region ========================================================================= USING =====================================================================================
using FastEndpoints; using FastEndpoints;
using Nemera.Presentation.Web.Common.DependencyInjection;
using Nemera.Presentation.Web.Common.HealthChecks;
using Nemera.Presentation.Web.Common.Utilities;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@@ -11,6 +8,9 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using Nemera.Presentation.Web.Common.DependencyInjection;
using Nemera.Presentation.Web.Common.HealthChecks;
using Nemera.Presentation.Web.Common.Utilities;
using Scalar.AspNetCore; using Scalar.AspNetCore;
using Serilog; using Serilog;
using System; using System;
@@ -50,7 +50,16 @@ public class Program
builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(5012)); // HTTP only. builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(5012)); // HTTP only.
} }
else else
{
logPath = Path.Combine(AppContext.BaseDirectory, "logs"); // Use local binary path. logPath = Path.Combine(AppContext.BaseDirectory, "logs"); // Use local binary path.
// A published build used to fall back to the framework's port 5000. Keep the documented default only when the host
// did not provide an address or a port through configuration, including ASPNETCORE_URLS, ASPNETCORE_HTTP_PORTS
// and ASPNETCORE_HTTPS_PORTS.
if (string.IsNullOrWhiteSpace(builder.Configuration["Urls"])
&& string.IsNullOrWhiteSpace(builder.Configuration["HTTP_PORTS"])
&& string.IsNullOrWhiteSpace(builder.Configuration["HTTPS_PORTS"]))
builder.WebHost.UseUrls("http://localhost:5012");
}
Directory.CreateDirectory(logPath); Directory.CreateDirectory(logPath);
if (!logPath.EndsWith(Path.DirectorySeparatorChar.ToString())) if (!logPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
logPath = logPath += Path.DirectorySeparatorChar; logPath = logPath += Path.DirectorySeparatorChar;
+1
View File
@@ -366,6 +366,7 @@
<File Path="../global.json" /> <File Path="../global.json" />
<File Path="../build/build.proj" /> <File Path="../build/build.proj" />
<File Path="../build/BundledPlugins.props" /> <File Path="../build/BundledPlugins.props" />
<File Path="../build/RuntimeIdentifiers.props" />
<File Path="../build/BundledPlugins.manifest" /> <File Path="../build/BundledPlugins.manifest" />
<File Path="../build/BundledPlugins.deny.manifest" /> <File Path="../build/BundledPlugins.deny.manifest" />
<File Path="../src/Nemera.Presentation.Api/Dockerfile.release" /> <File Path="../src/Nemera.Presentation.Api/Dockerfile.release" />
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
#endregion
namespace Nemera.Presentation.Api.IntegrationTests.Common.Setup;
/// <summary>
/// Reads an embedded resource from an assembly file without loading the assembly into the current process.
/// </summary>
/// <remarks>
/// The published bundled plugin manifest verification inspects publish folders of other architectures, where loading the assembly would fail.
/// </remarks>
[ExcludeFromCodeCoverage]
public static class PublishedAssemblyResourceReader
{
/// <summary>
/// Reads an embedded resource from an assembly file without loading the assembly into the current process.
/// </summary>
/// <param name="assemblyPath">The absolute path of the assembly file.</param>
/// <param name="resourceName">The name of the embedded resource.</param>
/// <returns>The raw bytes of the embedded resource.</returns>
public static byte[] ReadEmbeddedResource(string assemblyPath, string resourceName)
{
using (FileStream assemblyStream = File.OpenRead(assemblyPath))
{
using (PEReader peReader = new(assemblyStream))
{
// A publish folder without managed metadata means the wrong artifact was passed, so fail instead of reporting a missing resource.
if (!peReader.HasMetadata)
throw new InvalidOperationException($"The assembly '{assemblyPath}' does not contain managed metadata.");
MetadataReader metadataReader = peReader.GetMetadataReader();
foreach (ManifestResourceHandle resourceHandle in metadataReader.ManifestResources)
{
ManifestResource resource = metadataReader.GetManifestResource(resourceHandle);
// A resource with a non-null implementation is linked from another file, so its bytes are not stored in this resources directory.
if (!metadataReader.StringComparer.Equals(resource.Name, resourceName) || !resource.Implementation.IsNil)
continue;
// The embedded payloads live in the PE resources directory, and every resource offset is relative to the start of that directory.
PEMemoryBlock resourceDirectory = peReader.GetSectionData(peReader.PEHeaders.CorHeader!.ResourcesDirectory.RelativeVirtualAddress);
BlobReader resourceReader = resourceDirectory.GetReader((int)resource.Offset, resourceDirectory.Length - (int)resource.Offset);
// Every embedded resource is prefixed with a four-byte length before its payload.
int resourceLength = resourceReader.ReadInt32();
return resourceReader.ReadBytes(resourceLength);
}
}
}
// Returning empty bytes would let the manifest verification compare against nothing, so a missing resource is treated as a broken artifact.
throw new InvalidOperationException($"The embedded resource '{resourceName}' is missing from '{assemblyPath}'.");
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
#endregion
namespace Nemera.Presentation.Api.IntegrationTests.Common.Setup;
/// <summary>
/// Contains integration tests for the <see cref="PublishedAssemblyResourceReader"/> test helper.
/// </summary>
[ExcludeFromCodeCoverage]
public class PublishedAssemblyResourceReaderTests
{
/// <summary>
/// The resource name of the append-only trust list of previously released bundled plugin binaries.
/// </summary>
private const string HISTORICAL_MANIFEST_RESOURCE_NAME = "Nemera.Presentation.Api.BundledPlugins.historical.manifest";
[Fact]
public void ReadEmbeddedResource_WhenReadingTheLoadedAssemblyFile_ShouldMatchTheLoadedResourceStream()
{
// Arrange
// The loaded assembly's file is read directly, which is the same path the published artifact verification uses.
string assemblyPath = typeof(Program).Assembly.Location;
byte[] expectedResourceBytes;
using (Stream resourceStream = typeof(Program).Assembly.GetManifestResourceStream(HISTORICAL_MANIFEST_RESOURCE_NAME)
?? throw new InvalidOperationException($"The embedded manifest resource '{HISTORICAL_MANIFEST_RESOURCE_NAME}' is missing."))
{
using (MemoryStream resourceBuffer = new())
{
resourceStream.CopyTo(resourceBuffer);
expectedResourceBytes = resourceBuffer.ToArray();
}
}
// Act
byte[] actualResourceBytes = PublishedAssemblyResourceReader.ReadEmbeddedResource(assemblyPath, HISTORICAL_MANIFEST_RESOURCE_NAME);
// Assert
Assert.Equal(expectedResourceBytes, actualResourceBytes);
}
}
@@ -7,8 +7,6 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Xml.Linq; using System.Xml.Linq;
#endregion #endregion
@@ -217,41 +215,30 @@ public class BundledPluginManifestReaderTests
?? throw new InvalidOperationException($"The environment variable '{PUBLISH_DIRECTORY_ENVIRONMENT_VARIABLE}' is not set."); ?? throw new InvalidOperationException($"The environment variable '{PUBLISH_DIRECTORY_ENVIRONMENT_VARIABLE}' is not set.");
string publishedApiAssemblyPath = BundledPluginManifestTestPaths.GetPublishedApiAssemblyPath(publishDirectory); string publishedApiAssemblyPath = BundledPluginManifestTestPaths.GetPublishedApiAssemblyPath(publishDirectory);
string publishedPluginsDirectory = BundledPluginManifestTestPaths.GetPublishedPluginsDirectory(publishDirectory); string publishedPluginsDirectory = BundledPluginManifestTestPaths.GetPublishedPluginsDirectory(publishDirectory);
// Load the published API assembly in its own context, so the test reads the exact shipped binary without loading it into the test process. // Read the resource directly from the file. Loading the assembly would fail for a runtime whose architecture differs from the test process.
AssemblyLoadContext loadContext = new("PublishedBundledPluginManifestVerification", isCollectible: true); byte[] publishedManifestBytes = PublishedAssemblyResourceReader.ReadEmbeddedResource(publishedApiAssemblyPath, CURRENT_MANIFEST_RESOURCE_NAME);
try using (MemoryStream manifestStream = new(publishedManifestBytes))
{ {
Assembly publishedApiAssembly = loadContext.LoadFromAssemblyPath(publishedApiAssemblyPath); // Act
// The published assembly must embed the current manifest. A missing resource means the official publish step did not run. IReadOnlyDictionary<string, IReadOnlySet<string>> publishedManifestEntries = BundledPluginManifestReader.ReadExpectedChecksums(manifestStream);
using (Stream manifestStream = publishedApiAssembly.GetManifestResourceStream(CURRENT_MANIFEST_RESOURCE_NAME)
?? throw new InvalidOperationException("The published API assembly does not embed the current bundled plugin manifest."))
{
// Act
IReadOnlyDictionary<string, IReadOnlySet<string>> publishedManifestEntries = BundledPluginManifestReader.ReadExpectedChecksums(manifestStream);
// Assert // Assert
Assert.NotEmpty(publishedManifestEntries); Assert.NotEmpty(publishedManifestEntries);
// The manifest and the published plugin folder must agree exactly: every entry has a file, and the counts match. // The manifest and the published plugin folder must agree exactly: every entry has a file, and the counts match.
string[] publishedPluginAssemblyFileNames = [.. Directory.EnumerateFiles(publishedPluginsDirectory, BundledPluginManifestTestPaths.PLUGIN_ASSEMBLY_SEARCH_PATTERN) string[] publishedPluginAssemblyFileNames = [.. Directory.EnumerateFiles(publishedPluginsDirectory, BundledPluginManifestTestPaths.PLUGIN_ASSEMBLY_SEARCH_PATTERN)
.Select(Path.GetFileName) .Select(Path.GetFileName)
.OfType<string>()]; .OfType<string>()];
Assert.Equal(publishedManifestEntries.Count, publishedPluginAssemblyFileNames.Length); Assert.Equal(publishedManifestEntries.Count, publishedPluginAssemblyFileNames.Length);
foreach (KeyValuePair<string, IReadOnlySet<string>> entry in publishedManifestEntries) foreach (KeyValuePair<string, IReadOnlySet<string>> entry in publishedManifestEntries)
{ {
Assert.Contains(entry.Key, publishedPluginAssemblyFileNames, StringComparer.OrdinalIgnoreCase); Assert.Contains(entry.Key, publishedPluginAssemblyFileNames, StringComparer.OrdinalIgnoreCase);
string publishedAssemblyPath = Path.Combine(publishedPluginsDirectory, entry.Key); string publishedAssemblyPath = Path.Combine(publishedPluginsDirectory, entry.Key);
Assert.True(File.Exists(publishedAssemblyPath), $"The published plugin assembly '{entry.Key}' is missing from '{publishedPluginsDirectory}'."); Assert.True(File.Exists(publishedAssemblyPath), $"The published plugin assembly '{entry.Key}' is missing from '{publishedPluginsDirectory}'.");
string actualSha256 = _bundledPluginFileHashFixture.Create(publishedAssemblyPath); string actualSha256 = _bundledPluginFileHashFixture.Create(publishedAssemblyPath);
string expectedSha256 = Assert.Single(entry.Value); string expectedSha256 = Assert.Single(entry.Value);
Assert.Equal(expectedSha256, actualSha256, ignoreCase: true); Assert.Equal(expectedSha256, actualSha256, ignoreCase: true);
}
} }
} }
finally
{
// Unload the collectible context so the published assembly does not stay locked for later test runs.
loadContext.Unload();
}
} }
/// <summary> /// <summary>
@@ -285,8 +272,8 @@ public class BundledPluginManifestReaderTests
{ {
using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream(resourceName) using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream(resourceName)
?? throw new InvalidOperationException($"The embedded manifest resource '{resourceName}' is missing.")) ?? throw new InvalidOperationException($"The embedded manifest resource '{resourceName}' is missing."))
using (StreamReader reader = new(stream)) using (StreamReader reader = new(stream))
return reader.ReadToEnd(); return reader.ReadToEnd();
} }
/// <summary> /// <summary>