I have a Photino.Blazor project which due to some oddities in _content
depending on debug/release/publish outputs we ended up having to manually add the following content to the csproj which ensures that there is always the expected static files being output in a consistent way.
<Target Name="_StaticWebAssetsComputeFilesToBuild" AfterTargets="GetCopyToOutputDirectoryItems" DependsOnTargets="ResolveStaticWebAssetsInputs">
<ItemGroup>
<!-- Filter the static web assets foreign to the project and then add them to the list of resolved
files to publish.
-->
<_ExternalBuildStaticWebAsset Include="%(StaticWebAsset.FullPath)" Condition="'%(SourceType)' != ''">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>$([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\%(BasePath)\%(RelativePath)'))'))</TargetPath>
</_ExternalBuildStaticWebAsset>
<!-- Remove any existing external static web asset that might have been added as part of the
regular publish pipeline. -->
<_SourceItemsToCopyToOutputDirectory Remove="@(_ExternalBuildStaticWebAsset)" />
<_SourceItemsToCopyToOutputDirectory Include="@(_ExternalBuildStaticWebAsset)" />
</ItemGroup>
</Target>
This worked fine until we installed .net 9 (even if the project is still targetting .net 8), and then if you do a dotnet build the.csproj
it blows up because .net 9 adds a fingerprinting feature which seems to always be on and alters how static files are handled.
So the above code which worked in .net 8 will no longer work once .net 9 is installed, giving the error:
13>Microsoft.Common.CurrentVersion.targets(5322,5): Error MSB3021 : Unable to copy file "E:\Code\open-source\REDACTED\wwwroot\webfonts\quicksand\Quicksand-SemiBold.ttf" to "bin\Debug\net8.0\wwwroot_content\REDACTED\webfonts\quicksand\Quicksand-SemiBold#[.{fingerprint}]?.ttf". The filename, directory name, or volume label syntax is incorrect. : 'E:\Code\open-source\REDACTED\bin\Debug\net8.0\wwwroot_content\REDACTED\webfonts\quicksand\Quicksand-SemiBold#[.{fingerprint}]?.ttf'.
As you can see its now adding #[.{fingerprint}]?
to the output which never used to happen and is unwanted, so is there any way to turn off this feature within .net 9? as ideally I want to upgrade to .net 9 at some point, but I want it to stop trying to post process the static files.
You could try either of these properties
<PropertyGroup>
<StaticWebAssetFingerprintingEnabled>false</StaticWebAssetFingerprintingEnabled>
<StaticWebAssetsFingerprintContent>false</StaticWebAssetsFingerprintContent>
</PropertyGroup>