C
C#5d ago
Grofit

✅ Web project used to work, now msbuild failing but nothing has changed in the source

I have just opened up a project that was working fine last time I was compiling it (lets say 6 months ago), since then only thing I can think of that I have done is install .net 9, but other than that nothing has changed with .net to my knowledge. The projects in question are still targetting .net 8 anyway. So with that out of the way whenever I try to compile a Microsoft.NET.Sdk.Razor project which contains a section to copy static content:
<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>
<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>
Which blows up now because its adding #[.{fingerprint}]? into the destination file output for some reason, which never used to happen and says its unable to copy due to bad label syntax. (Will post more info on that on separate message as running out of characters in this one).
5 Replies
Grofit
GrofitOP5d ago
To give more context as I was running out of space. The msbuild logic used to just go through all the static content in the wwwroot path and copy it to the output path explicitly as it didnt correctly get copied before. Anyway this has been working fine until now and whenever I try to build this project it blows up saying:
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'.
The odd thing is that it looks like its adding some #[.{fingerprint}]? section in which it never used to and now makes the destination invalid, so has anyone else seen this happen before? Its ok problem solved or at least understood, since I installed .net 9 the dotnet cli is now using version 9 by default, so this must have some incompatibility with the above logic, which works fine in 8 so explicitly adding a global.json with the sdk.version being 8.0.100 (previous one I have installed from dotnet --list-sdks) it builds as expected No idea how you mark posts here as resolved etc so feel free to do so or close it 😄
MODiX
MODiX5d ago
If you have no further questions, please use /close to mark the forum thread as answered
Grofit
GrofitOP5d ago
I dont have permissions to use the close command apparently
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
Grofit
GrofitOP4d ago
"Your other left"

Did you find this page helpful?