Open kaleidocore opened 1 day ago
I also get this problem in .NET 8 Microsoft.NET.Sdk.Razor projects after installing .NET 9 SDK / VS 17.12:
5> Using "DefineStaticWebAssets" task from assembly "C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\..\tasks\net472\Microsoft.NET.Sdk.StaticWebAssets.Tasks.dll".
5> Task "DefineStaticWebAssets"
5> Task Parameter:RelativePathPattern=wwwroot/**
5> Task Parameter:SourceType=Discovered
5> Task Parameter:
5> FingerprintPatterns=
5> Initializer
5> Expression=#[.{fingerprint}]!
5> Pattern=*.lib.module.js
5> MvcJsModule
5> Pattern=*.cshtml.js
5> ComponentsJsModule
5> Pattern=*.razor.js
5> MvcScopedCss
5> Pattern=*.cshtml.css
5> ComponentsScopedCss
5> Pattern=*.razor.css
5> JsModuleManifest
5> Pattern=*.modules.json
5> Task Parameter:SourceId=MyProject
5> Task Parameter:FingerprintCandidates=True
5> Task Parameter:
5> CandidateAssets=
5> wwwroot\background.png
5> CopyToOutputDirectory=Never
5> CopyToPublishDirectory=PreserveNewest
5> ExcludeFromSingleFile=true
5> wwwroot\tlab.css
5> CopyToOutputDirectory=Never
5> CopyToPublishDirectory=PreserveNewest
5> ExcludeFromSingleFile=true
5> wwwroot\tlab.min.css
5> CopyToOutputDirectory=Never
5> CopyToPublishDirectory=PreserveNewest
5> ExcludeFromSingleFile=true
5> tsconfig.json
5> CopyToOutputDirectory=Never
5> CopyToPublishDirectory=PreserveNewest
5> ExcludeFromSingleFile=true
5> _Imports.razor
5> CopyToOutputDirectory=Never
5> ExcludeFromSingleFile=true
5> Pack=false
5> Scripts\init.ts
5> CopyToOutputDirectory=Never
5> Scripts\tlab.ts
5> CopyToOutputDirectory=Never
5> Styles\tlab.scss
5> CopyToOutputDirectory=Never
5> Styles\height.scss
5> CopyToOutputDirectory=Never
5> Styles\scroll.scss
5> CopyToOutputDirectory=Never
5> Styles\width.scss
5> CopyToOutputDirectory=Never
5> Task Parameter:ContentRoot=F:\source\MyProject\wwwroot\
5> Task Parameter:BasePath=_content/MyProject
5> Accepted asset 'wwwroot\background.png' for pattern 'wwwroot/**' with relative path 'background.png'
5> Computing fingerprint and integrity for asset 'wwwroot\background.png'
5> Fingerprinting asset 'background.png' as 'background#[.{fingerprint}]?.png' because it didn't match any pattern
5> Accepted asset 'wwwroot\tlab.css' for pattern 'wwwroot/**' with relative path 'tlab.css'
5> Computing fingerprint and integrity for asset 'wwwroot\tlab.css'
5> C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error : System.InvalidOperationException: No file exists for the asset at either location 'wwwroot\tlab.css' or 'wwwroot\tlab.css'.
5> C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error : at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.ComputeFingerprintAndIntegrity(String identity, String originalItemSpec)
5> C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error : at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssets.Execute()
5> Done executing task "DefineStaticWebAssets" -- FAILED.
The .css files are compiled with BuildWebCompiler2022 from .scss.
Is there an existing issue for this?
Describe the bug
After upgrading to VS 17.12.0 / .Net9 SDK: Solution Rebuild fails during fingerprinting of static assets, if those assets are (re-)produced during build.
In particular this applies to TypeScript files that are compiled to
.js
files underwwwroot/
during the build process, using the standardMicrosoft.TypeScript.MSBuild
(5.6.2) nuget.This worked in VS 17.11.x / .Net8 SDK. The project is a .Net8 project.
NB: It is also unclear why fingerprinting is even applied to .Net8 projects, and how to turn it off.
Expected Behavior
Rebuild should not fail. Analysis of static assets produced during build should be scheduled so that fingerprinting succeeds.
Steps To Reproduce
Minimal repro here: https://github.com/kaleidocore/TSBuildFail
The minimal repro is based on the basic TypeScript template/example described here: https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-aspnet-with-typescript?view=vs-2022
Typically Clean+Build succeeds, but Rebuild fails.
Exceptions (if any)
.NET Version
9.0.100
Anything else?
Other static assets produced during build also fails in the same way, e.g. .scss -> .css using WebCompiler.
A temporary workaround for the issue is to force a downgrade of the .Net SDK using a
global.json
in the root folder:I believe the core of this issue is actually much older, but the new Fingerprinting feature puts focus on it by failing completely, whereas it previously sort of "worked" - we have had very similar issues when publishing our projects (
dotnet publish solution.sln ...
) in previous versions of Visual Studio / .Net. It often appears random or timing based whether those same static files produced during build are actually included in the publish output. We've had to work around it by adding additional build steps such as Clean, Build, Publish and running it single-threaded.I also suspect these issues are related: https://github.com/dotnet/aspnetcore/issues/57147 https://github.com/dotnet/aspnetcore/issues/58748